Skip to content

Instantly share code, notes, and snippets.

View wyattdanger's full-sized avatar

Stephen Bush wyattdanger

View GitHub Profile
@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 = {
@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 / 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 / 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 / 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 / nuke_vim_backups.sh
Created April 14, 2011 20:07
recursively nukes vim backup files
find ./ -name '.*.sw*' -exec rm -v '{}' \;
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
# 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
@wyattdanger
wyattdanger / base.sh
Created December 13, 2010 16:41 — forked from jamessanders/base.sh
# 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" = "/" ]
/* 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%;}