Skip to content

Instantly share code, notes, and snippets.

View stickupkid's full-sized avatar

Simon Richardson stickupkid

View GitHub Profile
@stickupkid
stickupkid / pool.js
Created September 25, 2012 10:01
Object Pool in javascript.
var Task0 = function() {}
Task0.prototype = {
init: function(value) {
this.value = value;
}
};
var Task1 = {
init: function(value) {
this.value = value;
@stickupkid
stickupkid / Proxy.js
Created September 24, 2012 07:49
Proxies
var p = Proxy.create({
get: function(proxy, name) { // intercepts property access
return 'Hello, '+ name;
},
set: function(proxy, name, value) { // intercepts property assignments
alert(name +'='+ value);
return true;
}
});
@stickupkid
stickupkid / tuple.js
Created September 23, 2012 20:55
Tuple
function Tuple(_1) {
this.__1 = _1;
}
Tuple.prototype = {
toString: function() {
return "Tuple";
}
};
function tuple1(value) {
var scope = this;
function _Enum(ns, value, types, values){
this.ns = ns;
this.value = value;
this.types = types;
this.values = values;
function validate(){
var total = types.length;
enum Wildcard {
_;
}
class WildcardExtension {
public static function someMethod(w:Wildcard):Void {
// Do something.
}
}
@stickupkid
stickupkid / gist:2299889
Created April 4, 2012 09:14
Example of a blob builder.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="log"></div>
<script id="worker1" type="javascript/worker">
@stickupkid
stickupkid / gist:2282785
Created April 2, 2012 11:25
String Concatination
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
@stickupkid
stickupkid / gist:2049529
Created March 16, 2012 10:43
Comparing dictionaries (miss-hit)
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.Dictionary;
import flash.utils.getTimer;
import flash.utils.setTimeout;
public class Main extends Sprite
{
@stickupkid
stickupkid / gist:2049496
Created March 16, 2012 10:36
Comparing dictionaries
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.Dictionary;
import flash.utils.getTimer;
import flash.utils.setTimeout;
public class Main extends Sprite
{
@stickupkid
stickupkid / HTML Builder
Created January 18, 2012 16:53
Kotlin: HTML Builder Experiments
package html
import java.util.*
fun main(args : Array<String>) {
val result =
html {
head {
script {
+"var text = \"Hello, World!\""