This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]='' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this inside spec_helper.rb | |
def p(*objs) | |
puts objs.map { |o| inspect.gsub('<', '<').gsub('>', '>') }.join("\n") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Genetic algorithm playaround | |
# chendo 2009 | |
require 'rubygems' | |
require 'levenshtein' | |
class GA | |
def initialize | |
@pop = Array.new(100).map { random_string } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
NewerOlder