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
((window) -> | |
$ = window.$ | |
startApp = -> | |
StateMachine = window.StateMachine | |
$stateText = $("span.state") | |
fsm = StateMachine.create( | |
initial: "hungry" | |
events: [ | |
name: "eat" | |
from: ["hungry", "hungrysick"] |
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
cartProd = (paramArray) -> | |
addTo = (curr, args) -> | |
rest = args.slice(1) | |
last = not rest.length | |
result = [] | |
i = 0 | |
while i < args[0].length | |
copy = curr.slice() | |
copy.push args[0][i] | |
if last |
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
(defn cartesian-product | |
"All the ways to take one item from each sequence" | |
[& seqs] | |
(let [v-original-seqs (vec seqs) | |
step | |
(fn step [v-seqs] | |
(let [increment | |
(fn [v-seqs] | |
(loop [i (dec (count v-seqs)), v-seqs v-seqs] | |
(if (= i -1) nil |
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 cartProd(paramArray) { | |
function addTo(curr, args) { | |
var i, copy, | |
rest = args.slice(1), | |
last = !rest.length, | |
result = []; | |
for (i = 0; i < args[0].length; i++) { |
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
-module('sort'). | |
-export([start/0]). | |
start() -> | |
Ctr = spawn_link(counter, loop, [0]), | |
{ok, Data} = getData(), | |
{ok, _Sorted} = sortData(Data, Ctr), | |
counter:get_count(Ctr) . | |
getData() -> |
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
-module('counter'). | |
-export([incr/2, get_count/1, loop/1]). | |
loop(Count) -> | |
receive | |
{ incr, Add } -> | |
loop(Count + Add); | |
{ report, To } -> | |
To ! { count, Count }, | |
loop(Count) |
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 cartesian($input) { | |
// http://stackoverflow.com/questions/6311779/finding-cartesian-product-with-php-associative-arrays | |
$result = array(); | |
while (list($key, $values) = each($input)) { | |
// If a sub-array is empty, it doesn't affect the cartesian product | |
if (empty($values)) { | |
continue; | |
} | |
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 | |
sha=$2 | |
if [[ -z $dir || -z $sha ]] | |
then | |
echo "Usage: $0 otherRepoDir commitSha" | |
exit 1 | |
fi |
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 | |
for i in $(seq 1 31); do | |
echo $i = `ls -la|grep -c "Jan $i 2013"`; | |
done; |
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 | |
subl `git status|grep modified|awk '{ print $3 }'` |
OlderNewer