Skip to content

Instantly share code, notes, and snippets.

View stephencelis's full-sized avatar

Stephen Celis stephencelis

View GitHub Profile
#import "SCListener.h" // Remember to link to AudioToolbox.framework.
// Start listening.
[[SCListener sharedListener] listen];
// Retrieve the average power.
[[SCListener sharedListener] averagePower];
// Retrieve the peak power.
[[SCListener sharedListener] peakPower];
@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 / minifacture.rb
Last active September 17, 2016 18:33
factory_girl for minitest
# factory_girl for minitest
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
#!/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 / 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) {
@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 / 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'