Skip to content

Instantly share code, notes, and snippets.

View slawosz's full-sized avatar

Sławosz Sławiński slawosz

View GitHub Profile
def foo(bar, &baz)
baz.call(bar)
end
foo "bar" do |bar|
puts bar
end
foo("bar", lambda{|baz| puts bar })
class Programmer < ActiveRecord::Base
has_many :assignments
has_many :projects, :through => :assignments
end
class Programmer < ActiveRecord::Base
has_many :projects, :through => :assignments
end
@slawosz
slawosz / application.js.coffee
Created December 17, 2011 16:59 — forked from ddemaree/application.js.coffee
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
Change all 1.8 hashes to 1.9: `find -name '*.*rb' | xargs sed -i 's/:\([a-zA-Z_1-9]\+\) => /\1: /g'`
@slawosz
slawosz / 0-readme.md
Created February 1, 2012 07:49 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@slawosz
slawosz / id_rsa.pub
Created April 12, 2012 07:53
Public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCS3+74pH+rMQyzqxnvxRJkvRG+Bw6+6yVddiik7CBMpexCLzCLQ2JYC+3eXE34zZHg63zRJx1mg3gC/5EPHLuJnbze+nNu9eSZYw1/xc+muspHGg8gNLSiSFl11HbM3xXC67UUUNgRo0gzH9LRbA31OzREygASTZnWFgLoYAAWtU+fK6Fm0Sy7PIUdQVbGDM10loCFloyfbBlimqRPsSbMkCyqInJ64pU7LXzE8HMGnmPMfUHc2AXuWbQQfJGBsepL/+Xo3m1a2hMHGRCa9ZT9lL3R1VEflXENH/yUzfGiTaXitJ+WT/XOAA+yb4QY/cQgndvWP/lB04TN2BK9KgxF slawosz@gmail.com
@slawosz
slawosz / gc_test1.rb
Created September 30, 2012 19:57
Some simple profiling, memprof works only in 1.8!
class SimpleCalculator
def initialize(i)
@i = i
end
def calculate
@i * 6
end
end
@slawosz
slawosz / gist:3814476
Created October 1, 2012 21:17
Scala currying example
def sum(f: Int => Int)(a: Int, b: Int): Int = {
if (a > b) 0
else f(a) + sum(f)(a + 1, b)
}
def product(f: Int => Int)(a: Int, b: Int): Int = {
if (a > b) 1
else f(a) * product(f)(a + 1, b)
}
@slawosz
slawosz / shared_examples.rb
Created November 23, 2012 10:46
rspec beauty #1
# instead
shared_examples_for "ApplicationController" do |params|
it "should complain about missing parameters" do
params.each_key do |key|
result = request_proc.call(params.except(key))
result.should be_bad_request
end
end
end
@slawosz
slawosz / 0-readme.md
Created November 26, 2012 16:49 — forked from sxua/0-readme.md
ruby-1.9.3-p286 cumulative performance patch.

Patch for ruby 1.9.3-p327 is here: https://gist.github.com/4063779

Patched ruby 1.9.3-p286 for 30% faster rails boot

Overview

This script installs a patched version of ruby 1.9.3-p286 with boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches.