This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////// Helpers for in-place editing ////////// | |
// Returns an event map that handles the "escape" and "return" keys and | |
// "blur" events on a text input (given by selector) and interprets them | |
// as "ok" or "cancel". | |
okCancelEvents = function(selector, callbacks) { | |
var ok = callbacks.ok || function() {}; | |
var cancel = callbacks.cancel || function() {}; | |
var events = {}; | |
events['keyup ' + selector + ', keydown ' + selector] = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session.setDefault("parents", []) | |
Session.setDefault("children", []) | |
Template.main.rendered = function() { | |
// autoupdate the parents and children | |
Deps.autorun(function() { | |
nodeId = Session.get("editNode"); | |
if (nodeId) { | |
parents = parentsOf(nodeId) | |
children = childrenOf(nodeId) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* complete.ly 1.0.0 | |
* MIT Licensing | |
* Copyright (c) 2013 Lorenzo Puccetti | |
* | |
* This Software shall be used for doing good things, not bad things. | |
* | |
**/ | |
completely = function completely(container, config) { | |
config = config || {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').hotKey({ | |
key: 's', | |
modifier: 'cmd' | |
}, saveNote) | |
$('body').hotKey({ | |
key: 'esc', | |
}, cancelNote) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wait(msg=''): | |
print msg | |
a = raw_input("press <enter> to continue...") | |
def yesno(msg): | |
print msg | |
a = raw_input('y/n: ') | |
if a == 'y': | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
from pprint import pprint | |
def arrayToList(arr): | |
if type(arr) == type(array([])): | |
return arrayToList(arr.tolist()) | |
elif type(arr) == type([]): | |
return [arrayToList(a) for a in arr] | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
from pprint import pprint | |
def arrayToList(arr): | |
if type(arr) == type(array([])): | |
return arrayToList(arr.tolist()) | |
elif type(arr) == type([]): | |
return [arrayToList(a) for a in arr] | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When you're gitignore is not working as it should, clear the cache and re-commit the files. All thanks to this amazing answer: | |
http://stackoverflow.com/questions/11451535/gitignore-not-working | |
git rm -r --cached . | |
git add . | |
git commit -m "fixed untracked files" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PS1='\[\033[31m\]$ \[\033[32m\]' | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad | |
alias ls='ls -GFh' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
def f(x): | |
print x | |
return x**2 | |
if __name__ == '__main__': | |
# 8 processors | |
p = Pool(8) | |
a = range(100) |