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
| 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
| 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
| 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
| 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 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 () { | |
| // 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
| var geocoder = require('geocoder'); | |
| // Geocoding | |
| geocoder.geocode("Atlanta, GA", function ( err, data ) { | |
| // do stuff with data | |
| }); | |
| // Reverse Geocoding | |
| geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) { | |
| // do stuff with data |
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
| # This sets default key to control-a instead of control-b. | |
| # I also recommend remapping caps lock to control in system preferences | |
| set-option -g prefix C-a | |
| bind-key C-w last-window | |
| set -g base-index 1 | |
| set-option -g default-terminal "screen-256color" | |
| # act like vim | |
| setw -g mode-keys vi | |
| bind h select-pane -L |
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
| # This sets default key to control-a instead of control-b. | |
| # I also recommend remapping caps lock to control in system preferences | |
| set-option -g prefix C-a | |
| bind-key C-w last-window | |
| set -g base-index 1 | |
| set-option -g default-terminal "screen-256color" | |
| # act like vim | |
| setw -g mode-keys vi | |
| bind h select-pane -L |