Skip to content

Instantly share code, notes, and snippets.

View mlsteele's full-sized avatar

Miles Steele mlsteele

View GitHub Profile
@mlsteele
mlsteele / script
Created May 31, 2014 04:29
Created by shoutcode
ag fofo
@mlsteele
mlsteele / taksman-example.txt
Created February 4, 2015 23:00
Taksman - Assignment management tool for school.
miles@attercop:~/code/taksman$ tree tasks
tasks
├── done
│   └── foo
├── entry
│   ├── 033-dns
│   ├── 033-reading
│   ├── 115-cable
│   ├── 115-lab1
│   ├── 115-locker
#!/usr/bin/env python
import sys
import subprocess
import netifaces
if __name__ == "__main__":
ipv4 = netifaces.ifaddresses('wlan0')[netifaces.AF_INET][0]['addr']
print ipv4
if len(sys.argv) > 1:
subprocess.Popen(["sm", "-f", "#000", "-b", "#DDD", " {} ".format(ipv4)])
@mlsteele
mlsteele / interceptMethod.js
Created July 5, 2012 07:32
Intercepts and wraps a method of a js object.
// 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) {
@mlsteele
mlsteele / classifier.scala
Last active October 10, 2015 22:25
classifier.scala
object SententialCalculus {
// Here is a scala program which classifies an SC sentence.
// It recognizes whether the sentence is an SC sentence,
// and returns the parsed typed tree.
// You can run this with the following command, but here's
// an executive summary.
// fsc -d build classifier.scala && scala -classpath build SententialCalculus
// Executive summary:
// If the input is a single predicate atom, this is an atom.
// If the input starts with a NOT, this is a negation.
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):
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')])
def f(x, y, z):
print x + y
print z
def f(int x, int y, string z):
print x + y
print z
# 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
@mlsteele
mlsteele / IntervalManager.coffee
Created August 6, 2013 17:55
Helper class for managing the execution of javascript interval tasks.
# (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.