Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will Fitzgerald
committed
Apr 4, 2012
0 parents
commit 6432780
Showing
12 changed files
with
3,358 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
.sass-cache/* |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
fs = require 'fs' | |||
{spawn, exec} = require 'child_process' | |||
|
|||
mergeFiles =(inputFiles, outputFile, minify=false) -> | |||
|
|||
# Add directories and extensions to filenames | |||
inputFiles = for f in inputFiles | |||
"src/#{f}.coffee" | |||
outputFile = "lib/#{outputFile}.coffee" | |||
|
|||
remaining = inputFiles.length | |||
appContents = new Array | |||
|
|||
for inputFile, index in inputFiles then do (inputFile, index) -> | |||
fs.readFile inputFile, 'utf8', (err, fileContents) -> | |||
throw err if err | |||
appContents[index]= fileContents | |||
process() if --remaining is 0 | |||
|
|||
process = -> | |||
|
|||
fs.writeFile outputFile, appContents.join('\n\n'), 'utf8', (err) -> | |||
throw err if err | |||
exec "coffee --compile #{outputFile}", (err, stdout, stderr) -> | |||
throw err if err | |||
# console.log stdout + stderr | |||
fs.unlink outputFile, (err) -> | |||
throw err if err | |||
|
|||
js = outputFile.replace /coffee$/, 'js' | |||
console.log js | |||
if minify | |||
js_output_file = js.replace /\.js$/, '.min.js' | |||
exec "java -jar '/users/zeke/.jars/compiler.jar' --js #{js} --js_output_file #{js_output_file}", (err, stdout, stderr) -> | |||
throw err if err | |||
console.log js_output_file | |||
|
|||
# task 'bake', 'Compile and concatenate CoffeeScript files to JavaScript, and create minified versions', -> | |||
# mergeFiles ['reqwest', 'swagger'], 'swagger', false | |||
|
|||
task 'watch', 'Automatically recompile CoffeeScript files to JavaScript', -> | |||
coffee = spawn 'coffee', ['-cw', '-o', 'lib/js', 'src/coffee'] | |||
coffee.stdout.on 'data', (data) -> console.log data.toString().trim() | |||
test_coffee = spawn 'coffee', ['-cw', '-o', 'test', 'test'] | |||
test_coffee.stdout.on 'data', (data) -> console.log data.toString().trim() | |||
|
|||
|
|||
task 'dev', "Open source files, run spec in browser, and watch for changes", -> | |||
exec "$EDITOR ." | |||
exec "open test/suite.html" | |||
coffee = spawn 'coffee', ['-cw', '-o', 'lib/js', 'src/coffee'] | |||
coffee.stdout.on 'data', (data) -> console.log data.toString().trim() |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
JsSet: A small set package for Sets in Javascript |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
#!/bin/bash | |||
# unbind if bound | |||
ps -awx | grep "ssh -f -N -L" | grep "8012" | awk '{print $1}' | xargs kill | |||
# bind | |||
ssh -f -N -L 8012:localhost:8012 ec2-50-18-237-212.us-west-1.compute.amazonaws.com | |||
# | |||
open public/fretboard.html |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,83 @@ | |||
this.Set = class Set | |||
constructor: (items=[]) -> | |||
@store= {} | |||
@store[item] = true for item in items | |||
|
|||
add: (object) -> | |||
@store[object] = true | |||
|
|||
contains: (object) -> | |||
@store[object] || false | |||
|
|||
delete: (object) -> | |||
delete(@store[object]) | |||
|
|||
items: () -> | |||
Object.keys(@store) | |||
|
|||
size: () -> this.items().length | |||
|
|||
equals: (other) -> | |||
s = @store | |||
eq = true | |||
for item in this.items() | |||
do (item) -> | |||
eq = false unless other.store[item] | |||
return eq unless eq | |||
loc = this | |||
for item in other.items() | |||
do (item) -> | |||
eq = false unless loc.store[item] | |||
return eq | |||
|
|||
union: (other) -> | |||
new Set(other.items().concat(this.items())) | |||
|
|||
intersection: (other) -> | |||
ks = [] | |||
for item in this.items() | |||
do (item) -> | |||
ks[ks.length] = item if other.contains(item) | |||
new Set(ks) | |||
|
|||
difference: (other) -> | |||
ks = [] | |||
for item in this.items() | |||
do (item) -> | |||
ks[ks.length] = item unless other.contains(item) | |||
new Set(ks) | |||
|
|||
union_arity: (other) -> | |||
(this.union(other)).size() | |||
|
|||
intersection_arity: (other) -> | |||
n = 0 | |||
for item in this.items() | |||
do (item) -> | |||
n++ if other.contains(item) | |||
n | |||
|
|||
difference_arity: (other) -> | |||
n = 0 | |||
for item in this.items() | |||
do (item) -> | |||
n++ unless other.contains(item) | |||
n | |||
|
|||
jaccardIndex: (other) -> this.intersection_arity(other) / this.union_arity(other) | |||
|
|||
jaccardDistance: (other) -> 1 - this.jaccardIndex(other) | |||
|
|||
hammingDistance: (other) -> | |||
this.union_arity(other) - this.intersection_arity(other) | |||
|
|||
normalizedHammingDistance: (other,size=null) -> | |||
if size == null | |||
this.jaccardDistance(other) | |||
else | |||
(this.union_arity(other) - this.intersection_arity(other)) / size | |||
|
|||
|
|||
|
|||
|
|||
|
Oops, something went wrong.