Skip to content

Instantly share code, notes, and snippets.

Greg Weng snowmantw

Block or report user

Report or block snowmantw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:20cc68b6487bcc7b142ad0120fa9c996
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
View gist:3ed154f5fc8001717e8b7822f9e5cf76
OMG Monodraw is super AWESOME!!
╔═══════════════════════╗
║ ║
┌──║ Scanning Job ║
│ ║ ║
│ ╚═══════════════════════╝
@snowmantw
snowmantw / StateTree.hs
Created Nov 4, 2017
List to "Tree" in State Monad
View StateTree.hs
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],
View gist:f7b2010dc3752fa5db60f5719ae3b878
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 Sep 21, 2016
Try to do a regulator, draft
View regulator.js
'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 Jul 16, 2016
Node.js OAuth + multipart form uploading for Plurk uploadPicture
View oauthmultipartform.js
var fs = require('fs');
var request = require('request');
/*
var plurkTokens =
{ "consumer_key": "<key>"
, "consumer_secret": "<secret>"
, "token": "<token>"
, "token_secret": "<secret>"
};
View ncu-exam.js
// 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() {
View ncu-q4.js
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});
View ncu-q3.js
var Cuboid = function() {
this.volume = function() {
return this.cuboidSize[0] *
this.cuboidSize[1] *
this.cuboidSize[2] ;
};
};
Cuboid.prototype.cuboidSize = [12, 8, 10];
View ncu-q2.js
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');
};
You can’t perform that action at this time.