Skip to content

Instantly share code, notes, and snippets.

View chendo's full-sized avatar

chendo chendo

View GitHub Profile
# Daft Golf
# Encode the entire lyrics of Harder Better Faster Stronger in the least amount of characters
# without cheating. Source of lyrics: http://lyricwiki.org/Daft_Punk:Harder,_Better,_Faster,_Stronger
# First attempt without being really anal: 500b
s=%w(after better do ever faster harder hour is it make makes more never our over stronger than us work)
m1="chavnohzy3a7uvnb4iw21ogt3xwazyiw6gqsoaihdjw36q8encnd1oxfpy2eomjfxfr9"
m2="5vjlr1vcd8f7rdjb3c3zfk0kh6cjxc2l8dzvzk2hhfrwkg2n2ln04mpli1tq5gnfu7nvxc6dbk8yq9uxnfboimh5902mqtggizhhaakr2nk2xsh4qar5b8aypdocmeakqelscg11evw57i3ttep2ott0pqteclmae5sckhc"
def d(e, a)
t=e.to_i(36).to_s(2)
t[0]=''
# SMS Rickroll script
# Word by word.
# Total messages to be sent: 450
# By @chendo
# Requires sendsms and a jailbroken iPhone
song = "We're no strangers to love
You know the rules ... and so do I
A full commitment's what I'm ... thinkin' of
You wouldn't get this from any other guy
# put this inside spec_helper.rb
def p(*objs)
puts objs.map { |o| inspect.gsub('<', '&lt;').gsub('>', '&gt;') }.join("\n")
end
# Genetic algorithm playaround
# chendo 2009
require 'rubygems'
require 'levenshtein'
class GA
def initialize
@pop = Array.new(100).map { random_string }
end
# http://mozy.com/contest
# Question 4
# chendo's solution
require 'benchmark'
year = 0
fibs = [2, 0, 0, 0, 0] # age 0, 1, 2, 3, 4
adults = 0 # age > 5
Benchmark.bm do |bm|
# http://www.slate.com/id/2101150/sidebar/2101387/ent/2101353/
poem = <<-EOF.downcase.gsub(/[^a-z]/, '')
Dammit I'm mad.
Evil is a deed as I live.
God, am I reviled? I rise, my bed on a sun, I melt.
To be not one man emanating is sad. I piss.
Alas, it is so late. Who stops to help?
Man, it is hot. I'm in it. I tell.
I am not a devil. I level "Mad Dog".
@chendo
chendo / gist:10335
Created September 11, 2008 23:07
or maybe not. ignore this
/* Adding icon to status bar in 1.x */
NSString *pathToDefault = [NSString stringWithFormat:@"%@/Default.png", [[NSBundle mainBundle] bundlePath]];
NSURL *urlToDefault = [NSURL fileURLWithPath:pathToDefault];
CGImageDestinationRef dest = CGImageDestinationCreateWithURL((CFURLRef)urlToDefault, CFSTR("public.png")/*kUTTypePNG*/, 1, NULL);
CGImageDestinationAddImage(dest, defaultPNG, NULL);
CGImageDestinationFinalize(dest);
CFRelease(defaultPNG);