Skip to content

Instantly share code, notes, and snippets.

@erikformella
erikformella / class_test.cpp
Created November 5, 2011 15:37
showing how virtual functions can make pseudo type introspection
#include <iostream>
#include <vector>
using namespace std;
class Animal
{
public:
virtual void sound()
{
@erikformella
erikformella / dabbutHax.js
Created November 12, 2011 15:34
dick move
/*
USAGE:
copy and paste all of this into the javascript console. you can then call falseVote(ians_comment_id, times) to upvote
ian as partygoer times times. you can also provide your own comment_id by doing an inspect element on the voting div
on anyone's profile.
the ajax requests are synchronous to allow for the coockie bs. this makes the execution seem slow for large times.
i wonder how long it takes to run it for thousands of iterations...
*/
@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
@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 / 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 / rand.c
Created March 15, 2012 23:29
Andrew Purcell's custom rand()
// sonystyle ^_^
int rand() {
return 1;
}
@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();
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 / 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);
@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