text:
<?xml version="1.0" encoding="utf-8"?>
<comment>
		<sentence>
				<text>pohvale na brzoj dostavi , u mamilu je pisalo kako pizza stiže za 40min a stigla je za 20min . </text>
				<pairs>
						<pair aspect="dostavi" anchor="pohvale" link="+" sent="+" />
						<pair aspect="pizza" anchor="pohvale" link="" sent="" />
						<pair aspect="stiže" anchor="pohvale" link="" sent="" />
						<pair aspect="stigla" anchor="pohvale" link="" sent="" />
						<pair aspect="dostavi" anchor="brzoj" link="+" sent="+" />
						<pair aspect="pizza" anchor="brzoj" link="" sent="" />
						<pair aspect="stiže" anchor="brzoj" link="" sent="" />
						<pair aspect="stigla" anchor="brzoj" link="" sent="" />
				</pairs>
		</sentence>
		<sentence>
				<text>pizza jako ukusna </text>
				<pairs>
						<pair aspect="pizza" anchor="ukusna" link="+" sent="+" />
				</pairs>
		</sentence>
</comment>

redpajama_set_name: RedPajamaGithub


text:
#include "../include/fiol.h"

#ifdef DEBUG
/*!
 * Read a 8bit data in Big Endian from a binary string.
 *
 * \param src The string to read from
 * \param dst The var where to store the read value
 *
 * \return Number of bytes read
 */
uint8_t fiolBRead8BE(const unsigned char* src, int8_t* dst)
{
    if(src == NULL)
        return 0;

    if(dst != NULL)
    {
        (*dst) = src[0];
    }

    return 1;
}

/*!
 * Read a 16bit data in Big Endian from a binary string.
 *
 * \param src The string to read from
 * \param dst The var where to store the read value
 *
 * \return Number of bytes read
 */
uint8_t fiolBRead16BE(const unsigned char* src, int16_t* dst)
{
    if(src == NULL)
        return 0;

    if(dst != NULL)
    {
        (*dst) = (src[0] << 8) + src[1];
    }

    return 2;
}

/*!
 * Read a 32bit data in Big Endian from a binary string.
 *
 * \param src The string to read from
 * \param dst The var where to store the read value
 *
 * \return Number of bytes read
 */
uint8_t fiolBRead32BE(const unsigned char* src, int32_t* dst)
{
    if(src == NULL)
        return 0;

    if(dst != NULL)
    {
        (*dst) = (src[0] << 24) + (src[1] << 16) + (src[2] << 8) + src[3];
    }

    return 4;
}
#endif


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.hive;

import com.facebook.presto.spi.type.BigintType;
import com.facebook.presto.spi.type.BooleanType;
import com.facebook.presto.spi.type.DoubleType;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.spi.type.VarcharType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;

import javax.annotation.Nullable;

import java.util.Set;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.hadoop.hive.serde.Constants.BIGINT_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.BINARY_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.BOOLEAN_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.DOUBLE_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.FLOAT_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.INT_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.SMALLINT_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.STRING_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.TIMESTAMP_TYPE_NAME;
import static org.apache.hadoop.hive.serde.Constants.TINYINT_TYPE_NAME;
import static org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;

public final class HiveType
{
    public static final HiveType HIVE_BOOLEAN = new HiveType(BOOLEAN_TYPE_NAME);
    public static final HiveType HIVE_BYTE = new HiveType(TINYINT_TYPE_NAME);
    public static final HiveType HIVE_SHORT = new HiveType(SMALLINT_TYPE_NAME);
    public static final HiveType HIVE_INT = new HiveType(INT_TYPE_NAME);
    public static final HiveType HIVE_LONG = new HiveType(BIGINT_TYPE_NAME);
    public static final HiveType HIVE_FLOAT = new HiveType(FLOAT_TYPE_NAME);
    public static final HiveType HIVE_DOUBLE = new HiveType(DOUBLE_TYPE_NAME);
    public static final HiveType HIVE_STRING = new HiveType(STRING_TYPE_NAME);
    public static final HiveType HIVE_TIMESTAMP = new HiveType(TIMESTAMP_TYPE_NAME);
    public static final HiveType HIVE_BINARY = new HiveType(BINARY_TYPE_NAME);

    private static final Set<HiveType> SUPPORTED_HIVE_TYPES = ImmutableSet.of(HIVE_BOOLEAN, HIVE_BYTE, HIVE_SHORT, HIVE_INT, HIVE_LONG, HIVE_FLOAT, HIVE_DOUBLE, HIVE_STRING, HIVE_TIMESTAMP, HIVE_BINARY);

    private final String hiveTypeName;

    private HiveType(String hiveTypeName)
    {
        this.hiveTypeName = checkNotNull(hiveTypeName, "hiveTypeName is null");
    }

    @JsonValue
    public String getHiveTypeName()
    {
        return hiveTypeName;
    }

    public Category getCategory()
    {
        return TypeInfoUtils.getTypeInfoFromTypeString(hiveTypeName).getCategory();
    }

    public static HiveType getSupportedHiveType(String hiveTypeName)
    {
        HiveType hiveType = getHiveType(hiveTypeName);
        checkArgument(hiveType != null, "Unknown Hive type: " + hiveTypeName);
        return hiveType;
    }

    @JsonCreator
    @Nullable
    public static HiveType getHiveType(String hiveTypeName)
    {
        HiveType hiveType = new HiveType(hiveTypeName);
        if (!(hiveType.getCategory() == Category.LIST || hiveType.getCategory() == Category.MAP || hiveType.getCategory() == Category.STRUCT || SUPPORTED_HIVE_TYPES.contains(hiveType))) {
            return null;
        }
        return hiveType;
    }

    public static HiveType getSupportedHiveType(ObjectInspector fieldInspector)
    {
        HiveType hiveType = getHiveType(fieldInspector);
        checkArgument(hiveType != null, "Unknown Hive category: " + fieldInspector.getCategory());
        return hiveType;
    }

    public static HiveType getHiveType(ObjectInspector fieldInspector)
    {
        return getHiveType(fieldInspector.getTypeName());
    }

