Skip to content

Instantly share code, notes, and snippets.

@susisu
susisu / core.js
Created April 30, 2014 16:02
ES6 Promise のラッパー的な (Chrome(いつからか), Firefox(>=29, JavaScript1.8) で動作します)
this.mosaic = this.mosaic || {};
(function(mosaic)
{
Object.defineProperty(mosaic,
"core", {value: function()
{
this.Action = mosaic.core.Action;
this.wrap = mosaic.core.wrap;
this.fail = mosaic.core.fail;
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.net.navigateToURL;
import flash.net.URLRequest;
@susisu
susisu / json.js
Created November 5, 2014 15:20
Simple JSON Parser with Loquat https://github.com/susisu/Loquat
/*
* Simple JSON Parser
* http://www.json.org/index.html
*/
var lq = require("loquat");
var util = require("util");
/*
* Parsers
@susisu
susisu / yami.js
Last active August 29, 2015 14:09
var f = function (a) { return a.toString() }
(function () {
console.log(f("test"))
})()
@susisu
susisu / palindromic_squares.txt
Last active August 29, 2015 14:10
first 100 palindromic squares
1 1
2 4
3 9
11 121
22 484
26 676
101 10201
111 12321
121 14641
202 40804
@susisu
susisu / ctor.js
Last active August 29, 2015 14:10
[[Construct]]
// 注意: アロー関数を排除できない
function ctor (Ctor) {
return function () {
if(typeof Ctor !== "function") {
throw new TypeError(typeof Ctor + " is not a function");
}
var proto = Ctor.prototype;
if (proto === null || typeof proto !== "object") {
proto = Object.prototype;
}
say -v Cellos aki no tah no ka ri ho no e o oh oh wa gah ko ro mo de tsu you ni nu reh tsu tsu
say -v Cellos ha ru su ghee te na tsu ki ni k ra ah shi ko ro mo ho su cho oh ame no ka goo yama
say -v Cellos a shi be ki no yama dory no oh oh no na gah na gah shi yo he toe ri ka mo ne m
say -v Cellos tah go no woo ra woo chi ee de mi rae eh bar foo ji no tah ka ne yu ki wa foo ri tsu tsu
say -v Cellos o coo yama momiji na coo shi ka ah no ko eh key coo toe ki zo aki ka na shi key
say -v Cellos ka sa sa ghee what a sell hash knee oak shi mo no shi ro ki o mi reh bar yo fu kae ni kae roo
class Test {
static function main() {
trace("Haxe is great!");
var nya : Foo = new Foo(function (x : String) : Void {
trace(x);
// btw
nya;
});
nya.say();
}
/*
* Reference:
* http://wasabiz.hatenablog.com/entry/20110118/1295335821
* http://code.activestate.com/recipes/496691/
*/
function TailRecursive(func) {
this.func = func;
this.isFirstCall = true;
this.continueKey = {};
@susisu
susisu / lambda.md
Created February 20, 2015 08:32
みんなだいすきラムダ式

みんなだいすきラムダ式.

function Lambda(argName, body) {
    this.argName = argName;
    this.body    = body;
}

Lambda.prototype.eval = function (env) {
    var argName = this.argName;