Skip to content

Instantly share code, notes, and snippets.

def change_description(cl)
Kernel.const_get(cl.model).describe_change(cl)
end
#
#
# WOULD THIS WORK, OR WOULD IT BREAK STUFF?
#
#
##OLD WAY
item(:field, :formatter => Proc.new{|derp| herp(derp)})
##NEW WAY
@eqdw
eqdw / evo
Created February 12, 2011 00:48
demonstration of genetic evolution with a string
Initial Word: ksjfhed
on iter 0
New word kspfhed on iteration 21
New word kspfied on iteration 43
New word kspfied on iteration 57
New word pspfied on iteration 68
New word pspfieo on iteration 69
New word pspfieo on iteration 93
New word pepfieo on iteration 99
on iter 100
#define MSG_FORMAT "%s cannot be authenticated.\n"
void incorrect_password(const char *user)
{
// user names are restricted to 256 characters (or less)
static const char *msg_format = MSG_FORMAT;
size_t len = strlen(user) + sizeof(MSG_FORMAT);
char *msg = (char *)malloc(len);
if (msg)
{
int ret = snprintf(msg, len, msg_format, user);
int i = 10;
while(i --> 0){
printf("%d\n", i);
}
@eqdw
eqdw / stefanize.rb
Created April 21, 2011 19:11
An extension that stef should always include
module Stefanize
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^(.*)_to_me$/
send($1.to_sym, *arguments, &block)
else
super
end
end
end
@eqdw
eqdw / gist:965159
Created May 10, 2011 19:09
pre-commit
#!/usr/bin/env ruby
result = `grep -rls "debugger" *`
if result != "" && result !~ /^log\/development\.log$/
puts "NEVER DO THIS AGAIN. THERE ARE DEBUG STATEMENTS IN THE CODEBASE"
puts "grep results: #{result}"
exit(1)
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
@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
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift