This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# take a note of http://stackoverflow.com/questions/10058996/changing-the-binding-of-a-proc-in-ruby | |
class Proc | |
def call_with_vars(vars, *args) | |
Struct.new(*vars.keys).new(*vars.values).instance_exec(*args, &self) | |
end | |
end | |
# test | |
lambda { foo }.call_with_vars(:foo => 3) # => 3 | |
lambda { |a| foo + a }.call_with_vars({:foo => 3}, 1) # => 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash={} | |
hash.instance_eval do # if you want this for all hashes, replace this line with class Hash | |
def []=(key,val) | |
ordered_keys << key | |
super(key,val) | |
end | |
def ordered_keys | |
@ordered_keys ||= [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections.Generic; | |
public interface ICardIdentifierListener { | |
void OnTargetChange(Transform t); | |
void OnTargetFound(Transform t); | |
void OnTargetTracked(Transform t); | |
void OnTargetLost(Transform t); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csp = require 'js-csp' | |
player = (name, table) -> | |
loop | |
ball = yield csp.take table | |
if ball is csp.CLOSED | |
console.log name + ": table's gone" | |
return | |
ball.hits += 1 | |
console.log name + " " + ball.hits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using Sa1; | |
public class CspTest : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
csp.go(this, simple()); | |
csp.go(this, timeout()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csp.go -> | |
console.time 'daisy chain' | |
n = 100000 | |
leftmost = csp.chan() | |
right = leftmost | |
left = leftmost | |
for i in [0...n] | |
right = csp.chan() | |
csp.go (left, right) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash proxy | |
# export HTTP_PROXY=http://127.0.0.1:16823/ | |
# export http_proxy=http://127.0.0.1:16823/ | |
# export HTTPS_PROXY=https://127.0.0.1:16823/ | |
# export https_proxy=https://127.0.0.1:16823/ | |
# export ALL_PROXY=http://127.0.0.1:16823/ | |
# export all_proxy=https://127.0.0.1:16823/ | |
# go path | |
export GOROOT=/usr/local/opt/go/libexec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
through = require('through2') | |
gulp.task 'src', -> | |
gulp.src './src/*.coffee' | |
.pipe coffee({bare: true}) | |
.pipe gulp.dest('./dest/') | |
.pipe through.obj((file, encoding, callback) -> | |
callback(null, doSomethingWithTheFile(file)) | |
) | |
.on 'error', gutil.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IMPORTANT: choose one | |
var RL_LIB = "libreadline"; // NOTE: libreadline is GPL | |
//var RL_LIB = "libedit"; | |
var HISTORY_FILE = require('path').join(process.env.HOME, '.mal-history'); | |
var ffi = require('ffi'), | |
fs = require('fs'); | |
var rllib = ffi.Library(RL_LIB, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'js-csp' { | |
namespace Boxes { | |
class Box<T> { | |
value: T | |
constructor(value: T) | |
} | |
class PutBox<T> { | |
handler: Handlers.HandlerType | |
value: T |
OlderNewer