This file contains 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
// function interceptor | |
var interceptMethod = function(object, methodName, newMethodGen) { | |
previousMethod = object[methodName] | |
object[methodName] = newMethodGen(previousMethod) | |
} | |
// where newMethodGen is of the form | |
foo = {x: function() {console.log('foo.x')}} | |
interceptMethod(foo, 'x', function(f) { |
This file contains 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 lib601.sm import * | |
def LTISM(cCoeffs, dCoeffs): | |
def parallelAddMany(machines): | |
return reduce(lambda a,b: ParallelAdd(a,b), machines, Gain(0)) | |
def CascadeMany(machines): | |
return reduce(lambda a,b: Cascade(a,b), machines, Gain(1)) | |
def RPower(power): |
This file contains 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
import this | |
import string | |
print '\n'.join([''.join([(this.d[c] if c in string.letters else c) for c in line]) for line in this.s.split('\n')]) |
This file contains 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 f(x, y, z): | |
print x + y | |
print z | |
def f(int x, int y, string z): | |
print x + y | |
print z | |
This file contains 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
# pre-apply this to an object's method definition to make it return the | |
# context and thus be chainable. | |
# example: | |
# class FOO | |
# addThing: make_chainable (e) -> @stuff.push e | |
make_chainable = (f) -> -> | |
f.apply this, arguments | |
this |
This file contains 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
# (written for edX) | |
# Helper class for managing the execution of interval tasks. | |
# Handles pausing and restarting. | |
class IntervalManager | |
# Create a manager which will call `fn` | |
# after a call to .start every `ms` milliseconds. | |
constructor: (@ms, @fn) -> | |
@intervalID = null | |
# Start or restart firing every `ms` milliseconds. |
This file contains 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
%===================================================================== | |
% mshw.cls | |
% Provide mshw.cls class | |
% Derived from jhwhw.cls | |
% https://gist.github.com/jhwilson/1278588 | |
% http://tex.stackexchange.com/questions/31183/class-file-for-homework-assignments | |
%===================================================================== | |
%===================================================================== | |
% Identification |
This file contains 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
#!/usr/bin/env bash | |
find . -type f | grep "." | grep -v ".git" | sed "s/.*\.\(.*\)/\1/" | sort | uniq -c | sed "s/^[ \t]*//" | sort -n |
This file contains 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
ag fofo |
This file contains 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
ag fofo |
OlderNewer