Skip to content

Instantly share code, notes, and snippets.

@ccorcos
ccorcos / completely.js
Created April 21, 2014 04:24
complete.ly (js) customized for semantic-ui
/**
* 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 || {};
@ccorcos
ccorcos / gist:11132188
Created April 21, 2014 04:24
how to use hotkeys.js
$('body').hotKey({
key: 's',
modifier: 'cmd'
}, saveNote)
$('body').hotKey({
key: 'esc',
}, cancelNote)
@ccorcos
ccorcos / gist:11196516
Created April 22, 2014 22:25
Some convenient helpers for interacting via the commandline in python
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
@ccorcos
ccorcos / matrixAnnoyance.py
Created April 22, 2014 23:43
Python NumPy: this function takes a list of matrices and converts it into a 2D matrix filling in zeros where no matrix is specified
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:
@ccorcos
ccorcos / git.txt
Created May 1, 2014 22:08
fix gitignore my clearing git cache
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"
@ccorcos
ccorcos / bash_profile
Created May 31, 2014 23:20
My custom terminal settings
export PS1='\[\033[31m\]$ \[\033[32m\]'
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
@ccorcos
ccorcos / parallel.py
Created June 7, 2014 02:39
parallel processing in python
from multiprocessing import Pool
def f(x):
print x
return x**2
if __name__ == '__main__':
# 8 processors
p = Pool(8)
a = range(100)
@ccorcos
ccorcos / gist:fc277c67cef88f4a0b06
Created July 24, 2014 18:11
Resize text areas in Meteor rendered to fit content
Template.name.rendered = ->
# resize the text areas
Meteor.defer ->
$('.content').on( 'change keyup keydown paste cut', 'textarea',
-> $(this).height(0).height(this.scrollHeight)).find('textarea').change()
$('textarea').trigger('change')
@ccorcos
ccorcos / decorators.py
Created November 18, 2014 04:57
example of how python decorators, *args and **kwargs work
# An example of how to make decorators and also how *args and **kwargs work.
from functools import partial
def wrapping(func):
def wrapper(func, *args, **kwargs):
# print "wrapper"
# print func
# print args
# printwrappergs
@ccorcos
ccorcos / theano_test.py
Created November 20, 2014 22:57
theano shape error
import theano
import theano.tensor as T
import numpy
# The model basically looks like this:
#
# o_t a_t
# | |
# | |