    public static HiveType toHiveType(Type type)
    {
        if (BooleanType.BOOLEAN.equals(type)) {
            return HIVE_BOOLEAN;
        }
        if (BigintType.BIGINT.equals(type)) {
            return HIVE_LONG;
        }
        if (DoubleType.DOUBLE.equals(type)) {
            return HIVE_DOUBLE;
        }
        if (VarcharType.VARCHAR.equals(type)) {
            return HIVE_STRING;
        }
        throw new IllegalArgumentException("unsupported type: " + type);
    }

    public static Function<Type, HiveType> columnTypeToHiveType()
    {
        return new Function<Type, HiveType>()
        {
            @Override
            public HiveType apply(Type type)
            {
                return toHiveType(type);
            }
        };
    }

    public static Function<HiveType, String> hiveTypeNameGetter()
    {
        return new Function<HiveType, String>()
        {
            @Override
            public String apply(HiveType type)
            {
                return type.getHiveTypeName();
            }
        };
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        HiveType hiveType = (HiveType) o;

        if (!hiveTypeName.equals(hiveType.hiveTypeName)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode()
    {
        return hiveTypeName.hashCode();
    }
}


text:
package com.flipkart.poseidon.sample.datatypes;

import flipkart.lego.api.entities.DataType;

import java.util.ArrayList;
import java.util.List;

public class PostsDataType implements DataType {
    private List<PostDataType> posts = new ArrayList<>();

    public List<PostDataType> getPosts() {
        return posts;
    }

    public void setPosts(List<PostDataType> posts) {
        this.posts = posts;
    }
}


text:
package org.hisp.dhis.tracker.bundle;

import static org.hisp.dhis.tracker.Assertions.assertNoErrors;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.io.IOException;
import java.util.List;

import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.program.notification.ProgramNotificationInstance;
import org.hisp.dhis.tracker.TrackerImportService;
import org.hisp.dhis.tracker.TrackerTest;
import org.hisp.dhis.tracker.report.TrackerImportReport;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author Zubair Asghar
 */
class TrackerSideEffectHandlerServiceTest extends TrackerTest
{
    @Autowired
    private TrackerImportService trackerImportService;

    @Autowired
    private IdentifiableObjectManager manager;

    @Override
    protected void initTest()
        throws IOException
    {
        setUpMetadata( "tracker/tracker_metadata_with_program_rules.json" );
        injectAdminUser();
    }

    @Test
    @Disabled( "Needs to be added once rule engine PR is merged" )
    void testRuleEngineSideEffectHandlerService()
        throws IOException
    {
        TrackerImportReport trackerImportReport = trackerImportService.importTracker( fromJson(
            "tracker/enrollment_data_with_program_rule_side_effects.json" ) );
        assertNoErrors( trackerImportReport );

        List<ProgramNotificationInstance> instances = manager.getAll( ProgramNotificationInstance.class );
        assertFalse( instances.isEmpty() );
        ProgramNotificationInstance instance = instances.get( 0 );
        assertEquals( "FdIeUL4gyoB", instance.getProgramNotificationTemplateSnapshot().getUid() );
    }
}


text:
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/types.h>

#include <asm/addrspace.h>
#include <asm/bootinfo.h>
#include <asm/dec/machtype.h>
#include <asm/dec/prom.h>
#include <asm/page.h>
#include <asm/sections.h>

volatile unsigned long mem_err;		/* So we know an error occurred */

/*
 * Probe memory in 4MB chunks, waiting for an error to tell us we've fallen
 * off the end of real memory.  Only suitable for the 2100/3100's (PMAX).
 */

#define CHUNK_SIZE 0x400000

static inline void pmax_setup_memory_region(void)
{
	volatile unsigned char *memory_page, dummy;
	char old_handler[0x80];
	extern char genexcept_early;

	/* Install exception handler */
	memcpy(&old_handler, (void *)(CKSEG0 + 0x80), 0x80);
	memcpy((void *)(CKSEG0 + 0x80), &genexcept_early, 0x80);

	/* read unmapped and uncached (KSEG1)
	 * DECstations have at least 4MB RAM
	 * Assume less than 480MB of RAM, as this is max for 5000/2xx
	 * FIXME this should be replaced by the first free page!
	 */
	for (memory_page = (unsigned char *)CKSEG1 + CHUNK_SIZE;
	     mem_err == 0 && memory_page < (unsigned char *)CKSEG1 + 0x1e00000;
	     memory_page += CHUNK_SIZE) {
		dummy = *memory_page;
	}
	memcpy((void *)(CKSEG0 + 0x80), &old_handler, 0x80);

	add_memory_region(0, (unsigned long)memory_page - CKSEG1 - CHUNK_SIZE,
			  BOOT_MEM_RAM);
}

/*
 * Use the REX prom calls to get hold of the memory bitmap, and thence
 * determine memory size.
 */
static inline void rex_setup_memory_region(void)
{
	int i, bitmap_size;
	unsigned long mem_start = 0, mem_size = 0;
	memmap *bm;

	/* some free 64k */
	bm = (memmap *)CKSEG0ADDR(0x28000);

	bitmap_size = rex_getbitmap(bm);

	for (i = 0; i < bitmap_size; i++) {
		/* FIXME: very simplistically only add full sets of pages */
		if (bm->bitmap[i] == 0xff)
			mem_size += (8 * bm->pagesize);
		else if (!mem_size)
			mem_start += (8 * bm->pagesize);
		else {
			add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
			mem_start += mem_size + (8 * bm->pagesize);
			mem_size = 0;
		}
	}
	if (mem_size)
		add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
}

void __init prom_meminit(u32 magic)
{
	if (!prom_is_rex(magic))
		pmax_setup_memory_region();
	else
		rex_setup_memory_region();
}

void __init prom_free_prom_memory(void)
{
	unsigned long end;

	/*
	 * Free everything below the kernel itself but leave
	 * the first page reserved for the exception handlers.
	 */

#if defined(CONFIG_DECLANCE) || defined(CONFIG_DECLANCE_MODULE)
	/*
	 * Leave 128 KB reserved for Lance memory for
	 * IOASIC DECstations.
	 *
	 * XXX: save this address for use in dec_lance.c?
	 */
	if (IOASIC)
		end = __pa(&_text) - 0x00020000;
	else
#endif
		end = __pa(&_text);

	free_init_pages("unused PROM memory", PAGE_SIZE, end);
}


text:
using System;
using System.Net;

namespace LegendaryClient.Logic.Region
{
    public sealed class KR : BaseRegion
    {
        public override string RegionName
        {
            get { return "KR"; }
        }

        public override string InternalName
        {
            get { return "KR"; }
        }

        public override string ChatName
        {
            get { return "kr"; }
        }

        //No known news URI for Korea
        public override Uri NewsAddress
        {
            get { return new Uri(""); }
        }

        public override string Server
        {
            get { return "prod.kr.lol.riotgames.com"; }
        }

        public override string LoginQueue
        {
            get { return "https://lq.kr.lol.riotgames.com/"; }
        }

        public override string Locale
        {
            get { return "ko_KR"; }
        }

        public override IPAddress[] PingAddresses
        {
            get
            {
                return new IPAddress[]
                {
                    //No known IP address
                };
            }
        }

        public override Uri SpectatorLink
        {
            get { return new Uri("http://QFKR1PROXY.kassad.in:8088/observer-mode/rest/"); }
        }

        public override string SpectatorIpAddress
        {
            get { return "110.45.191.11:80"; }
        }
    }
}


text:
require 'spec_helper'

describe 'Cistern::Collection' do
  class SampleService
    include Cistern::Client
  end

  class Drug < SampleService::Model
    identity :id
    attribute :name
  end

  class Drugs < SampleService::Collection
    model Drug

    def all
      load([{ id: 1 }, { id: 3, name: 'tom' }, { id: 2 }])
    end
  end

  class Tacs < SampleService::Collection
    cistern_method :toes
  end

  it 'should generate a default collection method' do
    expect(SampleService.new.drugs).not_to be_empty
  end

  it 'should allow for a specific collection name' do
    expect(SampleService.new).to respond_to(:toes)
    expect(SampleService.new).not_to respond_to(:tacs)
  end

  it 'should give to_s' do
    collection = Drugs.new
    expect(collection.to_s).not_to eq '[]'
    expect(collection.to_s.gsub(/:[^>]*/, '')).to eq(collection.all.to_s.gsub(/:[^>]*/, ''))
  end

  it 'should give size and count' do
    expect(Drugs.new.size).to eq(3)
    expect(Drugs.new.count).to eq(3)
  end

  it 'should give first' do
    expect(Drugs.new.first).to eq(Drug.new(id: 1))
  end

  it 'should give last' do
    expect(Drugs.new.last).to eq(Drug.new(id: 2))
  end

  it 'should reject' do
    expect(Drugs.new.reject { |m| m.id == 2 }).to eq([Drug.new(id: 1), Drug.new(id: 3)])
  end

  it 'should select' do
    expect(Drugs.new.select { |m| m.id == 2 }).to eq([Drug.new(id: 2)])
  end

  it 'should slice' do
    expect(Drugs.new.slice(0, 2)).to eq([Drug.new(id: 1), Drug.new(id: 3, name: 'tom')])
  end

  it 'should ==' do
    Drugs.new.all == Drugs.new.all
  end

  describe 'deprecation', :deprecated do
    class DeprecatedCollectionService
      include Cistern::Client
    end

    it 'responds to #service' do
      class DeprecationCollection < DeprecatedCollectionService::Collection
        service_method :deprecator
      end

      sample = DeprecatedCollectionService.new.deprecator
      expect(sample.service).to eq(sample.cistern)
    end
  end
end


text:
/*  Android NDK doesn't have its own ucontext.h */
#ifndef ucontext_h_seen
#define ucontext_h_seen

#include <asm/sigcontext.h>       /* for sigcontext */
#include <asm/signal.h>           /* for stack_t */

typedef struct ucontext {
        unsigned long uc_flags;
        struct ucontext *uc_link;
        stack_t uc_stack;
        struct sigcontext uc_mcontext;
        unsigned long uc_sigmask;
} ucontext_t;

#endif


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Arctic Alpine Mycology (New York), II 333 (1987)

#### Original name
Omphalia luteovitellina Pilát & Nannf., 1954

### Remarks
null


text:
<?xml version="1.0" encoding="UTF-8"?>
<service xmlns="urn:radl:service" name="nwv">
  <resources>
    <resource name="ibimpoej">
      <location uri="/hefcwyls/gibjrvav/{komvysev}/hdarcloc/{komvysev}"/>
    </resource>
  </resources>
</service>


text:
function Player() {}

function Player_ctor(player, name, cue) {
  player.name = name;
  player.ball_color = false;
  player.cue_color = cue;
}

Player.prototype.join_game = function(game, table) {
  this.game = game;
  this.table = table;
}

Player.prototype.mouse_down = function(vec) {}
Player.prototype.mouse_up = function(vec) {}
Player.prototype.mouse_move = function(vec) {}

Player.prototype.begin_shot = function() {
  this.table.begin_shot();
}

// -- Human --

function HumanPlayer(name, cue) {
  Player_ctor(this, name, cue);
}

HumanPlayer.prototype = new Player();

HumanPlayer.prototype.mouse_down = function(vec) {
  var table = this.table;
  if (!table.is_stable()) return;
  if (!table.shot) {
    this.begin_shot();
  }
  if (!table.ball_in_hand) {
    var cue_ball = table.cue_ball;
    if (vec.distance_from(cue_ball.position) < cue_ball.radius) {
      table.shot.set_cueball_strikepoint(cue_ball, vec);
    }
  }
}

HumanPlayer.prototype.mouse_up = function(vec) {
  var table = this.table;
  if (table.ball_in_hand) {
    var cue_ball = table.cue_ball;
    cue_ball.position = vec;
    if ( cue_ball.is_legal_ball_in_hand_position(table) ) {
      table.ball_in_hand = 0;
    }
  }
  else if (table.shot) {
    table.shot.adjust( vec );
    table.commit_shot();
  }
}

HumanPlayer.prototype.mouse_move = function(vec) {
  var table = this.table;
  if (table.ball_in_hand) {
    table.cue_ball.position = vec;
  }
  else if (table.shot && table.shot.start) {
    table.shot.adjust( vec );
  }
}

// -- Computer --

function ComputerPlayer(name, cue) {
  Player_ctor(this, name, cue);
}

ComputerPlayer.prototype = new Player();

ComputerPlayer.prototype.get_direct_shots = function(legal_balls, cueball) {
  var pockets = this.table.pockets;
  var candidates = [];
  for (var i = 0; i < legal_balls.length; i++) {
    var ball = legal_balls[i];
    for (var j = 0; j < pockets.length; j++) {
      var pocket = pockets[j];
      var candidate = ShotCandidate.direct_shot(
          this.table, cueball, ball, pocket);
      if (candidate.is_possible()) {
        if (DEBUG) console.log("direct", pocket, candidate);
        candidates.push(candidate);
      }
    }
  }
  return candidates;
}

ComputerPlayer.prototype.get_cushion_shots = function(legal_balls, cueball) {
  var pockets = this.table.pockets;
  var cushions = this.table.cushions;
  var candidates = [];
  for (var i = 0; i < cushions.length; i++) {
    var cushion = cushions[i];
    for (var j = 0; j < legal_balls.length; j++) {
      var ball = legal_balls[j];
      for (var k = 0; k < pockets.length; k++) {
        var pocket = pockets[k];
        var candidate = ShotCandidate.cueball_cushion_shot(
            this.table, cueball, cushion, pocket, ball);
        if (candidate.is_possible()) {
          if (DEBUG) console.log("cushion: ", candidate);
          candidates.push(candidate);
        }
      }
    }
  }
  return candidates;
}

ComputerPlayer.prototype.get_potting_candidates = function() {
  var pockets = this.table.pockets;
  var balls = this.table.balls;
  var game = this.game;
  var cue_ball = this.table.cue_ball;
  var cushions = this.table.cushions;
  var candidates = [];

  for (var object_ball_index = 0; object_ball_index < balls.length;
      object_ball_index++) {
    var object_ball = balls[object_ball_index];
    if (!game.ball_is_ok_to_hit(object_ball, this)) {
        continue;
    }

    for (var pot_ball_index = 0; pot_ball_index < balls.length;
        pot_ball_index++) {
      var pot_ball = balls[pot_ball_index];
      if (!game.ball_is_good_to_pot(pot_ball, this)) {
        continue;
      }

      for (var pocket_index = 0; pocket_index < pockets.length;
          pocket_index++) {
        var pocket = pockets[pocket_index];
        for (var cueball_cushion_index = 0;
            cueball_cushion_index <= cushions.length; cueball_cushion_index++) {
          // cueball_cushion null implies no cushion.
          var cueball_cushion = cushions[cueball_cushion_index];
          for (var object_ball_cushion_index = 0;
              object_ball_cushion_index <= cushions.length;
              object_ball_cushion_index++) {
            var object_ball_cushion = cushions[object_ball_cushion_index];
            var candidate = this.get_shot(
                cue_ball, cueball_cushion, object_ball, object_ball_cushion,
                pot_ball, pocket);
            if (candidate) {
              candidates.push(candidate);
            }
          }
        }
      }
    }
  }

  return candidates;
}

ComputerPlayer.prototype.get_shot = function(
    cueball, cueball_cushion, object_ball, object_ball_cushion, pot_ball,
    pocket) {
  if ((cueball_cushion || object_ball_cushion) && this.table.is_break_shot) {
    return null;
  }

  var shot_candidate = ShotCandidate.canon_shot(
      this.table, cueball, cueball_cushion, pocket,
      object_ball, object_ball_cushion, pot_ball);

  if (shot_candidate && shot_candidate.is_possible()) {
    if (this.game.ball_is_great_to_pot(pot_ball, this)) {
      shot_candidate.difficulty *= 0.6;
      shot_candidate.strength = shot_candidate.base_strength;
      shot_candidate.great_shot = true;
      if (!shot_candidate.cueball_cushion) {
        shot_candidate.spin_strength = 0;
        shot_candidate.difficulty *= 0.7;
      }
    }
    if (DEBUG) console.log("get_shot: ", shot_candidate);
    return shot_candidate;
  }

  return null;
}

ComputerPlayer.prototype.get_random_shots = function(legal_balls, cueball, count) {
  var candidates = [];
  for (var i = 0; i < count; i++) {
    var ball = legal_balls[i % legal_balls.length];
    var offset = polar_vector(
        Math.random() * ball.radius * 1.9, Math.random() * 2 * Math.PI );
    var aimpoint = offset.add(ball.position);
    var candidate = ShotCandidate.pocketless_shot(this.table, cueball, aimpoint, ball);
    if (candidate.is_possible()) {
      candidates.push(candidate);
    }
  }
  return candidates;
}

ComputerPlayer.prototype.grep_candidates = function(candidates, match_fn) {
  var match = [];

  for (var i = 0; i < candidates.length; ++i)  {
    if (match_fn(candidates[i])) {
      match.push(candidates[i]);
    }
  }

  return match;
}

ComputerPlayer.prototype.get_easy_shot_candidates = function(
    legal_balls, cueball) {
  var candidates = this.get_direct_shots(legal_balls, cueball);
  var easy = this.grep_candidates(candidates, function(candidate)
    { return candidate.is_possible() && candidate.is_easy() });
  return easy.length != 0;
}

ComputerPlayer.prototype.get_shot_candidates = function(legal_balls, cueball) {
  var candidates = this.get_potting_candidates();

  candidates = this.grep_candidates(
      candidates, function(candidate) {return candidate.is_possible()});

  if (candidates.length > 0) {
    var easy = this.grep_candidates(
        candidates, function(candidate) {return candidate.is_easy()});
    if (DEBUG) console.log("Easy: ", easy.length, easy);
    if (easy.length > 0) {
      return easy;
    }

    var moderate = this.grep_candidates(
        candidates, function(candidate) {return candidate.is_moderate()});
    moderate.sort(ShotCandidate.sort_by_difficulty);
    if (DEBUG) console.log("Moderate: ", moderate.length, moderate);
    if (moderate.length > 0) {
      var difficulty = moderate[0].difficulty * 1.5;
      var moderate = this.grep_candidates(moderate,
          function(candidate) { return candidate.difficulty < difficulty });
      return moderate;
    }
  }

  candidates = candidates.concat(this.get_random_shots(
      legal_balls, cueball, legal_balls.length * 20));

  if (candidates.length > 0) {
    var easy = this.grep_candidates(
        candidates, function(candidate) {return candidate.is_easy()});
    if (easy.length > 0) {
      return easy;
    }
    var hard = this.grep_candidates(
        candidates, function(candidate) {return candidate.is_possible()});
    if (hard.length > 0) {
      return hard;
    }
    return candidates;
  }

  var random_aimpoint = new Vector(Math.random() * 2 - 1, Math.random() - 0.5);
  if (DEBUG) console.log("RANDOM: ", random_aimpoint);
  return [ShotCandidate.random_shot(this.table, cueball, random_aimpoint)];
}

ComputerPlayer.prototype.set_ball_in_hand_position = function(legal_balls) {
  var table = this.table;
  var pockets = table.pockets;
  var cue_ball = table.cue_ball;
  var positions = [];
  for (var i = 0; i < 500; i++) {
    var position = table.random_position(cue_ball);
    cue_ball.position = position;
    if (cue_ball.is_legal_ball_in_hand_position(table, position) &&
        this.get_easy_shot_candidates(legal_balls, cue_ball)) {
      positions.push(position);
    }
  }
  if (positions.length == 0) {
    var bbox = table.legal_ball_in_hand_bounding_box();
    var width = bbox.right - bbox.left - 2 * cue_ball.radius;
    var height = bbox.bottom - bbox.top - 2 * cue_ball.radius;
    var x = bbox.left + (Math.random() * width) + cue_ball.radius;
    var y = bbox.top + (Math.random() * height) + cue_ball.radius;
    positions = [ new Vector(x, y) ];
  }

  var index = Math.floor(Math.random() * positions.length);
  cue_ball.position = positions[index];
}

ComputerPlayer.prototype.begin_shot = function() {
  var table = this.table;
  var game = this.game;

  var shot = table.begin_shot();

  var legal_balls = this.game.legal_balls(this);
  if (DEBUG) console.log("BEGIN COMPUTER SHOT");

  if (table.ball_in_hand) {
    this.set_ball_in_hand_position(legal_balls);
    table.ball_in_hand = 0;
  }

  var shot_candidates = this.get_shot_candidates(legal_balls, table.cue_ball);

  var delay = 700;
  var display_time = 500;
  setTimeout(function() { shot_candidates[0].begin_shot(shot) }, delay);

  var shots_to_show = shot_candidates.length;
  if (DEBUG) {
    display_time *= 2;
    //shots_to_show *= 5;
  } else if (shots_to_show > 5) {
    shots_to_show = 5;
  }

  function preview_shot(index) {
    delay += display_time;
    setTimeout(function() { shot_candidates[index].begin_shot(shot) }, delay);
  }

  for (var i = 1; i < shots_to_show; i++) {
    preview_shot(i % shot_candidates.length);
  }

  var index = this.select_shot(shot_candidates);
  var index = Math.floor(Math.random() * shot_candidates.length);

  preview_shot(index);

  delay += 1000;
  setTimeout(function() { shot_candidates[index].commit_shot(shot) }, delay);
}

// assume candidates.length > 0;
ComputerPlayer.prototype.select_shot = function(candidates) {
  if (candidates[0].great_shot) {
    return 0;
  }
  var cumulative = [];
  var total = 0;
  for (var i = 0; i < candidates.length; i++) {
    total += candidates[i].difficulty;
    cumulative.push(total);
  }
  var selection = Math.random() * total;
  for (var i = 0; i < cumulative.length; i++) {
    if (cumulative[i] > selection) {
      return cumulative.length - i - 1;
    }
  }
  return 0;
}


text:
import { Session } from './wd-interfaces';
/**
 * Defines a command which runs on the whole webdriver server - not against a particular session
 *
 * @param {string} method The method which the command uses (e.g. `'GET'`)
 * @param {string} path The path for the command.  Uses express URL notation, so you can use
 *   /element/:elementId/command to put the parameter `elementId` in the path
 * @param {function} exec The code server-side to actually execute the command.  Receives a list
 *   of all sessions and an object containing all the url + json parameters.  The returned value
 *   will be returned to the client, and can be a promise.
 */
export declare class GlobalCommand<T extends Session> {
    method: 'GET' | 'POST' | 'DELETE' | 'PUT';
    path: string;
    exec: (sessions: T[], params: {
        [name: string]: any;
    }) => any;
    constructor(method: 'GET' | 'POST' | 'DELETE' | 'PUT', path: string, exec: (sessions: T[], params: {
        [name: string]: any;
    }) => any);
}
/**
 * Defines a command whcih runs against a particular session.
 *
 * @param {string} method The method which the command uses (e.g. `'GET'`)
 * @param {string} path The path for the command.  Automatically has `/session/:sessionId` prepended
 *   to it.
 * @param {function} exec The code server-side to actually execute the command.  Receives the
 *   session indicated by `sessionId` and an object containing all the paramters.  If no such
 *   session can be found, throws an error indicating such.
 */
export declare class Command<T extends Session> {
    method: 'GET' | 'POST' | 'DELETE' | 'PUT';
    path: string;
    exec: (session: T, params: {
        [name: string]: any;
    }) => any;
    constructor(method: 'GET' | 'POST' | 'DELETE' | 'PUT', path: string, exec: (session: T, params: {
        [name: string]: any;
    }) => any);
    _globalize(): GlobalCommand<T>;
}


text:
package com.ing.baker.recipe.javadsl.interactions;

import com.ing.baker.recipe.annotations.FiresEvent;
import com.ing.baker.recipe.annotations.RequiresIngredient;
import com.ing.baker.recipe.javadsl.events.InteractionEventExample;
import com.ing.baker.recipe.javadsl.events.InteractionProvidedEvent;
import com.ing.baker.recipe.javadsl.events.InteractionProvidedEvent2;

public interface FiresTwoEventInteraction {
    @FiresEvent(oneOf = {InteractionProvidedEvent.class, InteractionProvidedEvent2.class})
    InteractionEventExample apply(@RequiresIngredient("initialIngredient") String initialIngredient);
}


text:
function errorPrefix(resourceName) {
  return 'DS.create(' + resourceName + ', attrs[, options]): ';
}

/**
 * @doc method
 * @id DS.async methods:create
 * @name create
 * @description
 * The "C" in "CRUD". Delegate to the `create` method of whichever adapter is being used (http by default) and inject the
 * result into the data store.
 *
 * ## Signature:
 * ```js
 * DS.create(resourceName, attrs[, options])
 * ```
 *
 * ## Example:
 *
 * ```js
 * DS.create('document', {
 *   author: 'John Anderson'
 * }).then(function (document) {
 *   document; // { id: 5, author: 'John Anderson' }
 *
 *   // The new document is already in the data store
 *   DS.get('document', document.id); // { id: 5, author: 'John Anderson' }
 * });
 * ```
 *
 * @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
 * @param {object} attrs The attributes with which to create the item of the type specified by `resourceName`.
 * @param {object=} options Configuration options. Also passed along to the adapter's `create` method. Properties:
 *
 * - `{boolean=}` - `useClass` - Whether to wrap the injected item with the resource's instance constructor.
 * - `{boolean=}` - `cacheResponse` - Inject the data returned by the adapter into the data store. Default: `true`.
 * - `{boolean=}` - `upsert` - If `attrs` already contains a primary key, then attempt to call `DS.update` instead. Default: `true`.
 * - `{boolean=}` - `eagerInject` - Eagerly inject the attributes into the store without waiting for a successful response from the adapter. Default: `false`.
 * - `{function=}` - `beforeValidate` - Override the resource or global lifecycle hook.
 * - `{function=}` - `validate` - Override the resource or global lifecycle hook.
 * - `{function=}` - `afterValidate` - Override the resource or global lifecycle hook.
 * - `{function=}` - `beforeCreate` - Override the resource or global lifecycle hook.
 * - `{function=}` - `afterCreate` - Override the resource or global lifecycle hook.
 *
 * @returns {Promise} Promise produced by the `$q` service.
 *
 * ## Resolves with:
 *
 * - `{object}` - `item` - A reference to the newly created item.
 *
 * ## Rejects with:
 *
 * - `{IllegalArgumentError}`
 * - `{NonexistentResourceError}`
 */
function create(resourceName, attrs, options) {
  var DS = this;
  var deferred = DS.$q.defer();

  try {
    var definition = DS.definitions[resourceName];
    var injected;

    options = options || {};

    if (!definition) {
      throw new DS.errors.NER(errorPrefix(resourceName) + resourceName);
    } else if (!DS.utils.isObject(attrs)) {
      throw new DS.errors.IA(errorPrefix(resourceName) + 'attrs: Must be an object!');
    }
    if (!('cacheResponse' in options)) {
      options.cacheResponse = true;
    }

    if (!('upsert' in options)) {
      options.upsert = true;
    }

    if (!('eagerInject' in options)) {
      options.eagerInject = definition.eagerInject;
    }

    if (!('notify' in options)) {
      options.notify = definition.notify;
    }

    deferred.resolve(attrs);

    if (options.upsert && attrs[definition.idAttribute]) {
      return DS.update(resourceName, attrs[definition.idAttribute], attrs, options);
    } else {
      return deferred.promise
        .then(function (attrs) {
          var func = options.beforeValidate ? DS.$q.promisify(options.beforeValidate) : definition.beforeValidate;
          return func.call(attrs, resourceName, attrs);
        })
        .then(function (attrs) {
          var func = options.validate ? DS.$q.promisify(options.validate) : definition.validate;
          return func.call(attrs, resourceName, attrs);
        })
        .then(function (attrs) {
          var func = options.afterValidate ? DS.$q.promisify(options.afterValidate) : definition.afterValidate;
          return func.call(attrs, resourceName, attrs);
        })
        .then(function (attrs) {
          var func = options.beforeCreate ? DS.$q.promisify(options.beforeCreate) : definition.beforeCreate;
          return func.call(attrs, resourceName, attrs);
        })
        .then(function (attrs) {
          if (options.notify) {
            DS.emit(definition, 'beforeCreate', DS.utils.merge({}, attrs));
          }
          if (options.eagerInject && options.cacheResponse) {
            attrs[definition.idAttribute] = attrs[definition.idAttribute] || DS.utils.guid();
            injected = DS.inject(resourceName, attrs);
          }
          return DS.adapters[options.adapter || definition.defaultAdapter].create(definition, options.serialize ? options.serialize(resourceName, attrs) : definition.serialize(resourceName, attrs), options);
        })
        .then(function (res) {
          var func = options.afterCreate ? DS.$q.promisify(options.afterCreate) : definition.afterCreate;
          var attrs = options.deserialize ? options.deserialize(resourceName, res) : definition.deserialize(resourceName, res);
          return func.call(attrs, resourceName, attrs);
        })
        .then(function (attrs) {
          if (options.notify) {
            DS.emit(definition, 'afterCreate', DS.utils.merge({}, attrs));
          }
          if (options.cacheResponse) {
            var resource = DS.store[resourceName];
            if (options.eagerInject) {
              var newId = attrs[definition.idAttribute];
              var prevId = injected[definition.idAttribute];
              var prev = DS.get(resourceName, prevId);
              resource.previousAttributes[newId] = resource.previousAttributes[prevId];
              resource.changeHistories[newId] = resource.changeHistories[prevId];
              resource.observers[newId] = resource.observers[prevId];
              resource.modified[newId] = resource.modified[prevId];
              resource.saved[newId] = resource.saved[prevId];
              resource.index.put(newId, prev);
              DS.eject(resourceName, prevId, { notify: false });
              prev[definition.idAttribute] = newId;
              resource.collection.push(prev);
            }
            var created = DS.inject(resourceName, attrs, options);
            var id = created[definition.idAttribute];
            resource.completedQueries[id] = new Date().getTime();
            resource.previousAttributes[id] = DS.utils.deepMixIn({}, created);
            resource.saved[id] = DS.utils.updateTimestamp(resource.saved[id]);
            return DS.get(resourceName, id);
          } else {
            return DS.createInstance(resourceName, attrs, options);
          }
        })
        .catch(function (err) {
          if (options.eagerInject && options.cacheResponse) {
            DS.eject(resourceName, injected[definition.idAttribute], { notify: false });
          }
          return DS.$q.reject(err);
        });
    }
  } catch (err) {
    deferred.reject(err);
    return deferred.promise;
  }
}

module.exports = create;


text:
class Application;
struct PhysBody3D;

class Module
{
private :
	bool enabled;

public:

	Module(bool start_enabled = true)
	{}

	virtual ~Module()
	{}

	virtual bool Init()
	{
		return true;
	}

	virtual bool Start()
	{
		return true;
	}

	virtual bool Gui_Engine_Modules(float dt)
	{
		return true;
	}

	virtual bool LoadConfig(JSON_Object* node)
	{
		return true;
	}

	virtual bool SaveConfig(JSON_Object* node)const
	{
		return true;
	}

	virtual update_status PreUpdate(float dt)
	{
		return UPDATE_CONTINUE;
	}

	virtual update_status Update(float dt)
	{
		return UPDATE_CONTINUE;
	}

	virtual update_status PostUpdate(float dt)
	{
		return UPDATE_CONTINUE;
	}

	virtual bool CleanUp()
	{
		return true;
	}
	virtual void StartTimer() {
		this->module_timer->Start();

	};
	virtual void PauseTimer() {
		this->module_timer->Pause();

	};
	virtual void ResumeTimer() {
		this->module_timer->Resume();

	};
	virtual void StopTimer() {
		this->module_timer->Stop();

	}

	virtual void OnCollision(PhysBody3D* body1, PhysBody3D* body2)
	{}
public:
	Timer* module_timer;
	std::string name = "";

	float performance[90] = { 0 };
	int performance_offset = 0;
};


text:
namespace CppNet
{
	namespace System
	{
		interface _AppDomain
		{
			virtual void GetTypeInfoCount(UInt32& pcTInfo) const;
		};

		class AppDomain
		{

		};
	}
}

#endif


text:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ESRI.ArcGIS.Catalog;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.GeoDatabaseExtensions;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Editor;

namespace ParcelFabricQualityControl
{
  public class AddQCLayers : ESRI.ArcGIS.Desktop.AddIns.Button
  {
    static public string AssemblyDirectory
    {
      get
      {
        string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
        UriBuilder uri = new UriBuilder(codeBase);
        string path = Uri.UnescapeDataString(uri.Path);
        return System.IO.Path.GetDirectoryName(path);
      }
    }

    public AddQCLayers()
    {
    }

    protected override void OnClick()
    {
      IArray LineLyrArr;
      IArray PolygonLyrArr;
      IActiveView pActiveView = ArcMap.Document.ActiveView;
      IMap pMap = pActiveView.FocusMap;

      Utilities Utils = new Utilities();

      if (!Utils.GetFabricSubLayers(pMap, esriCadastralFabricTable.esriCFTLines, out LineLyrArr))
        return;

      if (!Utils.GetFabricSubLayers(pMap, esriCadastralFabricTable.esriCFTParcels, out PolygonLyrArr))
        return;

      IFeatureLayer pFlyr = (IFeatureLayer)LineLyrArr.get_Element(0);
      IFeatureClass pFabricLinesFC = pFlyr.FeatureClass;

      pFlyr = (IFeatureLayer)PolygonLyrArr.get_Element(0);
      IFeatureClass pFabricParcelsFC = pFlyr.FeatureClass;

      IProjectedCoordinateSystem2 pPCS = null;

      IGeoDataset pGeoDS = (IGeoDataset)pFabricLinesFC;
      ISpatialReference pFabricSpatRef = pGeoDS.SpatialReference;

      double dMetersPerUnit = 1;
      bool bFabricIsInGCS = !(pFabricSpatRef is IProjectedCoordinateSystem2);
      if (pFabricSpatRef != null)
      {
        if (!bFabricIsInGCS)
        {
          pPCS = (IProjectedCoordinateSystem2)pFabricSpatRef;
          dMetersPerUnit = pPCS.CoordinateUnit.MetersPerUnit;
        }
      }

      string fileName ="";
      if (dMetersPerUnit!=1)
        fileName = AssemblyDirectory + "\\QualityControlLayers\\QA Symbology Feet.lyr";
      else
        fileName = AssemblyDirectory + "\\QualityControlLayers\\QA Symbology Meters.lyr";
      bool bIsBefore1022 = false;
      string sBuild=Utils.GetDesktopBuildNumberFromRegistry();
      int iBuildNumber = 0;
      if (Int32.TryParse(sBuild, out iBuildNumber))
        bIsBefore1022 = iBuildNumber<3542; //CR278039 was fixed 10.2.2.3542

      AddQALayerToActiveView(pMap, pFabricLinesFC, pFabricParcelsFC, fileName, dMetersPerUnit, bIsBefore1022, bFabricIsInGCS);
    }

    protected override void OnUpdate()
    {
    }

    private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass,
      string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS)
    {
      if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr"))
      {
        return;
      }

      IWorkspace pWS = SourceLineFeatureClass.FeatureDataset.Workspace;
      bool bIsPostGres = false;

      if (pWS.Type != esriWorkspaceType.esriLocalDatabaseWorkspace)
      {
        IDatabaseConnectionInfo2 connectionInfo2 = (IDatabaseConnectionInfo2)(pWS);
        bIsPostGres = (connectionInfo2.ConnectionDBMS == esriConnectionDBMS.esriDBMS_PostgreSQL);

      }

      // Create a new GxLayer
      IGxLayer gxLayer = new GxLayerClass();
      IGxFile gxFile = (IGxFile)gxLayer;

      // Set the path for where the layerfile is located on disk
      gxFile.Path = layerPathFile;

      // Test if we have a valid layer and add it to the map
      if (!(gxLayer.Layer == null))
      {
        if (!(gxLayer.Layer is ICompositeLayer))
          return;
        ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer;
        for (int i=0; i<pCompLyr.Count; i++)
        {
          ILayer pLyr = pCompLyr.get_Layer(i);
          //
          if (pLyr is IFeatureLayer)
          {
            IFeatureLayer pFlyr = (IFeatureLayer)pLyr;
            //now update the definition query
            IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr;
            string sLyrName = pFlyr.Name;
            bool bExc = false;
            if (sLyrName.Contains("Minus"))
            {
              pFlyr.FeatureClass = SourceLineFeatureClass;
              bExc = false;

              SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);
              if (bExc || bFabricIsInGCS)
              {
                int jj=pFlyr.FeatureClass.FindField("ComputedMinusObserved");
                if (jj>-1)
                {
                  string sVal = (0.1 / metersPerUnit).ToString("0.00");
                  string sCminusO=pFlyr.FeatureClass.Fields.get_Field(jj).Name;
                  pFeatLyrDef.DefinitionExpression = "(" + sCminusO + " > " + sVal + " OR " + sCminusO + " < -" + sVal + ") AND (" + sCminusO + " IS NOT NULL)";

                  if (bIsPostGres)
                    pFeatLyrDef.DefinitionExpression = "(((st_length(shape) - distance) > " + sVal +
                      " OR (st_length(shape) - distance) < -" + sVal + " OR (distance - st_length(shape)) > " + sVal +
                      " OR  (distance - st_length(shape)) < -" + sVal +
                      ") AND (radius IS NULL AND (densifytype IS NULL OR densifytype <> 3))  AND category <> 4) OR ( ( ((st_length(shape) - arclength) > " + sVal +
                      " OR (st_length(shape) - arclength) < -" + sVal + ")    OR (arclength - st_length(shape)) > " + sVal +
                      " OR  (arclength - st_length(shape)) < -" + sVal + ") AND ( NOT arclength IS NULL ) )"; //this is query for ST_Geometry as well as PG_Geometry
                }
                continue;
              }

              string s = pFeatLyrDef.DefinitionExpression;
              int iField = SourceLineFeatureClass.FindField("ArcLength");
              if (iField > -1)
              {

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ArcLength", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("Category");
              if (iField > -1)
              {

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"Category\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Category", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("Radius");
              if (iField > -1)
              {

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"Radius\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Radius", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("Distance");
              if (iField > -1)
              {

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Distance", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("DensifyType");
              if (iField > -1)
              {
                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"DensifyType\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("DensifyType", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              pFeatLyrDef.DefinitionExpression = s.Replace("\"Shape_Length\"", SourceLineFeatureClass.LengthField.Name);
              pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name);

            }
            else if (sLyrName.Contains("Parcel"))
            { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present.
              //Can test if the release is 10.1 and knock out the def query, or else exclude the layers.

              string s = pFeatLyrDef.DefinitionExpression;
              int iField=SourcePolygonFeatureClass.FindField("MiscloseDistance");
              string s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
              pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2);
              pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("MiscloseDistance", s2);

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE");
              s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
              pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2);
              pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorE", s2);

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN");
              s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
              pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2);
              pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorN", s2);

              pFlyr.FeatureClass = SourcePolygonFeatureClass;
              SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);

              if (s.ToLower().Contains("power") && bIsBefore1022)
              {//remove the def query CR278039
                pFeatLyrDef.DefinitionExpression = "";
                continue;
              }

            }
          }
        }
        gxLayer.Layer.Name = "QA Symbology";

        IMxDocument pMXDoc = ArcMap.Document;
        IOperationStack pOpSt = pMXDoc.OperationStack;
        IAddLayersOperation pAddLyrOp = new AddLayersOperationClass();
        pAddLyrOp.SetDestinationInfo(0,map,null);
        pAddLyrOp.Name = "Add Fabric QA Layer";
        pAddLyrOp.AddLayer(gxLayer.Layer);
        IOperation pOp=(IOperation)pAddLyrOp;
        pOpSt.Do(pOp);
      }
    }

