Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@lukeredpath
lukeredpath / fizzbuzz.lol
Created April 4, 2012 12:46
LOLCode fizzbuzz
HAI
CAN HAS STDIO?
I HAS A VAR IZ 0
IM IN YR LOOP
UPZ VAR!!1
IZ VAR BIGR THAN 100?
GTFO.
KTHX
IZ VAR LEFTOVAR 15 LIEK 0?
VISIBLE "FIZZBUZZ"
@lukeredpath
lukeredpath / fizzbuzz.rb
Created April 4, 2012 12:42
Over-engineered fizzbuzz
# over-engineered version
module FizzBuzzer
def self.evenly_divisible_by?(number, by_number)
(number % by_number) == 0
end
class Fizz
def self.satisfied_by?(number)
FizzBuzzer.evenly_divisible_by?(number, 3)
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@judofyr
judofyr / evil.rb
Created March 29, 2012 15:21
Experimenting with MRI internals in FFI
require 'ffi'
class Object
def memory_location
object_id * 2
end
def to_pointer
FFI::Pointer.new(memory_location)
end
@solnic
solnic / osx_rails_env_setup_in_6_steps.md
Created March 29, 2012 12:33
6 steps to get up'n'running with Rails on OS X

6 steps to set up a rails development environment on OS X:

  • install Apple Command Line Tools
  • install homebrew[1]: /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
  • install rvm: bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
  • install ruby rvm install 1.9.3
  • install rails
def lazy
yield
rescue NameError
Module.new
end
begin
raise "foo"
rescue lazy { Foo }, lazy { Exception }
end
@funny-falcon
funny-falcon / not_ugly_test.rb
Created March 12, 2012 05:53
uglier is sometimes faster
#!/usr/bin/env ruby
require 'yaml'
y=[]
(1..10000).each{|x|
#next unless x/2==(1.0*x)/2
z=x
divisors=[1]
_continue=true
@tarcieri
tarcieri / benchmark.rb
Created March 11, 2012 04:03
Puma parser benchmark
require 'rubygems'
require 'puma'
require 'benchmark/ips'
request = <<-REQUEST
GET / HTTP/1.1
Host: www.example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 Safari/535.11
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@avdi
avdi / dem_bones.rb
Created March 8, 2012 06:48
Failure in two-level has_one...:through chain
# This is in a Rails 3.0 app
# Class names changed to protect the innocent
class NeckBone
has_one :back_bone
has_one :thigh_bone, :through => :back_bone
has_one :knee_bone, :through => :thigh_bone
delegate :walk_around, :to => :knee_bone
end
@Epictetus
Epictetus / 0-readme.md
Created March 8, 2012 06:32 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.