Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@mattmccray
mattmccray / hxn.sh
Last active December 16, 2015 01:09 — forked from jdonaldson/hxn.sh
export OLDPATH=$PATH
export HAXE_NIGHTLY=$HOME/bin/haxe_nightly
export USE_HAXE_NIGHTLY=false
hxn(){
if [ -z "$USE_HAXE_NIGHTLY" ] || $USE_HAXE_NIGHTLY; then
echo "Changing to Haxe stable version"
export HAXE_STD_PATH=$OLD_HAXE_STD
export PATH=$OLDPATH
export USE_HAXE_NIGHTLY=false
else
class EventEmitter
emit: (event, args...) ->
return false unless @events?[event]
listener args... for listener in @events[event]
return true
addListener: (event, listener) ->
@emit 'newListener', event, listener
((@events?={})[event]?=[]).push listener
@mattmccray
mattmccray / EntryPoint.ts
Last active October 10, 2015 23:46 — forked from flq/EntryPoint.ts
Gists for the blog post porting react app to tyescript
import {assign} from 'lodash'
function startModule() {
//etc.
}
global['Project'] = assign(global['Project'] || {}, {
startModule
});
@mattmccray
mattmccray / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console