This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am chendo on github. | |
* I am chendo (https://keybase.io/chendo) on keybase. | |
* I have a public key whose fingerprint is A4DE F0C8 847D 31DB 8B81 5264 EB16 FAE3 D887 BCDF | |
To claim this, I am signing this object: |
This file contains 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
module RequiredKeywordArguments | |
def required!(name) | |
backtrace = caller_locations(1).map { |c| c.to_s } | |
ex = ArgumentError.new("Missing required keyword argument '#{name}'") | |
ex.set_backtrace(backtrace) | |
raise ex | |
end | |
end | |
class Foo |
This file contains 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
require 'celluloid/io' | |
require 'socket' | |
class Server | |
include Celluloid::IO | |
def run | |
@tcp = TCPServer.new('0.0.0.0', 31337) | |
loop do | |
Connection.new_link(@tcp.accept).async.run |
This file contains 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
package main | |
import ( | |
"fmt" | |
"github.com/apcera/nats" | |
"runtime" | |
"sync/atomic" | |
"time" | |
) |
This file contains 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); |
This file contains 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 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 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 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 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 |
OlderNewer