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
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
/// <summary> | |
/// A base class for creating editors that decorate Unity's built-in editor types. | |
/// </summary> | |
public abstract class DecoratorEditor : Editor |
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
#if ENABLE_UNET | |
namespace UnityEngine.Networking | |
{ | |
[AddComponentMenu("Network/NetworkManagerHUD")] | |
[RequireComponent(typeof(NetworkManager))] | |
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] | |
public class NetworkManagerHUD : MonoBehaviour | |
{ | |
public NetworkManager manager; |
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using System.Threading; | |
namespace Sa1 { | |
/// <summary> | |
/// ins: do not use timeout in the csp.subthread |
OlderNewer