text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using EnvDTE;
using EnvDTE80;

namespace CodeShare.SSMSPlugin.Common.Plugin
{
    public class WindowManager
    {
        private DTE2 _applicationObject;
        private AddIn _addInInstance;

        public WindowManager(DTE2 _applicationObject, AddIn _addInInstance)
        {
            this._applicationObject =_applicationObject;
            this._addInInstance = _addInInstance;
        }

        public Window CreateAddinWindow<T>(string caption)
            where T : class
        {
            return this.CreateAddinWindow<T>(caption, Guid.NewGuid());
        }

        public Window CreateAddinWindow<T>(string caption, Guid id)
            where T : class
        {
            return CreateToolWindow<T>(caption, id, _addInInstance);
        }

        public Window CreateToolWindow<T>(string caption, Guid uiTypeGuid, AddIn addinInstance)
            where T : class
        {
            Type type = typeof(T);

            Windows2 win2 = _applicationObject.Windows as Windows2;
            if (win2 != null)
            {
                object controlObject = null;
                Window toolWindow = win2.CreateToolWindow2(addinInstance, type.Assembly.Location, type.FullName, caption, "{" + uiTypeGuid.ToString() + "}", ref controlObject);
                toolWindow.Visible = true;
                return toolWindow;
            }

            return null;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
var SerialPort = require('serialport');
var PixelPusher = require('heroic-pixel-pusher');
var getPixels = require('get-pixels');
var fs = require('fs');
var q = require('q');
var gm = require('gm');

var files;
var debug;
var noise;
var teensy;

[files, debug, noise, teensy].forEach((debugMode) => {
  debugMode = function(){};
});

if (process.env.ENVIRONMENT == 'dev') {
  debug = require('ndebug')('info');
  noise = require('ndebug')('noise');
  teensy = require('ndebug')('teensy');
  files = require('ndebug')('files');
}

var imageFiles = [];
var currentFile = 0;
var teensyPort;

var RPM;
var SYNC;

var rpmReg = /\(smoothed\): ([0-9.]+)/ig;
var tickReg = /(TICK)/ig;
var teensyReg = /usb.+[0-9]+/i;

var teensySearchPeriod = 1000;
var imageChangePeriod = 15000;

var imageColumns = [];
var stripsArray = [];

readFilesFromDir();
nextFile();
loadFile().then(img => {
  debug(`loadFile() ${img} ready`);
});

var PixelInterface = function () {

  var vm = this;

  vm.PixelStrip = PixelPusher.PixelStrip;
  vm.PixelPusherInstance = new PixelPusher(); // will start listener.

  vm.UPDATE_FREQUENCY_MILLIS = 6;
  vm.PIXELS_PER_STRIP = 360;
  vm.exec = function () { return function () {} }; // NOP CLOSURE

  vm.timer;
  vm.controller;

  vm.updateTiming = function (timing) {
    if (typeof timing == 'number') {
      debug('Setting new timing to:', timing, 'ms');
      vm.UPDATE_FREQUENCY_MILLIS = timing;
      vm.resetTimer();
    }
  };

  vm.updateExecutable = function (exec) {
    if (typeof exec == 'function') {
      debug('Updating exec');
      vm.exec = exec;
      vm.resetTimer();
    }
  }

  vm.resetTimer = function () {
    if (!!vm.timer) {
      debug('Killing timer');
      clearTimeout(vm.timer);
      if (vm.isActive) {
        debug('Restarting loop');
        vm.timer = setInterval(function() {
          vm.exec();
        }, vm.UPDATE_FREQUENCY_MILLIS);
      }
    }
  }

  vm.waveRider = function(strips) {
    var waveWidth = 2;
    var waveHeight = vm.PIXELS_PER_STRIP / waveWidth;
    var wavePosition = 0;
    var startIdx;
    debug('init: waveRider');
    return function innerRider() {
      //debug('Call:', wavePosition);
      startIdx = waveHeight + wavePosition;
      for (var i = startIdx, j = waveWidth; i < vm.PIXELS_PER_STRIP &&  i > waveHeight && j > 0; i--, j--) {
          strips.forEach(function (strip) {
            strip.getPixel(i).setColor(255, 0, 255, (j / waveWidth) / 1.0);
          });
      }

      startIdx = waveHeight - wavePosition;
      for (var i = startIdx, j = waveWidth; i > 0 &&  i < waveHeight && j > 0; i++, j--) {
        strips.forEach(function (strip) {
          strip.getPixel(i).setColor(255, 0, 255, (j / waveWidth) / 1.0);
        });
      }

      strips.forEach(function (strip) {
        strip.getRandomPixel().setColor(0,0,255, 0.1);
      });
      //vm.controller.refresh(strips.map(function (strip) { return strip.getStripData();}));
      vm.controller.emit('data', strips.map(function (strip) { return strip.getStripData();}));

      strips.forEach(function (strip) {
        strip.clear();
      });

      wavePosition = (wavePosition + 1) % waveHeight;
    }
  }

  vm.isActive = false;

  vm.writeImage = function (strips) {
    var columnIter = 0;
    var column = [];
    var localImageCopy = [];
    return function writeColumns () {
      localImageCopy = [].concat.apply(imageColumns); // get a detached copy
      column = localImageCopy[columnIter];

      for (var i = 0; i < vm.PIXELS_PER_STRIP; i++) {
        strips.forEach(function (strip, stripIndex) {
          strip.getPixel(i).setColor(
            localImageCopy[columnIter][i][0], // R
            localImageCopy[columnIter][i][1], // G
            localImageCopy[columnIter][i][2] // B
          );
        });
      }

      strips.forEach(function (strip) {
        strip.getRandomPixel().setColor(0, 0, 255, 0.3);
      });

      vm.controller.emit('data', strips.map(function (strip) { return strip.getStripData();}));

      strips.forEach(function (strip) {
        strip.clear();
      });

      //debug(imageColumns[columnIter][0], imageColumns.length, columnIter);
      columnIter = (columnIter >= localImageCopy.length - 1) ? 0 : columnIter += 1;
      //columnIter = (columnIter + 1) % imageColumns.length;
    }
  }

  vm.PixelPusherInstance.on('discover', (controller) => {

    vm.controller = controller;
    vm.isActive = true;

    ['-----------------------------------',
     'Discovered PixelPusher on network: ',
     controller.params.pixelpusher,
     '-----------------------------------'].forEach(line => noise(line));

    // capture the update message sent back from the pp controller
    controller.on('update', () => {
      noise({ updatePeriod: controller.params.pixelpusher.updatePeriod, deltaSequence: controller.params.pixelpusher.deltaSequence, powerTotal: controller.params.pixelpusher.powerTotal });
    }).on('timeout', () => {
      debug('TIMEOUT : PixelPusher at address [' + controller.params.ipAddress + '] with MAC (' + controller.params.macAddress + ') has timed out. Awaiting re-discovery....');
      if (!!vm.timer) clearInterval(vm.timer);
      vm.isActive = false;
      vm.controller = null;
    });

    stripsArray = [];
    for (var i = 0; i < 1; i++) {
      stripsArray.push(new vm.PixelStrip(i, vm.PIXELS_PER_STRIP));
    }
    //var STRIPS_PER_PACKET = controller.params.pixelpusher.stripsPerPkt;
    //var NUM_PACKETS_PER_UPDATE = NUM_STRIPS/STRIPS_PER_PACKET;
    vm.PIXELS_PER_STRIP = controller.params.pixelpusher.pixelsPerStrip;

    vm.exec = vm.waveRider(stripsArray); // returns closure
//    vm.exec = vm.writeImage(stripsArray);

    vm.timer = setInterval(function() {
      vm.exec();
    }, vm.UPDATE_FREQUENCY_MILLIS);

  }).on('error', (err) => {
    vm.isActive = false;
    vm.controller = null;
    debug('PixelPusher Error: ' + err.message);
  });
};

var PixelPusherInterface = new PixelInterface();
//PixelPusherInterface.updateExecutable(oi);
//PixelPusherInterface.updateTiming(100);
currentFile = -1;

// Set the exec pattern

function readFilesFromDir() {
  items = fs.readdirSync('./data/');
  items = items.filter(item => {
    return /\.(jpg|jpeg|png)$/i.test(item);
  });
  items.forEach( (item, i) => {
    imageFiles[i] = './data/' + items[i];
  });
}

function nextFile() {
  currentFile++;
  currentFile = (currentFile >= imageFiles.length) ? 0 : currentFile;
}

function previousFile() {
  currentFile--;
  currentFile = (currentFile < 0) ? imageFiles.length - 1 : currentFile;
}

function getNDColumns(pixels) {
  var width = pixels.shape[0];
  var height = pixels.shape[1];
  imageColumns = [];
  for (var col = 0; col < width; col++) {
    imageColumns[col] = [];
    for (var row = 0; row < height; row++) {
      imageColumns[col].push([pixels.get(col, row, 0), pixels.get(col, row, 1), pixels.get(col, row, 2), pixels.get(col, row, 3)]);
    }
  }
}

function loadFile() {
  var deferred = q.defer();
  debug('Working on:', imageFiles[currentFile]);
  var resized = imageFiles[currentFile].replace(/data\//g, 'data/resized/').replace(/\.png/g, '.jpg');
  gm(imageFiles[currentFile])
    .quality(100)
    .resize(360, 360)
    .write(resized, function (err) {
      if (!err) {
        debug('done');
        getPixels(resized, function(err, pixels) {
          getNDColumns(pixels);
          deferred.resolve(resized);
        });
      } else {
        console.log(err);
      }
  });
  return deferred.promise;
}

function parseDataFromRing(data) {
  var matches = rpmReg.exec(data);
  if (matches && matches[1] != null) {
    RPM = Number(matches[1]);
    teensy('\t\tRPM', RPM);
  }
  matches = tickReg.exec(data);
  if (matches && matches[1] != null) {
    SYNC = new Date();
    teensy('SYNC signal caught.', SYNC);
  }
}

function pickupTeensy () {
  teensy('Looking for Teensy..');
  SerialPort.list(function (err, ports) {
    ports.forEach(function(port) {
      if (teensyReg.test(port.comName)) {
        teensy('Found teensy:', port);
        teensyPort = new SerialPort(port.comName, {
  	      parser: SerialPort.parsers.readline('\n')
        });
        teensyPort.on('data', (data) => {
          teensy(data);
          parseDataFromRing(data);
        });
        teensyPort.on('close', () => {
          teensyPort = undefined;
          teensy('Teensy disconnected.');
        });
      }
    });
  });
}

function dec2bin(dec) {
  return (dec >>> 0).toString(2);
}

setInterval(function () {
  //readFilesFromDir();
  nextFile();
  loadFile().then(() => {
    debug('Image ready.');
  });
}, imageChangePeriod);

setInterval(function () {
  if (teensyPort == undefined) {
    pickupTeensy();
//    parseDataFromRing('TARGETRPM: 100.00 GAP: -34.13 GGAP: 34.13 RPM: 134.13 (smoothed): 133 HZ: 2.24 Ascending: 1 Power: 2600.00 Voltage: 2.09 Output: 0.00');
//    parseDataFromRing('TARGETRPM: 100.00 GAP: -34.13 GGAP: 34.13 RPM: 134.13 (smoothed): 133 HZ: 2.24 Ascending: 1 Power: 2600.00 Voltage: 2.09 Output: 0.00 TICK');
  }
}, teensySearchPeriod);


text:
using LibSass.Compiler.Options;
using Xunit;

namespace LibSass.Tests.Unit
{
    public static class OutputStyleTests
    {
        [Fact]
        public static void WithCompact_ProcudecsCompactOutput()
        {
            var result = new SassOptions
            {
                Data = "a{b:c}",
                OutputStyle = SassOutputStyle.Compact
            }
            .Compile();

            Assert.Equal("a { b: c; }\n", result.Output);
        }

        [Fact]
        public static void WithCompressed_ProcudecsCompressedOutput()
        {
            var result = new SassOptions
            {
                Data = "a{b:c}",
                OutputStyle = SassOutputStyle.Compressed
            }
            .Compile();

            Assert.Equal("a{b:c}\n", result.Output);
        }

        [Fact]
        public static void WithExpanded_ProcudecsExpandedOutput()
        {
            var result = new SassOptions
            {
                Data = "a{b:c}",
                OutputStyle = SassOutputStyle.Expanded
            }
            .Compile();

            Assert.Equal("a {\n  b: c;\n}\n", result.Output);
        }

        [Fact]
        public static void WithNested_ProcudecsNestedOutput()
        {
            var result = new SassOptions
            {
                Data = "a{b:c}",
                OutputStyle = SassOutputStyle.Nested
            }
            .Compile();

            Assert.Equal("a {\n  b: c; }\n", result.Output);
        }

        [Fact]
        public static void WithoutOutputStyle_ProcudecsOutputWithDefaultStyle() // default is 'Nested'
        {
            var result = new SassOptions
            {
                Data = "a{b:c}"
            }
            .Compile();

            Assert.Equal("a {\n  b: c; }\n", result.Output);
        }
    }
}


text:
package structures.avl;

import structures.map.Map;

/**
 * @author Ztiany
 * Email ztiany3@gmail.com
 * Date 2018/10/18 23:30
 */
public class AVLMap<Key extends Comparable<Key>, Value> implements Map<Key, Value> {

    private AVLTree<Key, Value> mAVLTree = new AVLTree<>();

    @Override
    public void add(Key key, Value value) {
        mAVLTree.add(key, value);
    }

    @Override
    public Value remove(Key key) {
        return mAVLTree.remove(key);
    }

    @Override
    public Value get(Key key) {
        return mAVLTree.get(key);
    }

    @Override
    public boolean contains(Key key) {
        return mAVLTree.contains(key);
    }

    @Override
    public int size() {
        return mAVLTree.size();
    }

    @Override
    public void set(Key key, Value value) {
        mAVLTree.set(key, value);
    }

    @Override
    public boolean isEmpty() {
        return mAVLTree.isEmpty();
    }

}


text:
<!DOCTYPE html>

        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width">
        <title>Junshoong의 기술블로그 - django tag</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
        <link rel="stylesheet" href="../../theme/css/pygment.css" />
        <link rel="stylesheet" href="../../theme/css/style.css" />
        <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">

 Junshoong의 기술블로그

            [Django] User에게 권한 부여하기

        2017-04-21, Fri

코드 몇줄로 간단하게 권한을 부여할 수 있다.

user = User.objects.get(username='testuser')
perm = Permission.objects.get(codename='model.add_model …

            [Django] serializer의 구현

        2017-04-20, Thu

DRF에서 create를 구현하는 경우 ViewSet의 perform_create를 사용하면 Serializer의 create를 돌지 않는다.

            [Django] timezone 설정

        2017-04-19, Wed

Django에서 기본적인 DateTimeField를 현재 timezone으로 맞추고 싶다.

settings.py

TIME_ZONE = 'Asia/Seoul'
# USE_TZ = True

여기서 TIME_ZONE만 수정해주니까 저장되는 값이 …

            [Django] restframework에서 image 제공하기

        2017-04-16, Sun

DRF에서 image field를 serving 해보자.

            [DevOps] ArchLinux에서 Django + PostgreSQL 설정하기

        2017-01-04, Wed

Django + PostgreSQL

django 프로젝트에서 사용하는 DBMS로 PostgreSQL을 사용하도록 한다. 이 가이드에서는 Arch Linux 기준으로 작성되었다. 일부분은 같은 부분이 있겠지만 …

            [Django] MariaDB를 사용해서 Django개발 환경 만들기

        2016-11-03, Thu

개요

django는 기본적으로 sqlite3를 지원한다.

project/settings.py 를 확인해보면 아래와 같은 부분을 확인할 수 있다.

DATABASES = {
    'default': {
        'ENGINE': 'django …

            [Django] ImageField 업로드문제

        2016-09-09, Fri

Django의 ImageFile를 만들어서 서버에 업로드를 하는데 계속해서 아래와 같은 메세지가 나타났다.

This field is required.

admin 페이지에서 업로드할때는 문제가 없는데 …

        1 / 2
            »

 Category

            Agile
            (2)

            Angular
            (1)

            Blog
            (3)

            Book
            (3)

            CSS
            (1)

            CTF
            (4)

            DevOps
            (2)

            Django
            (6)

            Docker
            (2)

            Editor
            (3)

            English
            (2)

            ETC
            (11)

            Game
            (2)

            Git
            (2)

            Life
            (22)

            Linux
            (19)

            Mac
            (1)

            Movie
            (1)

            Nginx
            (2)

            Pelican
            (1)

            Python
            (8)

            Regex
            (1)

            Shell
            (2)

 Social

         email
         facebook
         linkedin
         slideshare
         github
         stack-overflow
         FEED


text:
package com.intellij.sh.psi.impl;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import static com.intellij.sh.ShTypes.*;
import com.intellij.sh.psi.*;

public class ShExpExpressionImpl extends ShBinaryExpressionImpl implements ShExpExpression {

  public ShExpExpressionImpl(ASTNode node) {
    super(node);
  }

  public void accept(@NotNull ShVisitor visitor) {
    visitor.visitExpExpression(this);
  }

  public void accept(@NotNull PsiElementVisitor visitor) {
    if (visitor instanceof ShVisitor) accept((ShVisitor)visitor);
    else super.accept(visitor);
  }

  @Override
  @NotNull
  public PsiElement getExponent() {
    return findNotNullChildByType(EXPONENT);
  }

}


text:
package so.paws.db

import play.api.Plugin

trait DbPlugin[T] extends Plugin {
  def db: T
}


text:
RefStatutTaches

    <jh-alert></jh-alert>

                <button class="btn btn-primary" ui-sref="refStatutTache.new">
                     Create a new RefStatutTache
                </button>

                <form name="searchForm" class="form-inline">

                        <input type="text" class="form-control" ng-model="searchQuery" id="searchQuery" placeholder="query">

                    <button class="btn btn-info" ng-click="search()"> Search a RefStatutTache
                    </button>
                </form>

                    ID
                    Code
                    Libelle

                    {{refStatutTache.id}}
                    {{refStatutTache.code}}
                    {{refStatutTache.libelle}}

                        <button type="submit"
                                ui-sref="refStatutTache.detail({id:refStatutTache.id})"
                                class="btn btn-info btn-sm">
                              View
                        </button>
                        <button type="submit"
                                ui-sref="refStatutTache.edit({id:refStatutTache.id})"
                                class="btn btn-primary btn-sm">
                              Edit
                        </button>
                        <button type="submit"
                                ui-sref="refStatutTache.delete({id:refStatutTache.id})"
                                class="btn btn-danger btn-sm">
                              Delete
                        </button>


text:
ACCEPTED

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

#### Published in
Bull. Soc. R. Bot. Belg. , sér. 2 29: 134 (1891)

#### Original name
Mortierella capitata Marchal, 1891

### Remarks
null


text:
<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>UIConductor Frontend</title>
  <!-- UICD version 369372853 - Beta-->

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="https://unpkg.com/@angular/material@6.0.0/prebuilt-themes/indigo-pink.css" rel="stylesheet">

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/themes/default/style.min.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/jstree.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="styles.css" />
</head>

<body class="mat-typography">
  <app-root fxFill>Loading...</app-root>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
  <script src="uicd-bundle.js"></script>
</body>

</html>


text:
package antlr

// The basic notion of a tree has a parent, a payload, and a list of children.
//  It is the most abstract interface for all the trees used by ANTLR.
///

var TreeInvalidInterval = NewInterval(-1, -2)

type Tree interface {
	GetParent() Tree
	SetParent(Tree)
	GetPayload() interface{}
	GetChild(i int) Tree
	GetChildCount() int
	GetChildren() []Tree
}

type SyntaxTree interface {
	Tree

	GetSourceInterval() *Interval
}

type ParseTree interface {
	SyntaxTree

	Accept(Visitor ParseTreeVisitor) interface{}
	GetText() string

	ToStringTree([]string, Recognizer) string
}

type RuleNode interface {
	ParseTree

	GetRuleContext() RuleContext
	GetBaseRuleContext() *BaseRuleContext
}

type TerminalNode interface {
	ParseTree

	GetSymbol() Token
}

type ErrorNode interface {
	TerminalNode

	errorNode()
}

type ParseTreeVisitor interface {
	Visit(tree ParseTree) interface{}
	VisitChildren(node RuleNode) interface{}
	VisitTerminal(node TerminalNode) interface{}
	VisitErrorNode(node ErrorNode) interface{}
}

type BaseParseTreeVisitor struct{}

var _ ParseTreeVisitor = &BaseParseTreeVisitor{}

func (v *BaseParseTreeVisitor) Visit(tree ParseTree) interface{}            { return nil }
func (v *BaseParseTreeVisitor) VisitChildren(node RuleNode) interface{}     { return nil }
func (v *BaseParseTreeVisitor) VisitTerminal(node TerminalNode) interface{} { return nil }
func (v *BaseParseTreeVisitor) VisitErrorNode(node ErrorNode) interface{}   { return nil }

// TODO
//func (this ParseTreeVisitor) Visit(ctx) {
//	if (Utils.isArray(ctx)) {
//		self := this
//		return ctx.map(function(child) { return VisitAtom(self, child)})
//	} else {
//		return VisitAtom(this, ctx)
//	}
//}
//
//func VisitAtom(Visitor, ctx) {
//	if (ctx.parser == nil) { //is terminal
//		return
//	}
//
//	name := ctx.parser.ruleNames[ctx.ruleIndex]
//	funcName := "Visit" + Utils.titleCase(name)
//
//	return Visitor[funcName](ctx)
//}

type ParseTreeListener interface {
	VisitTerminal(node TerminalNode)
	VisitErrorNode(node ErrorNode)
	EnterEveryRule(ctx ParserRuleContext)
	ExitEveryRule(ctx ParserRuleContext)
}

type BaseParseTreeListener struct{}

var _ ParseTreeListener = &BaseParseTreeListener{}

func (l *BaseParseTreeListener) VisitTerminal(node TerminalNode)      {}
func (l *BaseParseTreeListener) VisitErrorNode(node ErrorNode)        {}
func (l *BaseParseTreeListener) EnterEveryRule(ctx ParserRuleContext) {}
func (l *BaseParseTreeListener) ExitEveryRule(ctx ParserRuleContext)  {}

type TerminalNodeImpl struct {
	parentCtx RuleContext

	symbol Token
}

var _ TerminalNode = &TerminalNodeImpl{}

func NewTerminalNodeImpl(symbol Token) *TerminalNodeImpl {
	tn := new(TerminalNodeImpl)

	tn.parentCtx = nil
	tn.symbol = symbol

	return tn
}

func (t *TerminalNodeImpl) GetChild(i int) Tree {
	return nil
}

func (t *TerminalNodeImpl) GetChildren() []Tree {
	return nil
}

func (t *TerminalNodeImpl) SetChildren(tree []Tree) {
	panic("Cannot set children on terminal node")
}

func (t *TerminalNodeImpl) GetSymbol() Token {
	return t.symbol
}

func (t *TerminalNodeImpl) GetParent() Tree {
	return t.parentCtx
}

func (t *TerminalNodeImpl) SetParent(tree Tree) {
	t.parentCtx = tree.(RuleContext)
}

func (t *TerminalNodeImpl) GetPayload() interface{} {
	return t.symbol
}

func (t *TerminalNodeImpl) GetSourceInterval() *Interval {
	if t.symbol == nil {
		return TreeInvalidInterval
	}
	tokenIndex := t.symbol.GetTokenIndex()
	return NewInterval(tokenIndex, tokenIndex)
}

func (t *TerminalNodeImpl) GetChildCount() int {
	return 0
}

func (t *TerminalNodeImpl) Accept(v ParseTreeVisitor) interface{} {
	return v.VisitTerminal(t)
}

func (t *TerminalNodeImpl) GetText() string {
	return t.symbol.GetText()
}

func (t *TerminalNodeImpl) String() string {
	if t.symbol.GetTokenType() == TokenEOF {
		return "<EOF>"
	}

	return t.symbol.GetText()
}

func (t *TerminalNodeImpl) ToStringTree(s []string, r Recognizer) string {
	return t.String()
}

// Represents a token that was consumed during reSynchronization
// rather than during a valid Match operation. For example,
// we will create this kind of a node during single token insertion
// and deletion as well as during "consume until error recovery set"
// upon no viable alternative exceptions.

type ErrorNodeImpl struct {
	*TerminalNodeImpl
}

var _ ErrorNode = &ErrorNodeImpl{}

func NewErrorNodeImpl(token Token) *ErrorNodeImpl {
	en := new(ErrorNodeImpl)
	en.TerminalNodeImpl = NewTerminalNodeImpl(token)
	return en
}

func (e *ErrorNodeImpl) errorNode() {}

func (e *ErrorNodeImpl) Accept(v ParseTreeVisitor) interface{} {
	return v.VisitErrorNode(e)
}

type ParseTreeWalker struct {
}

func NewParseTreeWalker() *ParseTreeWalker {
	return new(ParseTreeWalker)
}

// Performs a walk on the given parse tree starting at the root and going down recursively
// with depth-first search. On each node, EnterRule is called before
// recursively walking down into child nodes, then
// ExitRule is called after the recursive call to wind up.
func (p *ParseTreeWalker) Walk(listener ParseTreeListener, t Tree) {
	switch tt := t.(type) {
	case ErrorNode:
		listener.VisitErrorNode(tt)
	case TerminalNode:
		listener.VisitTerminal(tt)
	default:
		p.EnterRule(listener, t.(RuleNode))
		for i := 0; i < t.GetChildCount(); i++ {
			child := t.GetChild(i)
			p.Walk(listener, child)
		}
		p.ExitRule(listener, t.(RuleNode))
	}
}

//
// Enters a grammar rule by first triggering the generic event {@link ParseTreeListener//EnterEveryRule}
// then by triggering the event specific to the given parse tree node
//
func (p *ParseTreeWalker) EnterRule(listener ParseTreeListener, r RuleNode) {
	ctx := r.GetRuleContext().(ParserRuleContext)
	listener.EnterEveryRule(ctx)
	ctx.EnterRule(listener)
}

// Exits a grammar rule by first triggering the event specific to the given parse tree node
// then by triggering the generic event {@link ParseTreeListener//ExitEveryRule}
//
func (p *ParseTreeWalker) ExitRule(listener ParseTreeListener, r RuleNode) {
	ctx := r.GetRuleContext().(ParserRuleContext)
	ctx.ExitRule(listener)
	listener.ExitEveryRule(ctx)
}

var ParseTreeWalkerDefault = NewParseTreeWalker()


text:
#include "stdafx.h"
#include "EOSAIGameRules.h"
#include "EOSAIUnitTemplate.h"
#include "EOSAIBuildingDescription.h"
#include "EOSAIGamePlayer.h"
#include "EOSAICommonData.h"
#include "EOSAITechnologyDesc.h"
#include "EOSAITechTreeNode.h"
#include "EOSAINationalSummary3.h"
#include "EOSAIBuildOption.h"
#include "EOSAIMain.h"

using namespace EOSAI;
#include "EOSAIInterface.h"
extern EOSAI::CInterface* g_pEOSAIInterface;

bool  CGameRules::CanBuild( long iPlayer, CEOSAIBuildOption* pBuildOption, bool bAllowOldTechnologies )
{
	EOSAI::CGamePlayer* pGamePlayer = g_pEOSAIInterface->GetGamePlayer( iPlayer );
	if( pGamePlayer == NULL ) return true;

	CString strUnitsubset = pGamePlayer->GetUnitsubset();

	//if( pBuildOption->IsIncProd() ) return true;
	if( pBuildOption->IsMoney() ) return true;

	if( pBuildOption->IsABuilding() )
	{
		CString strBuilding = pBuildOption->GetBuildingDescription()->GetInternalName();
		return CanBuildBuilding( iPlayer, strBuilding );
	}
	if( pBuildOption->IsAUnit() )
	{
		CString strUnit = pBuildOption->GetAIUnitTemplate()->GetInternalName();
		CString strUpgradedUnit = pBuildOption->GetAIUnitTemplate()->GetUnitsubsetUpgradeTo( strUnitsubset );

		bool bCanBuildThisUnit = CanBuildUnit(iPlayer, strUnit);
		if (bAllowOldTechnologies || strUpgradedUnit == _T(""))
		{
			return bCanBuildThisUnit; // CanBuildUnit(iPlayer, strUnit);
		}
		else
		{
			if (bCanBuildThisUnit == false) return false;

			bool bCanBuildupgradedUnit = CanBuildUnit(iPlayer, strUpgradedUnit);
			return bCanBuildThisUnit && !bCanBuildupgradedUnit;
		}
	}
	ASSERT( false );
	return false;
}

bool  CGameRules::UnitsubsetExists( CString strUnitsubset )
{
	POSITION pos = m_UnitsubsetList.GetHeadPosition();
	while( pos )
	{
		CString strUnitsubsetInList = m_UnitsubsetList.GetNext( pos );
		if( strUnitsubset == strUnitsubsetInList ) return true;
	}
	return false;
}

void  CGameRules::RemoveUnitsubset( CString strUnitsubset )
{
	POSITION pos = m_UnitsubsetList.GetHeadPosition();
	while( pos )
	{
		POSITION prevPos = pos;
		CString strUnitsubsetInList = m_UnitsubsetList.GetNext( pos );
		if( strUnitsubsetInList == strUnitsubset )
		{
			m_UnitsubsetList.RemoveAt( prevPos );
		}
	}
}

long  CGameRules::GetUnitsubsetIndex( CString strUnitsubset )
{
	long iIndex = 1;
	POSITION pos = m_UnitsubsetList.GetHeadPosition();
	while( pos )
	{
		CString strUnitsubsetInList = m_UnitsubsetList.GetNext( pos );
		if( strUnitsubsetInList == strUnitsubset )
		{
			return iIndex;
		}
		iIndex++;
	}
	return 0;
}

//

void CGameRules::SetInitialCanBuildUnit( CString strUnitsubset, CString strInternalUnitName )// EOSAI::CUnitsubsetValue* pValue )
{
	// Debug: look for that value in the list already
	POSITION pos = m_InitialCanBuildUnitList.GetHeadPosition();
	while( pos )
	{
		EOSAI::CUnitsubsetValue* p = m_InitialCanBuildUnitList.GetNext( pos );
		if( p->m_strUnitsubset == strUnitsubset && p->m_strValue == strInternalUnitName )
		{
			return; // it's already in the list
		}
	}

	EOSAI::CUnitsubsetValue* pValue = new EOSAI::CUnitsubsetValue;
	pValue->m_strUnitsubset = strUnitsubset;
	pValue->m_strValue = strInternalUnitName;
	m_InitialCanBuildUnitList.AddTail( pValue );
}

void CGameRules::SetInitialCanBuildBuilding( CString strUnitsubset, CString strInternalBuildingName )
{
	// Debug: look for that value in the list already
	POSITION pos = m_InitialCanBuildBuildingList.GetHeadPosition();
	while( pos )
	{
		EOSAI::CUnitsubsetValue* p = m_InitialCanBuildBuildingList.GetNext( pos );
		if( p->m_strUnitsubset == strUnitsubset && p->m_strValue == strInternalBuildingName )
		{
			return; // it's already in the list
		}
	}

	EOSAI::CUnitsubsetValue* pValue = new EOSAI::CUnitsubsetValue;
	pValue->m_strUnitsubset = strUnitsubset;
	pValue->m_strValue = strInternalBuildingName;
	m_InitialCanBuildBuildingList.AddTail( pValue );
}

// MovementUnitType
//

void CGameRules::AddMovementUnitType( CEOSAIMovementUnitType* pMovementUnitType )
{
	m_MovementUnitTypes.AddTail( pMovementUnitType );
}

CEOSAIMovementUnitType* CGameRules::GetMovementUnitType( long iMovementUnitType )
{
	POSITION pos = m_MovementUnitTypes.GetHeadPosition();
	while( pos )
	{
		CEOSAIMovementUnitType* pMovementUnitType = m_MovementUnitTypes.GetNext( pos );
		if( pMovementUnitType->m_iMovementUnitType == iMovementUnitType ) return pMovementUnitType;
	}
	return NULL;
}

CEOSAIMovementUnitType*  CGameRules::GetMovementUnitTypeByExternalName( CString strExternalName )
{
	POSITION pos = m_MovementUnitTypes.GetHeadPosition();
	while( pos )
	{
		CEOSAIMovementUnitType* pMovementUnitType = m_MovementUnitTypes.GetNext( pos );
		if( pMovementUnitType->m_strExternalName == strExternalName ) return pMovementUnitType;
	}
	return NULL;
}

//
//
void CGameRules::AddCombatUnitType( CEOSAICombatUnitType* pCombatUnitType )
{
	m_CombatUnitTypes.AddTail( pCombatUnitType );
}

CEOSAICombatUnitType* CGameRules::GetCombatUnitType( long iCombatUnitType )
{
	POSITION pos = m_CombatUnitTypes.GetHeadPosition();
	while( pos )
	{
		CEOSAICombatUnitType* pCombatUnitType = m_CombatUnitTypes.GetNext( pos );
		if( pCombatUnitType->m_iCombatUnitType == iCombatUnitType ) return pCombatUnitType;
	}
	return NULL;
}

CEOSAICombatUnitType*  CGameRules::GetCombatUnitTypeByExternalName( CString strExternalName )
{
	POSITION pos = m_CombatUnitTypes.GetHeadPosition();
	while( pos )
	{
		CEOSAICombatUnitType* pCombatUnitType = m_CombatUnitTypes.GetNext( pos );
		if( pCombatUnitType->m_strExternalName == strExternalName ) return pCombatUnitType;
	}
	return NULL;
}

// Technology
//
long  CGameRules::GetSpendingRequiredForXResearchPoints( float fResearchPoints )
{
	#ifdef THINGS_TO_COMPILE_EVENTUALLY
	ASSERT( false );
	#endif THINGS_TO_COMPILE_EVENTUALLY
	/*
	for( long iDollars=0; iDollars<100; iDollars++ )
	{
		float fVal = GetResearchPoints( iDollars );
		if( fVal >= fResearchPoints ) return iDollars;
	}
	*/
	return 100;
}
/*
void  CGameRules::AddTechnologyDesc( CEOSAITechnologyDesc* pTechDesc )
{
	m_TechnologyDescs.AddTail( pTechDesc );
}
*/
CEOSAITechnologyDesc*  CGameRules::GetTechnologyDesc( CString strInternalName )
{
	POSITION pos = m_TechnologyDescs.GetHeadPosition();
	while( pos )
	{
		CEOSAITechnologyDesc* pTechNode = m_TechnologyDescs.GetNext( pos );
		if( pTechNode->GetInternalName() == strInternalName ) return pTechNode;
	}
	return NULL;
}
/*
void  CGameRules::DeleteTechnologyDesc( CEOSAITechnologyDesc* pTechDesc )
{
	POSITION pos = m_TechnologyDescs.GetHeadPosition();
	while( pos )
	{
		POSITION prevPos = pos;
		CEOSAITechnologyDesc* pTechDescInList = m_TechnologyDescs.GetNext( pos );
		if( pTechDescInList == pTechDesc )
		{
			m_TechnologyDescs.RemoveAt( prevPos );
		}
	}

	// Delete TechTreeNodes that reference this TechDesc
	DeleteTechTreeNodes( pTechDesc->GetInternalName() );

	delete pTechDesc;
}
*/
CEOSAITechTreeNode* CGameRules::GetTechTreeNode( CString strTechDesc )
{
	POSITION pos = m_TechTreeNodes.GetHeadPosition();
	while( pos )
	{
		CEOSAITechTreeNode* pTechTreeNode = m_TechTreeNodes.GetNext( pos );
		if( pTechTreeNode->m_strTechName == strTechDesc ){ return pTechTreeNode; }
	}
	return NULL;
}

void  CGameRules::DeleteTechTreeNodes( CString strTechDesc )
{
	POSITION pos = m_TechTreeNodes.GetHeadPosition();
	while( pos )
	{
		POSITION prevPos = pos;
		CEOSAITechTreeNode* pTechTreeNodeInList = m_TechTreeNodes.GetNext( pos );
		if( pTechTreeNodeInList->m_strTechName == strTechDesc )
		{
			m_TechTreeNodes.RemoveAt( prevPos );

			// Re-wire the TreeTechNode
			CEOSAITechTreeNode* pCurrentNode = pTechTreeNodeInList;
			CEOSAITechTreeNode* pCurrentNodeParent = pTechTreeNodeInList->m_pParentNode;

			if( pCurrentNodeParent )
			{
				pCurrentNodeParent->RemoveChild( pCurrentNode );
			}
			// Move my children to my parent
			while( pCurrentNode->m_ChildNodes.IsEmpty() == FALSE )
			{
				CEOSAITechTreeNode* pChild = pCurrentNode->m_ChildNodes.RemoveHead();
				pChild->m_pParentNode = pCurrentNodeParent;
				if( pCurrentNodeParent )
				{
					pCurrentNodeParent->m_ChildNodes.AddTail( pChild );
				}
			}
			//
			delete pCurrentNode;
		}
	}
}

void  CGameRules::RemoveFromTechTreeNodeList( CEOSAITechTreeNode* pTechTreeNode )
{
	POSITION pos = m_TechTreeNodes.GetHeadPosition();
	while( pos )
	{
		POSITION prevPos = pos;
		CEOSAITechTreeNode* pTechTreeNodeInList = m_TechTreeNodes.GetNext( pos );
		if( pTechTreeNodeInList == pTechTreeNode )
		{
			m_TechTreeNodes.RemoveAt( prevPos );
		}
	}
}

CEOSAITechTreeNode*  CGameRules::GetFirstTechTreeNode( CString strTechDesc )
{
	POSITION pos = m_TechTreeNodes.GetHeadPosition();
	while( pos )
	{
		CEOSAITechTreeNode* pTechTreeNodeInList = m_TechTreeNodes.GetNext( pos );
		if( pTechTreeNodeInList->m_strTechName == strTechDesc )
		{
			return pTechTreeNodeInList;
		}
	}
	return NULL;
}

// AIUnitTemplates
//

void  CGameRules::AddAIUnitTemplate( CEOSAIUnitTemplate* pAIUnitTemplate )
{
	m_AIUnitTemplates.AddTail( pAIUnitTemplate );
}

CEOSAIUnitTemplate*  CGameRules::GetAIUnitTemplate( CString strAIUnitTemplate )
{
	POSITION pos = m_AIUnitTemplates.GetHeadPosition();
	while( pos )
	{
		CEOSAIUnitTemplate* pAIUnitTemplate = m_AIUnitTemplates.GetNext( pos );
		if( pAIUnitTemplate->GetInternalName() == strAIUnitTemplate )
		{
			return pAIUnitTemplate;
		}
	}
	return NULL;
}

void  CGameRules::GetAIUnitTemplates( CString strInTag, CList< CEOSAIUnitTemplate* >* pOutUnitTemplateList )
{
	POSITION pos = m_AIUnitTemplates.GetHeadPosition();
	while( pos )
	{
		CEOSAIUnitTemplate* pAIUnitTemplate = m_AIUnitTemplates.GetNext( pos );
		if( pAIUnitTemplate->UnitTagExists( strInTag ) )
		{
			pOutUnitTemplateList->AddTail( pAIUnitTemplate );
		}
	}
}

// Can I *ever* build the unit?
bool CGameRules::GetUnitsubsetAllowsBuilding( CString strUnitsubset, CString strBuilding )
{
	POSITION pos = m_BuildingDescriptionList.GetHeadPosition();
	while( pos )
	{
		CEOSAIBuildingDescription* pBuildingDesc = m_BuildingDescriptionList.GetNext( pos );
		if( pBuildingDesc->GetInternalName() == strBuilding )
		{
			return pBuildingDesc->m_AllowUnitsubset.UnitsubsetIsPositive( strUnitsubset );
			//ffcgf
			//return pBuildingDesc->GetAllowUnitsubsetObj()->UnitsubsetIsPositive( strUnitsubset );
		}
	}
	return false;
}

bool CGameRules::CanBuildBuilding( long iPlayer, CString strBuilding )
{
	EOSAI::CGamePlayer* pPlayer = g_pEOSAIInterface->GetGamePlayer( iPlayer );
	if( pPlayer == NULL ){ ASSERT( false ); return false; }
/*
	#ifdef _DEBUG
	if( strBuilding == _T("Capitol") )
	{
		int g=0;
	}
	#endif
 */
	CString strUnitsubset = pPlayer->GetUnitsubset();

	// Can I *ever* build the unit?
	//ASSERT( false );//if( GetAllowBuilding( strUnitsubset, strBuilding ) == false ) return false;
	if( GetUnitsubsetAllowsBuilding( strUnitsubset, strBuilding ) == false ) return false;

	// Can I *initially* build the unit?
	bool bCanBuild = false;
	POSITION pos = m_InitialCanBuildBuildingList.GetHeadPosition();
	while( pos )
	{
		//CEOSAIUnitsubsetValue* pUnitsubsetValue = m_InitialCanBuildBuildingList.GetNext( pos );
		CUnitsubsetValue* pUnitsubsetValue = m_InitialCanBuildBuildingList.GetNext( pos );
		if( pUnitsubsetValue->m_strUnitsubset == strUnitsubset )
		{
			if( pUnitsubsetValue->m_strValue == strBuilding )
			{
				return true;
			}
		}
	}

	CEOSAINationalSummary3* pNationalSummary = g_pEOSAIMain->GetAICommonData()->GetAINationalSummary3( iPlayer );
	pos = m_TechnologyDescs.GetHeadPosition();
	while( pos )
	{
		CEOSAITechnologyDesc* pTechDesc = m_TechnologyDescs.GetNext( pos );
		bool bEnablesBuilding = pTechDesc->EnablesBuilding( strBuilding );
		if( bEnablesBuilding )
		{
			//if( pWorldDescPlayerProxy->GetTechnologyHasBeenDiscovered( pTechNode->GetInternalName() ) )
			if( pNationalSummary->GetTechnologyHasBeenDiscovered( pTechDesc->GetInternalName() ) )
			{
				return true;
			}
		}
	}

	return false;
}

void CGameRules::AddBuildingDescription( CEOSAIBuildingDescription* pBuildingDesc )
{
#ifdef _DEBUG
	// Make sure it doesn't exist
	POSITION pos = m_BuildingDescriptionList.GetHeadPosition();
	while( pos )
	{
		CEOSAIBuildingDescription* pBuildingDescInList = m_BuildingDescriptionList.GetNext( pos );
		if( pBuildingDescInList->GetInternalName() == pBuildingDesc->GetInternalName() )
		{
			ASSERT( false );
			//return pBuilding;
		}
	}
#endif _DEBUG
	m_BuildingDescriptionList.AddTail( pBuildingDesc );
}

CEOSAIBuildingDescription* CGameRules::GetAIBuildingDescription( CString strInternalName )
{
	POSITION pos = m_BuildingDescriptionList.GetHeadPosition();
	while( pos )
	{
		CEOSAIBuildingDescription* pBuilding = m_BuildingDescriptionList.GetNext( pos );
		if( pBuilding->GetInternalName() == strInternalName )
		{
			return pBuilding;
		}
	}
	return NULL;
}

CEOSAIBuildingDescription* CGameRules::GetAIBuildingDescriptionFromUpgradeLineAndLevel( CString strUpgradeLine, long iUpgradeLevel )
{
	POSITION pos = m_BuildingDescriptionList.GetHeadPosition();
	while( pos )
	{
		POSITION prevPos = pos;
		CEOSAIBuildingDescription* pBuilding = m_BuildingDescriptionList.GetNext( pos );
		if( pBuilding->m_strUpgradeLine == strUpgradeLine &&
			pBuilding->m_iUpgradeLevel == iUpgradeLevel )
		{
			return pBuilding;
		}
	}
	return NULL;
}

bool  CGameRules::GetAllowUnit( CString strUnitsubset, CString strUnit )
{
	POSITION pos = m_AIUnitTemplates.GetHeadPosition();
	while( pos )
	{
		CEOSAIUnitTemplate* pUnitTemplate = m_AIUnitTemplates.GetNext( pos );
		if( pUnitTemplate->GetInternalName() == strUnit )
		{
			return pUnitTemplate->GetAllowUnitsubsetObj()->UnitsubsetIsPositive( strUnitsubset );
		}
	}
	return false;
}

bool  CGameRules::CanBuildUnit( long iPlayer, CString strUnit )
{
	CGamePlayer* pGamePlayer = g_pEOSAIInterface->GetGamePlayer( iPlayer );
	if( pGamePlayer == NULL ){ ASSERT( false ); return false; }

	CString strUnitsubset = pGamePlayer->GetUnitsubset();

	// Can I *ever* build the unit?
	if( GetAllowUnit( strUnitsubset, strUnit ) == false ) return false;

	// Can I *initially* build the unit?
	bool bCanBuild = false;
	ASSERT(m_InitialCanBuildUnitList.IsEmpty() == false);
	POSITION pos = m_InitialCanBuildUnitList.GetHeadPosition();
	while( pos )
	{
		CUnitsubsetValue* pUnitsubsetValue = m_InitialCanBuildUnitList.GetNext( pos );
		if( pUnitsubsetValue->m_strUnitsubset == strUnitsubset )
		{
			if( pUnitsubsetValue->m_strValue == strUnit )
			{
				return true;
			}
		}
	}

	// Check the technology to see if the player can build it
	/*
	CPlayerTechnologySet* pTechnologySet = NULL;
	if( GetCommonState()->GetWorldDescServer() )
	{
		GetCommonState()->GetWorldDescServer()->GetTechnologyHasBeenDiscovered( iPlayer,
	}
	else
	{
		ASSERT( g_pGameAppState );
		CWorldDescPlayer* pWorldDescPlayer = g_pGameAppState->GetWorldDescPlayer();
		CPlayerTechnologyObject* pObject = pWorldDescPlayer->GetPlayerTechnologySet()->GetPlayerTechnologyObject( iPlayer );
		pObject->TechnologyExists(
	}
	*/
	//POSITION pos = m_TechnologyDescs.GetHeadPosition();
	pos = m_TechnologyDescs.GetHeadPosition();
	while( pos )
	{
		CEOSAITechnologyDesc* pTechNode = m_TechnologyDescs.GetNext( pos );
		bool bEnablesUnit = pTechNode->EnablesUnit( strUnit );
		if( bEnablesUnit )
		{
			CEOSAINationalSummary3* pNationalSummary = g_pEOSAIMain->GetAICommonData()->m_AINationalSummaries[iPlayer];
			if( pNationalSummary->GetTechnologyHasBeenDiscovered( pTechNode->GetInternalName() ) )
			{
				return true;
			}
/*
			if( GetCommonState()->GetWorldDescServer() )
			{
				if( GetCommonState()->GetWorldDescServer()->GetTechnologyHasBeenDiscovered( iPlayer, pTechNode->GetInternalName() ) )
				{
					return true;
				}
			}
			else
			{
				//ASSERT( g_pGameAppState );
				ASSERT( GetCommonState() );
				ASSERT( GetCommonState()->GetLocalPlayerWorldDescList()->IsEmpty() == FALSE );

				//CWorldDescPlayer* pWorldDescPlayer = g_pCommonState->GetWorldDescPlayerByPlayerNumber( iPlayer );
				//if( pWorldDescPlayer == NULL )
				//{
				//	pWorldDescPlayer = GetCommonState()->GetLocalHumanPlayerWorldDesc();
				//}
				//if( pWorldDescPlayer == NULL )
				//{
				//	pWorldDescPlayer = GetCommonState()->GetLocalPlayerWorldDescList()->GetHead();
				//}
				CWorldDescPlayer* pWorldDescPlayer = g_pCommonState->GetLocalPlayerWorldDescList()->GetHead();
				ASSERT( pWorldDescPlayer );
				//CWorldDescPlayer* pWorldDescPlayer = GetCommonState()->GetLocalPlayerWorldDescList()->GetHead();
				//CWorldDescPlayer* pWorldDescPlayer = g_pGameAppState->GetWorldDescPlayer();
				CPlayerTechnologyObject* pObject = pWorldDescPlayer->GetPlayerTechnologySet()->GetPlayerTechnologyObject( iPlayer );
				if( pObject && pObject->TechnologyExists( pTechNode->GetInternalName() ) )
				{
					return true;
				}
				/-*
				if( pWorldDescPlayer->GetTechnologyHasBeenDiscovered( pTechNode->GetName() ) )
				{
					return true;
				}
				*-/
			}
*/
		}
	}

	/*
	CWorldDescPlayer* pWorldDescPlayer = GetCommonState()->GetWorldDescPlayerByPlayerNumber( iPlayer );
	if( pWorldDescPlayer == NULL ){ ASSERT( false ); return false; }

	pos = m_TechnologyList.GetHeadPosition();
	while( pos )
	{
		CTechnologyDesc* pTechNode = m_TechnologyList.GetNext( pos );
		bool bEnablesUnit = pTechNode->EnablesUnit( strUnit );
		//bool bDisablesUnit = pTechNode->DisablesUnit( strUnit );
		if( bEnablesUnit )
		{
			if( GetCommonState()->GetWorldDescServer() )
			{
				if( GetCommonState()->GetWorldDescServer()->GetTechnologyHasBeenDiscovered( iPlayer, pTechNode->GetName() ) )
				{
					return true;
				}
			}
			else
			{
				if( pWorldDescPlayer->GetTechnologyHasBeenDiscovered( pTechNode->GetName() ) )
				{
					return true;
				}
			}
		}
	}
	*/

	return false;
}


text:
exports.config = {
    // Port must match with the expressjs port (see gulpfile)
    baseUrl: 'http://localhost:4444',

    specs: ['e2e/**/*.js'],

    multiCapabilities: [{
        browserName: 'firefox'
    }, {
        browserName: 'chrome'
    }]

};


text:
'''Run the pipeline as a program.'''

from rnapipe.pipeline import make_pipeline
import rnapipe.pipeline_base.main
import pkg_resources

PROGRAM_NAME = "rnapipe"
PROGRAM_INFO = pkg_resources.require(PROGRAM_NAME)[0]
PROGRAM_VERSION = PROGRAM_INFO.version

def main():
    rnapipe.pipeline_base.main.main(PROGRAM_NAME, PROGRAM_VERSION, make_pipeline)


text:
package com.twocheckout.model;

public class Contact {
    private String customer_service_email;
    private String customer_service_phone;
    private String customer_service_phone_ext;
    private String mailing_address_1;
    private String mailing_address_2;
    private String mailing_address_id;
    private String mailing_city;
    private String mailing_country_code;
    private String mailing_postal_code;
    private String mailing_state;
    private String office_email;
    private String office_phone;
    private String office_phone_ext;
    private String physical_address_1;
    private String physical_address_2;
    private String physical_address_id;
    private String physical_city;
    private String physical_country_code;
    private String physical_postal_code;
    private String physical_state;
    private String vendor_id;

    public String getCustomerServiceEmail() {
        return customer_service_email;
    }

    public String getCustomerServicePhone() {
        return customer_service_phone;
    }

    public String getCustomerServicePhoneExt() {
        return customer_service_phone_ext;
    }

    public String getMailingAddress1() {
        return mailing_address_1;
    }

    public String getMailingAddress2() {
        return mailing_address_2;
    }

    public String getMailingAddressId() {
        return mailing_address_id;
    }

    public String getMailingCity() {
        return mailing_city;
    }

    public String getMailingCountryCode() {
        return mailing_country_code;
    }

    public String getMailingPostalCode() {
        return mailing_postal_code;
    }

    public String getMailingState() {
        return mailing_state;
    }

    public String getOfficeEmail() {
        return office_email;
    }

    public String getOfficePhone() {
        return office_phone;
    }

    public String getOfficePhoneExt() {
        return office_phone_ext;
    }

    public String getPhysicalAddress1() {
        return physical_address_1;
    }

    public String getPhysicalAddress2() {
        return physical_address_2;
    }

    public String getPhysicalAddressId() {
        return physical_address_id;
    }

    public String getPhysicalCity() {
        return physical_city;
    }

    public String getPhysicalCountryCode() {
        return physical_country_code;
    }

    public String getPhysicalPostalCode() {
        return physical_postal_code;
    }

    public String getPhysicalState() {
        return physical_state;
    }

    public String getVendorId() {
        return vendor_id;
    }
}


text:
//
//  UploadApi.m
//  Pods
//
//  Created by caoyy on 17/4/6.
//
//

#import "UploadApi.h"
#import "AFAppUploadAPIClient.h"

@implementation UploadApi
/**
 车况数据上传
 @param token
 @param serviceId
 @param UploadParam
 @param block
 @return
 */
+(NSURLSessionDataTask *)dataUpload:(UploadParam*)_UploadParam block:(void (^)(BaseResponse *_BaseResponse, NSError *error)) block{
    return [[AFAppUploadAPIClient sharedClient] POST:@"upload/data_upload" parameters:@{@"dataParam":[_UploadParam mj_JSONString]} completionHandler:^(NSURLResponse *response, id JSON, NSError *error) {
        if(block){
            if(JSON){
                BaseResponse *mBaseResponse = [BaseResponse mj_objectWithKeyValues:JSON];
                if(mBaseResponse){
                    block(mBaseResponse, nil);
                } else {
                    block(nil, error);
                }
            } else {
                block(nil, error);
            }
        }
    }];
}
@end


text:
package commands

import (
	"fmt"

	"github.com/codegangsta/cli"
	"github.com/untoldwind/gorrd/rrd/cdata"
)

// Command line create command
var LastCommand = cli.Command{
	Name:      "last",
	Usage:     "Show the timestamp of the last update to a rrd file",
	Flags:     []cli.Flag{},
	ArgsUsage: "file.rrd",
	Action:    last,
}

func last(ctx *cli.Context) {
	filename, err := getFilenameArg(ctx)
	if err != nil {
		showError(ctx, err)
		return
	}

	rrd, err := cdata.OpenRrdRawFile(filename, true)
	if err != nil {
		fmt.Fprintln(ctx.App.Writer, err)
		return
	}
	defer rrd.Close()

	fmt.Fprintf(ctx.App.Writer, "%d\n", rrd.LastUpdate.Unix())
}


text:
require 'ansible/ruby/models/jinja_expression'

module Ansible
  module Ruby
    module DslBuilders
      class Base
        def initialize
          @result = nil
        end

        def _result
          @result
        end

        def respond_to_missing?(*)
          super
        end

        def jinja(text)
          Ansible::Ruby::Models::JinjaExpression.new(text)
        end

        # For the DSL, don't want to defer to regular method_missing
        def method_missing(id, *args, &block)
          result = _process_method id, *args, &block
          method_missing_return id, result, *args
        end

        private

        def _ansible_include(filename, &block)
          inclusion = Models::Inclusion.new(file: filename)
          if block
            args_builder = Args.new inclusion
            args_builder.instance_eval(&block)
          end
          inclusion
        end

        def _valid_attributes
          (self.class.instance_methods - Object.instance_methods - %i[_result method_missing validate?]).sort
        end

        def no_method_error(method, only_valid_clause)
          raise "Invalid method/local variable `#{method}'. #{only_valid_clause}"
        end

        def method_missing_return(*)
          # Don't leak return values
          nil
        end

        def _implicit_bool(args)
          args.empty? || args[0]
        end
      end
    end
  end
end


text:
package canvas;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

import gerenciadores.ProgramManager;

@SuppressWarnings("serial")
public class CPanel extends JPanel {

	private int _h = 0;
	private int _w = 0;

	private BufferedImage background;
	private ProgramManager programManager;

	@Override
	public void paint(Graphics g) {
		setBackGroundImage();
		_h = getHeight();
		_w = getWidth();
		g.setColor(Color.white);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(Color.black);
		g.drawImage(background, 0, 0, null);

		if (programManager != null) {
			programManager.draw(g);
		}
	}

	private void setBackGroundImage() {
		if (getWidth() == _w && getHeight() == _h) {
			return;
		}
		// delete background vai para gc
		background = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
		Graphics2D g = (Graphics2D) background.getGraphics();
		int tam = 25;
		Color branco = new Color(245, 245, 245);
		Color preto = new Color(60, 60, 60);
		for (int i = 0; i * tam < getWidth(); i++) {
			for (int j = 0; j * tam < getHeight(); j++) {
				if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
					g.setColor(preto);
				} else {
					g.setColor(branco);
				}
				g.fillRect(i * tam, j * tam, tam, tam);
			}
		}
	}

	public void setProgram(ProgramManager programManager) {
		this.programManager = programManager;
	}

}


text:
<Title>Property</Title>

PropertyTag

A Property Tag is a type used to name or identify properties that are
attached to the vertices and edges of a graph. A Property type is not
the type of the actual property values. Objects of the Property type
are not used except to carry the type information which specifies the
property. See the section about  Custom
Edge Properties for a description of how to define your own
property tags.

Associated Types

Property Kind
<TT>property_kind<PropertyTag>::type</TT>

This specifies whether the property is a Vertex Property Tag
(<tt>vertex_property_tag</tt>), an Edge Property Tag (<tt>edge_property_tag</tt>), or
a Graph Property Tag which is attached to the
graph object itself (<tt>graph_property_tag</tt>). The tags are
defined in <tt>boost/graph/properties.hpp</tt>. The <tt>property_kind</tt> traits class is defined in <tt>boost/pending/property.hpp</tt>.

Property ID Number
<TT>property_num<PropertyTag>::value</TT>

This is needed as a workaround when using compilers that do not
support partial specialization (and hence prevent us from using
<tt>boost::is_same</tt> to detect if two property tags are the same).
The <tt>property_num</tt> traits class is defined in <tt>boost/pending/property.hpp</tt>.

Refinement of

Default Constructible

Models

The following models of the Property Tag concept are defined
in <tt>boost/graph/properties.hpp</tt>.

<tt>vertex_index_t</tt>

<tt>edge_index_t</tt>

<tt>graph_name_t</tt>

<tt>vertex_name_t</tt>

<tt>edge_name_t</tt>

<tt>edge_weight_t</tt>

<tt>vertex_distance_t</tt>

<tt>vertex_color_t</tt>

<tt>vertex_degree_t</tt>

<tt>vertex_out_degree_t</tt>

<tt>vertex_in_degree_t</tt>

<tt>vertex_discover_time_t</tt>

<tt>vertex_finish_time_t</tt>

See Also

PropertyGraph
and
Property Map Concepts

Notes

On compilers that do not support partial specialization, each Property
type is also required to specialize
<tt>property_num<PropertyTag></tt> to contain an enum named
<tt>value</tt> which uniquely identifies the property type.

Copyright © 2000-2001
Jeremy Siek, Indiana University (jsiek@osl.iu.edu)


text:
using System;
using Entitas;
using UnityEditor;
using UnityEngine;

namespace Entitas.Unity.VisualDebugging {
    public class ColorTypeDrawer : ITypeDrawer {
        public bool HandlesType(Type type) {
            return type == typeof(Color);
        }

        public object DrawAndGetNewValue(Type type, string fieldName, object value, Entity entity, int index, IComponent component) {
            return EditorGUILayout.ColorField(fieldName, (Color)value);
        }
    }
}


text:
package org.jetbrains.concurrency;

public interface Obsolescent {
  /**
   * @return {@code true} if result of computation won't be used so computation may be interrupted
   */
  boolean isObsolete();
}


text:
package azkaban.monitor;

import java.util.concurrent.TimeUnit;

import azkaban.jobcontrol.impl.jobs.locks.JobLock;

/**
 * Test job lock that enforces a simple delay while acquiring it.
 */
public class TimeDelayJobLock implements JobLock {
    private long waitTimeMs;

    /**
     * constructor
     * @param waitTimeMs
     *            time in ms to simulate waiting on resources.
     */
    public TimeDelayJobLock(long waitTimeMs) {
        this.waitTimeMs = waitTimeMs;
    }

    @Override
    public void acquireLock() throws InterruptedException {
       Thread.sleep(waitTimeMs);
    }

    @Override
    public long getLockAcquireTime(TimeUnit unit) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public long getLockHeldTime(TimeUnit unit) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Status getStatus() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getTotalLockTime(TimeUnit unit) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void releaseLock() {
        // TODO Auto-generated method stub

    }

}