Skip to content

Instantly share code, notes, and snippets.

// I used to write like this
int foo(int herp, int derp)
{
if(herp > derp)
{
bar();
}
}
@eqdw
eqdw / gist:1894268
Created February 23, 2012 18:39
CS STUDENTS? Y U NO ESCAPE PARAMS
<?php
// Get team ID from url
$teamID = $_GET["team"];
// - SQL Queries
// Get university and team name
$query = "SELECT * FROM `delegations` WHERE delegID = " . $teamID;
@eqdw
eqdw / life.rb
Created December 3, 2011 20:13
Conway's Game of Life
infile = ARGV[0]
@gridsize = ARGV[1].to_i
@world = Array.new(@gridsize+2){|i| Array.new(@gridsize+2){"."}}
File.open(infile, "r") do |f|
(1..@gridsize).each do |i|
row = f.gets
rowarr = row.split(" ")
@eqdw
eqdw / gist:1336975
Created November 3, 2011 16:32
EASIEST MERGEFIX EVER
<<<<<<< HEAD
=======
>>>>>>> payroll
class Chocolate
def white?; ...; end;
def caffeinated?; ...; end;
def imported?; ...; end;
end
#main script
var foo = {
bar: 3,
baz: function(){ /* a function body */}
}
foo.quxx = function(){ /* a function body */}
############# THIS IS WITHIN THE LIBRARY #############
class Foo
def initialize(a, b, c, opts={})
#do some stuff
end
end
######################################################
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
@eqdw
eqdw / controllers.rb
Created June 9, 2011 16:46 — forked from burke/controllers.rb
Things I wish existed...
class GenericController < ApplicationController
end
class SpecificController < GenericController
end
@eqdw
eqdw / gist:993404
Created May 26, 2011 15:54
pre-commit hook to prevent
#!/usr/bin/env ruby
result = `grep -rls "debugger" *`
results = result.split("\n").reject{ |res| res =~ /\.log\s*$/ || res =~ /^\s*$/}
if results.length > 0
puts "NEVER DO THIS AGAIN. THERE ARE DEBUG STATEMENTS IN THE CODEBASE"
puts "offending files:"
results.each do |r|
puts " #{r}"
end