Skip to content

Instantly share code, notes, and snippets.

@isaiah
isaiah / gist:05e1f44346bfb11df89c
Created June 1, 2015 14:04
My Vimium bindings
# Insert your prefered key mappings here.
unmap h
unmap l
map h previousTab
map l nextTab
map u restoreTab
map d removeTab
map b Vomnibar.activateTabSelection
map t Vomnibar.activateInNewTab
@isaiah
isaiah / keyword_param.rb
Created February 17, 2015 14:51
scalable keyword parameter declaration
class Base
def xtest(foo:, bar:, **extra)
puts "base: #{foo}, #{bar}"
end
end
class Artzt < Base
def xtest(foo:, bar:, blah:)
super
puts "child: #{foo}, #{bar} #{blah}"
@isaiah
isaiah / vimperator
Created January 9, 2015 21:37
Custom key mappings to turn Vimium into vimperator
unmap h
unmap l
map h previousTab
map l nextTab
map u restoreTab
map d removeTab
map b Vomnibar.activateTabSelection
map t Vomnibar.activateInNewTab
map <c-o> goBack
@isaiah
isaiah / lazy.rb
Last active August 29, 2015 14:10
Pure ruby implementation of lazy enumerator
class Enumerator
class Lazy
def initialize(coll)
@lazy = Yid.new do |yielder|
if block_given?
coll.each do |x|
yield yielder, x
end
else
@isaiah
isaiah / fib.rb
Created November 26, 2014 14:17
Lazy evaluated fibonacci sequence
class Fib
def self.fib
a, b = [0, 1]
s = 1..Float::INFINITY
Enumerator::Lazy.new(s.lazy) do |yielder, val|
a, b = b, a + b
yielder << a
end
end
end
@isaiah
isaiah / Gemfile
Last active August 29, 2015 14:06
Bootsrap haml navbar & fixed footer layout
source 'https://rubygems.org'
gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'
gem 'haml-rails'
gem 'bootstrap-sass'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta1'
# Use postgresql as the database for Active Record
@isaiah
isaiah / non-streaming-headers
Last active August 29, 2015 14:04
Rails live streaming sample
$ curl localhost:8080 -I
HTTP/1.1 200 OK
Content-Type: text/html
ETag: "0f8cca87cff164a57033f54d75dc1288"
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.017000
Server: Jubilee(2.1.0)
Transfer-Encoding: chunked
Date: Thu, 24 Jul 2014 14:38:03 GMT