    private void SetLabelExpressionOnFeatureLayer(IFeatureLayer FeatLayer, out bool LabelExcluded)
    {
      string s = "";
      LabelExcluded = false;
      if (FeatLayer is IGeoFeatureLayer)
      {
        IGeoFeatureLayer pGeoFeatLyr = (IGeoFeatureLayer)FeatLayer;
        IAnnotateLayerPropertiesCollection pAnnoLyrPropsColl = pGeoFeatLyr.AnnotationProperties;
        IAnnotateLayerProperties pAnnoLyrProps; IElementCollection obj1; IElementCollection obj2;
        pAnnoLyrPropsColl.QueryItem(0, out pAnnoLyrProps, out obj1, out obj2);
        ILabelEngineLayerProperties LblEngProp = (ILabelEngineLayerProperties)pAnnoLyrProps;

        s = LblEngProp.Expression.ToLower();
        if (FeatLayer.FeatureClass.LengthField.Name.ToLower().Contains("st_length"))
        { //exclude the label on function generated field shape_length

          if (s.Contains("shape_length"))
          {
            LblEngProp.IsExpressionSimple = true;
            LblEngProp.Expression = "";
            LabelExcluded=true;
            return;
          }
        }

        LblEngProp.Expression = s.Replace("shape_length", FeatLayer.FeatureClass.LengthField.Name);

        IFeatureClass pFC = FeatLayer.FeatureClass;
        int iFld1 = pFC.Fields.FindField("shapestderrore");
        if (iFld1 > -1)
        {
          string s1 = pFC.Fields.get_Field(iFld1).Name;
          s = LblEngProp.Expression;
          LblEngProp.Expression = s.Replace("shapestderrore", s1);
        }

        int iFld2 = pFC.Fields.FindField("shapestderrorn");
        if (iFld2 > -1)
        {
          s = LblEngProp.Expression;
          string s2 = pFC.Fields.get_Field(iFld2).Name;
          LblEngProp.Expression = s.Replace("shapestderrorn", s2);
        }

      }
    }

  }
}


