Skip to content

Instantly share code, notes, and snippets.

<pre style="font: 10px/5px monospace;"><span style="color: #f0ede4;"></span><span style="color: #f0ede4;">#</span><span style="color: #ddd9ce;">#</span><span style="color: #cadfaa;">#</span><span style="color: #cadfaa;">#</span><span style="color: #cadfaa;">#</span><span style="color: #ebe8dd;">#</span><span style="color: #f4f2a5;">#</span><span style="color: #e4ded3;">#</span><span style="color: #f0ede4;">#</span><span style="color: #ede8e2;">#</span><span style="color: #f0ede4;">#</span><span style="color: #f0ede4;">#</span><span style="color: #e4ded3;">#</span><span style="color: #ddd9ce;">#</span><span style="color: #ddd9ce;">#</span><span style="color: #fcfda5;">#</span><span style="color: #e9daab;">#</span><span style="color: #ddd9ce;">#</span><span style="color: #f0ede4;">#</span><span style="color: #f0ede4;">#</span><span style="color: #f0ede4;">#</span><span style="color: #f0ede4;">#</span><span style="color: #f0ede4;">#</span><span style="color: #e8e4db;">#</span><span style="color: #f0ede4;">#</spa
# a.py
import b
print 'hi dom'
# b.py
import a
print 'hi erik'
@erikformella
erikformella / remove_track_numbers.scpt
Created June 20, 2012 23:43
Tryna fix some trax in iTunes
tell application "iTunes"
repeat with t in selection
set da_name to (name of t)
set x to (offset of "." in da_name) + 2
set y to (length of da_name)
set numbah to (text 1 thru ((offset of "." in da_name) - 1) of da_name)
set da_new_name to (text x thru y of da_name)
set name of t to da_new_name
set track number of t to numbah
end repeat
@erikformella
erikformella / omfgnyan.js
Created April 29, 2012 21:00
OMFGDOGS.com to NYAN.cat convertor bookmarklet (Speedproject)
// Just a quick hack for the cat lover in all of us
// Hijacks OMFGDOGS.com, and injects some Nyan Loveliness in there instead
// This is a bookmarklet! Copy and paste the code into an existing bookmark's URL, and rename it!
javascript:document.body.style.background='url(http://f.cl.ly/items/0x1J350B3E3t1h1b1m2r/0002.gif)';soundManager.stop('omfgdogs');soundManager.createSound({id: 'omfgnyan',url: 'http://iwantaneff.in/nyan.mp3',volume: 50,autoPlay: true,loops:999});void(0);
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@erikformella
erikformella / hax.js
Created April 15, 2012 16:34
If you have half a heart and like Ian Donovan or Matt Naz you will use this.
// First and foremost, go to the NCCC site and watch one of the Tufts videos.
// Next execute this code using your browser's javascript console.
// In Chrome, press command + option + j to open the developer console. Alternatively, navigate to View > Developer > JavaScript Console. Paste this whole test file into the console that just opened.
// In Firefox, use the Firebug extension to execute javascript.
// In other browsers, kill yourself.
// You must leave the window open for the code to keep voting for our dudes.
function destroy_this() {
vote.castVote();
@erikformella
erikformella / rand.c
Created March 15, 2012 23:29
Andrew Purcell's custom rand()
// sonystyle ^_^
int rand() {
return 1;
}
@erikformella
erikformella / Rakefile
Created February 8, 2012 21:55
A rakefile for 'compiling' haml and sass. Some is custom nosense so it might need to be modified if you want to use it.
include Rake::DSL
def rebuild(relative)
puts "------ change detected in #{relative}"
if relative.pathmap("%x") == ".scss"
sh 'sass', '--no-cache', '-r', './sass/addons/bourbon/lib/bourbon.rb', relative, "../www/stylesheets/"+relative.pathmap("%n.css")
elsif relative.pathmap("%x") == ".haml"
sh 'haml', '-f', 'html5', relative, "../www/"+relative.pathmap("%n.html")
end
end
@erikformella
erikformella / gist:1478072
Created December 14, 2011 19:27
nav bar follows page scroll
window.onload = function()
{
var headers = document.querySelectorAll('#docs h2, #guide h1');
var menu = document.getElementById('menu');
var init = menu.offsetTop;
var docked;
window.onscroll = function ()
{
if (!docked && (menu.offsetTop - scrollTop() < 0))
{
@erikformella
erikformella / unshred.rb
Created November 13, 2011 21:22
Solution for Instagram engineering challenge
# USAGE:
# ruby unshred.rb photo_name_1.png [photo_name_2.png] ...
#
# it will create an unshredded photo with the original name with "unshredded" prepended
#
require 'RMagick'
include Magick
SHRED_WIDTH = 32