This file contains hidden or 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
| // 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; | |
| }; |
This file contains hidden or 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
| # 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' * |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| prod = 1 | |
| for i in [1,2,3]: | |
| prod *= i |
This file contains hidden or 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
| prod = foldl (*) 1 [1,2,3] |
This file contains hidden or 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
| prod = reduce(operator.mul, [1,2,3], 1) |
This file contains hidden or 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
| 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; | |
| } |
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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
| localStorage.setItem(key, value); | |
| localStorage.getItem(key); | |
| localStorage.removeItem(key); | |
| localStorage.clear(); |
This file contains hidden or 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
| doctype html | |
| /[if lt IE 7] | |
| html.no-js.lt-ie9.lt-ie8.lt-ie7 lang="en" | |
| /[if IE 7] | |
| html.no-js.lt-ie9.lt-ie8 lang="en" | |
| /[if IE 8] | |
| html.no-js.lt-ie9 lang="en" | |
| | <!--[if (gte IE 8)]<!--> | |
| <html class="no-js"> <!--<![endif]--> | |
| head |
OlderNewer