Skip to content

Instantly share code, notes, and snippets.

js> function f() { var bar = 1; bar == (bar = bar + 1) }
js> dis(f)
flags: CONSTRUCTOR
loc op
----- --
main:
00000: one
00001: setlocal 0
00005: pop
00006: getlocal 0
OMG Monodraw is super AWESOME!!
╔═══════════════════════╗
║ ║
┌──║ Scanning Job ║
│ ║ ║
│ ╚═══════════════════════╝
@snowmantw
snowmantw / StateTree.hs
Created November 4, 2017 02:25
List to "Tree" in State Monad
module StateTree ( buildTree ) where
import Prelude hiding (lookup)
import Control.Monad.State
import Data.Map (Map, insert, insertWith, empty, lookup)
data Item = Item {
sId :: String,
pId :: String,
value :: [Char],
So if we have configs like:
- All button from Red Button to Blue Button (style change)
- The form should have 1 sidebar, 1 main aread with 4 fields, instead of only 1 main area with 2 fields (layout change)
- W/o loging, the Submit button pressed, it should show error message in DOM instead of redirect to login page (behaviour change)
The config will have a variance-id, like case01, case02...
--
@snowmantw
snowmantw / regulator.js
Created September 21, 2016 09:17
Try to do a regulator, draft
'use strict';
/**
* A regulator connects Source and Reducer/Effect with regards of responsiveness.
*/
class Regulator {
constructor(configs) {
this._source = null;
@snowmantw
snowmantw / oauthmultipartform.js
Created July 16, 2016 05:03
Node.js OAuth + multipart form uploading for Plurk uploadPicture
var fs = require('fs');
var request = require('request');
/*
var plurkTokens =
{ "consumer_key": "<key>"
, "consumer_secret": "<secret>"
, "token": "<token>"
, "token_secret": "<secret>"
};
// This would provide `createFile`, `createReadStream`, `writeContent` and `createWriteStream`.
var FileSystem = require('FileSystem');
var Reader = function() {
this.counter = 0;
};
Reader.prototype = FileSystem.prototype;
Reader.prototype.paths = ['/tmp/urandom-1.txt', '/tmp/urandom-2.txt'];
Reader.prototype.start = function() {
this.mainPromise = Promise.resolve()
.then(function() {
var Cube = function(width) {
this.width = width;
};
Cube.prototype.volume = function() {
return Math.pow(this.width, 3);
};
var cube = new Cube(4)
cube.volume = cube.volume.bind({ width: 3});
var Cuboid = function() {
this.volume = function() {
return this.cuboidSize[0] *
this.cuboidSize[1] *
this.cuboidSize[2] ;
};
};
Cuboid.prototype.cuboidSize = [12, 8, 10];
var Foo = function() {};
Foo.prototype.bark = function() {
console.log('Foo barks');
};
var Bar = function() {};
Bar.prototype = Foo.prototype;
Bar.prototype.bark = function() {
console.log('Bar barks');
};