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
| (function () { | |
| // MC Namespace | |
| var MC = { | |
| Map: function () {}, | |
| Marker: function () {} | |
| }; | |
| // MC Map | |
| MC.Map.prototype = { |
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
| function alphabetizeOn(arr, fn) { | |
| var tmp = [], | |
| final = []; | |
| arr.forEach(function (item) { | |
| var key = fn(item); | |
| tmp.push(key); | |
| }); |
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
| function uniquifyOn(arr, fn) { | |
| var returnArr = [], | |
| tempArr = []; | |
| arr.forEach(function (item) { | |
| var key = fn(item); | |
| if ( tempArr.indexOf(key) === -1) { | |
| returnArr.push(item); | |
| tempArr.push(key); |
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
| function extractOpenGraph(url, fn) { | |
| var og = []; | |
| jsdom.env({ | |
| html: url, | |
| done: function(errors, window) { | |
| jsdom.jQueryify(window, 'http://code.jquery.com/jquery-1.4.2.min.js' , function() { | |
| window.$('meta[property^=og]').each(function(i, tem) { | |
| og.push([ tem.getAttribute('property'), tem.getAttribute('content')]); | |
| }); | |
| fn(og); |
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
| var tree = [ 1, [2, 3], 4, 5]; | |
| function first(arr) { | |
| return arr[0]; | |
| } | |
| function rest(arr) { | |
| return arr.slice(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
| find ./ -name '.*.sw*' -exec rm -v '{}' \; |
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
| number = rand(10) + 1 | |
| correct = false | |
| puts "Guess a number between 1 and 10." | |
| until correct do | |
| guess = gets.to_i | |
| correct = guess.equal? number | |
| if correct |
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
| # Print the string "Hello, World" | |
| puts "Hello, World" | |
| # Find index of "Ruby" in "Hello, Ruby" | |
| "Hello, Ruby".index "Ruby" | |
| # Print your name ten time | |
| 10.times { puts "Stephen" } | |
| # This is equivalent to the above one-liner |
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
| # change directory to the base of your project | |
| # Your project base is the directory that contains | |
| # either _darcs or .git or .hg | |
| # to use as a command add to .zshrc or .bashrc | |
| # alias base='source <path/to/base.sh> | |
| CUR=$(pwd); | |
| while [ ! "$CUR" = "/" ] |
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
| /* grids */ | |
| @media screen and (max-width: 319px) {.unit { float: none !important; width: auto !important;} | |
| } | |
| .line:after,.lastUnit:after { clear: both; display: block; visibility: hidden; overflow: hidden; height: 0 !important; line-height: 0; font-size: xx-large; content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ";} | |
| .line {*zoom:1;} | |
| .unit { float: left;} | |
| .size1of1 { float: none;} | |
| .size1of2 { width: 50%;} | |
| .size1of3 { width: 33.33333%;} | |
| .size2of3 { width: 66.66666%;} |