Skip to content

Instantly share code, notes, and snippets.

View sdtsui's full-sized avatar

Daniel Tsui sdtsui

View GitHub Profile
@sdtsui
sdtsui / dockerMemory.sh
Created March 1, 2016 08:16
dockerMemory.sh
declare -a arr=();
for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`
do
arr+=$line;
arr+=" ";
done;
# echo ${#arr[@]};
# echo ${arr[@]};
docker stats $arr;
@sdtsui
sdtsui / underramdash.js
Created January 31, 2016 11:07 — forked from Cfeusier/underramdash.js
2kb unminified/unzipped drop-in for the usual utility functions
var underramdash = {
each: each,
map: map,
reduce: reduce,
filter: filter,
flatten: flatten,
uniq: uniq,
extend: extend,
every: every,
identity: identity
@sdtsui
sdtsui / ex1.cljs
Created January 22, 2016 02:32
ex1
;Working ClojureScript
(defn rps [p1 p2]
(if (== (count p1) (count p2)) "Draw!"
(let [win1 "Player 1 won!" win2 "Player 2 won!"]
(if (== p1 "scissors") (if (== p2 "paper") win1 win2)
(if (== p1 "rock") (if (== p2 "scissors") win1 win2)
(if (== p1 "paper") (if (== p2 "rock") win1 win2)
nil
)
)
@sdtsui
sdtsui / extendcopy.js
Last active January 14, 2016 01:26
extendcopy
//example
var x = {};
var y = { hi: 5};
_.extend(x, y);
console.log("Original");
console.log(x.hi); // 5
console.log("Changed");
y.hi = 6;
console.log(x.hi); // still 5
// x.hi = 5, the number, not a kind of 'eval' of y.hi
@sdtsui
sdtsui / om-next-david-nolen.md
Created January 12, 2016 22:14
om-next-david-nolen.md

David Nolen Talk - Om Next.

Preface: This is a riff on "The Language of the System" by Rich Hickey Problem Statements:

  1. Client Sever communication is ad-hoc (how)
  2. C/S communication requires a lot of out-of-band information ( what - read AWS docs)
  3. React render model makes moving up/across the UI tree tricky

Assumptions:

  1. Single-atom app state is good
@sdtsui
sdtsui / vimeoSpeed.js
Created September 14, 2015 23:15
vimeoSpeed
var vid = document.querySelector(".video");
vid.playbackRate = 2;
@sdtsui
sdtsui / gist:1761ed61e023144719c0
Created June 26, 2015 17:11
flipTable random notes
some pseudocode, i have some questions about how the tree will work.
probs@HR late
____________________
Store all of the elements in an immutable tree.
HTML5 deviceOrientation:
window.addEventListener('deviceMoveEvent??'), function(e){
@sdtsui
sdtsui / RBNode.es6
Created May 25, 2015 14:00
Static Get for RBTree
//RBNode.es6
const IM = require('immutable');
let BSTNode = require('./BSTNode');
export class RBNode extends BSTNode {
constructor(key, value, left, right, id, color = 0) {
super(key, value, left, right, id, true);
this.color = (!!color) ? RBNode.B : RBNode.R;
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.7.2/immutable.min.js"></script>
<script type="text/javascript">
console.log('IM :', Immutable);
var IM = Immutable;
var array = IM.List(["totally", "immutable", {hammer: "Can’t Touch This"}]);
console.log(array.get(1)); //immutable
array.get(2).hammer = "hm, surely I can mutate this nested object..."
console.log(array.get(2).hammer); //"hm, ...'