Skip to content

Instantly share code, notes, and snippets.

View stephencelis's full-sized avatar

Stephen Celis stephencelis

View GitHub Profile
@stephencelis
stephencelis / twoby.rb
Created May 16, 2013 23:12
Pretty big/breaking change in the new Ruby 2.0.0 patch level (p0 => p195).
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"}]
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"
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) {
#!/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/')"
@stephencelis
stephencelis / emoji.txt
Created April 3, 2012 18:38
iOS 6 / Mountain Lion Emoji
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
# 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"
@stephencelis
stephencelis / redcarpet.rb
Created August 29, 2011 05:54
Redcarpet (Markdown) template handler for Rails 3.1.
# 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
@stephencelis
stephencelis / Gemfile
Created February 15, 2011 14:12
Rails 3.1 Assets
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'
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
@stephencelis
stephencelis / Gemfile
Created December 21, 2010 15:10
CoffeeScript template handler for Rails 3.
gem 'coffee-script'
gem 'rails_assets', :git => 'git://github.com/wycats/rails_assets.git'