text:
require 'question/simple_choice'
require "question/simple_choice/version"
require "question/linked_list.rb"
require "question/simple_choice.rb"

  class SimpleChoice < Exam
    attr_accessor :text, :right, :distractor

    def initialize(args)
      @text = args[:text]
      raise ArgumentError, 'Specify :text' unless @text
      @right = args[:right]
      raise ArgumentError, 'Specify :right' unless @right
      @distractor = args[:distractor]
      raise ArgumentError, 'Specify :distractor' unless @distractor
    end

    def to_html
      @options = @distractor+[@right]
      @options = @options.shuffle# baraja
      s = ' '
      @options.each do |options|
		   s += %Q{<input type = "radio" value= "#{options}" name = 0 > #{options}\n}
      end
      botton = %Q{<input type="button" value="Enviar">}
	    #html=<<-"HTML"
	    "#{@text}<br/>\n#{s}\n#{botton}\n"
	    #HTML
    end

    def mostrar_pregunta
        "#{@text}"
    end

     def mostrar_respuestas
        "#{@options}"
     end

     def to_s
        valor = "\n#{@text}\n"
        @options.each do |opt|
          valor += "#{opt}\n"
        end
        valor
     end

     def <=> (other)
        @text <=> other.text
     end

  end #simplechoice

#no se ejecutara desde un require solo de consola
if __FILE__ == $0 then
    qq = Question::SimpleChoice.new(text: '2+5 =', right: 7, distractor: [2,5,10])
    puts qq.to_html
    #puts qq.mostrar_pregunta
    #puts qq.mostrar_respuestas
    #puts qq.to_s
end