Skip to content

Instantly share code, notes, and snippets.

Will Langstroth wlangstroth

Block or report user

Report or block wlangstroth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am wlangstroth on github.
  • I am wlangstroth (https://keybase.io/wlangstroth) on keybase.
  • I have a public key whose fingerprint is E2F2 215B AA83 1547 A87E E85F 69DF E208 FA87 7968

To claim this, I am signing this object:

View memoize.js
// Crockford's
function memoizer(memo, fundamental) {
var shell = function (n) {
var result = memo[n];
if (typeof result !== 'number') {
result = fundamental(shell, n);
memo[n] = result;
}
return result;
};
View rename.sh
# For those without rename
for i in *; do mv $i $i.mp3; done
# or
for f in *;do mv $f ${f/test/prod};done
# replace text in lots of files
perl -pi -e 's/wrong/right/g' *
View random.hs
import System.Random
randPairs :: (RandomGen g, Random a) => (a,a) -> g -> [(a,a)]
randPairs range gen = zip as bs
where (a,b) = split gen -- create two separate generators
as = randomRs range a -- one infinite list of randoms
bs = randomRs range b -- another
seed = 13561956 :: Int
mygen = mkStdGen seed
View loop.py
prod = 1
for i in [1,2,3]:
prod *= i
View foldl.hs
prod = foldl (*) 1 [1,2,3]
View reduce.py
prod = reduce(operator.mul, [1,2,3], 1)
View failbuzz.js
for (var i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
print "FizzBuzz";
} else if (i % 3 == 0) {
print "Fizz";
} else if (i % 5 == 0) {
print "Buzz";
} else {
print i;
}
@wlangstroth
wlangstroth / fizz.rb
Created Mar 29, 2011
still ugly, but I like it better
View fizz.rb
#!/usr/bin/env ruby
(1..100).each do |n|
out = ""
if n.modulo(3) == 0
out += "Fizz"
end
if n.modulo(5) == 0
out += "Buzz"
end
View localstorage.js
localStorage.setItem(key, value);
localStorage.getItem(key);
localStorage.removeItem(key);
localStorage.clear();
You can’t perform that action at this time.