Skip to content

Instantly share code, notes, and snippets.

View wyattdanger's full-sized avatar

Stephen Bush wyattdanger

View GitHub Profile
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
@wyattdanger
wyattdanger / nuke_vim_backups.sh
Created April 14, 2011 20:07
recursively nukes vim backup files
find ./ -name '.*.sw*' -exec rm -v '{}' \;
@wyattdanger
wyattdanger / sum-fringe.js
Created June 23, 2011 14:40
attempting to port a function from SICP lecture video.
var tree = [ 1, [2, 3], 4, 5];
function first(arr) {
return arr[0];
}
function rest(arr) {
return arr.slice(1);
}
@wyattdanger
wyattdanger / extract-opengraph.js
Created June 27, 2011 18:40
extracting opengraph metadata serverside
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);
@wyattdanger
wyattdanger / uniquify-on.js
Created June 28, 2011 15:49
uniquify an array of objects on some key
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);
@wyattdanger
wyattdanger / alphabetize-on.js
Created June 28, 2011 17:04
alphabetize an array of objects on some shared key
function alphabetizeOn(arr, fn) {
var tmp = [],
final = [];
arr.forEach(function (item) {
var key = fn(item);
tmp.push(key);
});
@wyattdanger
wyattdanger / map.js
Created June 30, 2011 14:55
playing with canvas to draw map
(function () {
// MC Namespace
var MC = {
Map: function () {},
Marker: function () {}
};
// MC Map
MC.Map.prototype = {
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
@wyattdanger
wyattdanger / tmux.conf
Created August 12, 2011 16:00
my tmux configuration
# 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
@wyattdanger
wyattdanger / .tmux.conf
Created August 12, 2011 16:00
my tmux configuration
# 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