Skip to content

Instantly share code, notes, and snippets.

Avatar

Kamil Szot KamilSzot

View GitHub Profile
View chai plugin to check if object tree contains some subtree
chai.use(function(chai, utils) {
function containsProperties(expected) {
var actual = this._obj;
var success = true;
if(!utils.flag(this, 'deep')) {
if(Array.isArray(expected)) {
this.assert(success = expected.subtract(Object.extended(actual).select(expected).keys()).length === 0, "expected "+JSON.stringify(actual)+" to have "+JSON.stringify(expected));
} else {
@KamilSzot
KamilSzot / gist:f326d4593d14d12cd5a9
Last active Aug 29, 2015
JavaScript 1.7 mouse drag state machine using generators as coroutines.
View gist:f326d4593d14d12cd5a9
var $box = $('<div id="box">').appendTo(document.body).css({
width: 100,
height: 100,
position: 'absolute',
left: 100,
top: 100,
background: 'green',
cursor: 'pointer',
border: '5px solid red'
});
View gist:11290301
$ cat .git/hooks/pre-commit
#!/bin/bash
root_dir=`git rev-parse --show-toplevel`
for new_file in `git status --porcelain | awk '/\?\?/ { print $2 }'`;
do