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
// Dependencies: rhino, growl, growlnotify, a twitter account (put your login info into the config object) | |
importClass(java.net.Authenticator) | |
importClass(java.net.PasswordAuthentication) | |
importClass(java.lang.Thread) | |
load('http://json.org/json2.js') | |
var config = { | |
email: 'my_username', |
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
var expression = arguments[0] | |
var options = {input:expression, output:''} | |
runCommand('maxima', '--very-quiet', options) | |
var result = options.output.replace(/\s+(.*?)\s+/, '$1') | |
print(result) |
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
var noun_type_city = { | |
_name: "city", | |
_cities: undefined, | |
_fetchCityOffsets: function(callback, prefix) { | |
if (this._cities) { | |
this._suggestCities(callback, prefix) | |
} else { | |
var self = this | |
jQuery.get( 'http://www.raphscallion.com/clock/timezones.php', {}, function( response ) { |
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 curry(func) { | |
function curried(args) { | |
return function(nextVal) { | |
var newArgs = args.concat([nextVal]) | |
if (newArgs.length >= func.arity) | |
return func.apply(null, newArgs) | |
else | |
return curried(newArgs) | |
} | |
} |
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
#!/bin/bash | |
DIR=$1 | |
FORMAT=${2:-'pdf'} | |
FILENAME="hierarchy.$FORMAT" | |
cat \ | |
<(echo 'digraph types {') \ | |
<(ack '(class|interface) \w+ (extends|implements) \w+' --java -h -o $DIR | \ | |
awk '{print "\"" $4 "\"", "->", "\"" $2 "\""}') \ | |
<(echo '}') \ |
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
<project name='jsjunit'> | |
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/> | |
<property name='slash' value='${file.separator}'/> | |
<path id='classpath'> | |
<pathelement path="${junit.jar}"/> | |
<pathelement path="${js.jar}"/> | |
<pathelement path="${basedir}"/> | |
</path> |
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
var sums = function(num) { | |
var sets = [[num]]; | |
for (var i = 1; i <= num/2; i++) { | |
var left = sums(i); | |
var right = sums(num-i); | |
left.forEach(function(lhs) { | |
right.forEach(function(rhs) { | |
sets.push(lhs.concat(rhs).sort()); | |
}) | |
}) |
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
(* translated from http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html *) | |
(* implement trampolining *) | |
type 'a bounce = Done of 'a | Call of (unit -> 'a bounce) | |
let rec trampoline = function | |
| Call thunk -> trampoline (thunk()) | |
| Done x -> x | |
(* define some functions which use them *) |
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 mixable() { | |
var parents = []; | |
return { | |
mixin: function(parent) { parents.push(parent); }, | |
__noSuchMethod__: function(id, args) { | |
for each (var parent in parents) { | |
if (typeof parent[id] === 'function') { | |
return parent[id].apply(this, args); | |
} | |
} |
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 chop(needle : Int, haystack : Array[Int]) : Int = { | |
if (haystack.length == 0) return -1 | |
val midPoint = haystack.length / 2 | |
val midValue = haystack(midPoint) | |
if (midValue == needle) | |
midPoint | |
else if (needle < midValue) | |
chop(needle, haystack.slice(0, midPoint)) | |
else |
OlderNewer