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
def keyword_fun arg = nil, **options | |
[arg, options] | |
end | |
keyword_fun hello: 'world', 'goodnight' => 'moon' | |
# Ruby 2.0.0p0 | |
# => [nil, {:hello=>"world", "goodnight"=>"moon"}] | |
# Ruby 2.0.0p195 | |
# => [{"goodnight"=>"moon"}, {:hello=>"world"}] |
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 'formula' | |
class Burl < Formula | |
homepage 'https://github.com/visionmedia/burl' | |
version '1.0.1' | |
url 'https://github.com/visionmedia/burl/tarball/1.0.1' | |
sha1 'f24bdfee9d2be74c20602aa12970f84df26214b2' | |
def install | |
system "make install" |
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
class CachedAccount < CachedDelegateClass(Recurly::Account) | |
self.cache_key = :account_code | |
cache_constructor :find | |
cache(:billing_info) | |
cache(:subscription) { subscriptions.live.first } | |
cache(:add_ons) { subscription.try(:add_ons).to_a } | |
cache(:plan) { subscription.try :plan } | |
cache(:balance) { |
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
#!/usr/bin/env sh | |
# | |
# Works best with blinking text: the last heart will blink when you have less | |
# than 25% of your battery life remaining. | |
# | |
# Add the following to your `~/.tmux.conf`; | |
# | |
# set -g status-right "#[fg=red]#(path/to/zelda-battery-tmux.sh) " | |
battery="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')" |
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
2139 ℹ INFORMATION SOURCE | |
23EB ⏫ BLACK UP-POINTING DOUBLE TRIANGLE | |
23EC ⏬ BLACK DOWN-POINTING DOUBLE TRIANGLE | |
23F0 ⏰ ALARM CLOCK | |
23F3 ⏳ HOURGLASS WITH FLOWING SAND | |
26C5 ⛅ SUN BEHIND CLOUD | |
26D4 ⛔ NO ENTRY | |
2705 ✅ WHITE HEAVY CHECK MARK | |
2753 ❓ BLACK QUESTION MARK ORNAMENT | |
2757 ❗ HEAVY EXCLAMATION MARK SYMBOL |
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
# Helper methods to encode and parse nested query strings without a | |
# third-party library (e.g. ActiveSupport, Addressable, or Rack). | |
module NestedQuery | |
autoload :CGI, 'cgi' | |
extend self | |
# Dumps a hash into a nested query string. | |
# | |
# NestedQuery.encode a: [1, 3], b: { 2 => 4 }, c: 5 | |
# # => "a%5B%5D=1&a%5B%5D=3&b%5B2%5D=4&c=5" |
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
# config/initializers/redcarpet.rb | |
class ActionView::Template | |
class Redcarpet < Handler | |
include Handlers::Compilable | |
def compile template | |
::Redcarpet.new(template.source).to_html.inspect | |
end | |
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
gem 'coffee-script' | |
gem 'compass', | |
:git => 'git://github.com/chriseppstein/compass.git', | |
:branch => 'master' | |
gem 'rails_assets', | |
:git => 'git://github.com/wycats/rails_assets.git' |
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 'open-uri' | |
require 'digest/md5' | |
class << OpenURI | |
CACHE_DIR = Rails.root.join 'tmp', 'cache', 'open-uri' | |
CACHE_DIR.mkdir unless CACHE_DIR.exist? | |
alias cache_original_open_uri open_uri | |
def open_uri name, *rest, &block | |
snap = Digest::MD5.hexdigest name.to_s |
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
gem 'coffee-script' | |
gem 'rails_assets', :git => 'git://github.com/wycats/rails_assets.git' |
NewerOlder