Skip to content

Instantly share code, notes, and snippets.

View ryanwood's full-sized avatar

Ryan Wood ryanwood

View GitHub Profile
~/code/opensource/mousetrap[master]% cat spec/integration/settings.yml
# Replace user and password with your CheddarGetter credentials.
user: myaccount
password: mypass
# Go create a product in the CheddarGetter web admin interface named "mousetrap_test".
product_code: MOUSETRAP_TEST
~/code/opensource/mousetrap[master]% spec -c -fn spec/integration/smoke_test.rb
The Wrapper Gem
@ryanwood
ryanwood / active_admin_heroku.rb
Created October 4, 2011 14:36 — forked from hoverlover/active_admin_heroku.rb
Rails initializer for using ActiveAdmin with Sass on Heroku
if Rails.env.production?
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets"))
template_paths = [
"#{Gem.loaded_specs['activeadmin'].full_gem_path}/app/assets/stylesheets", # Rails 3.1.x (asset pipeline)
"#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/sass" # Rails 3.0.x
]
old_compile_path = "#{Rails.root}/public/stylesheets"
@ryanwood
ryanwood / postgresql.rb
Created December 30, 2011 14:54
Postgres 8.4.6 Homebrew forumula
require 'formula'
require 'hardware'
class Postgresql < Formula
homepage 'http://www.postgresql.org/'
url 'http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.6/postgresql-8.4.6.tar.bz2'
md5 'fcc3daaf2292fa6bf1185ec45e512db6'
depends_on 'readline'
depends_on 'libxml2' if MACOS_VERSION < 10.6 # Leopard libxml is too old
@ryanwood
ryanwood / Gemfile
Created May 23, 2012 13:28
Problems with Skim
...
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'skim'
end
gem 'jquery-rails'

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ryanwood
ryanwood / gist:5963144
Created July 10, 2013 02:58
Center ellipsis
def hollow(text, minimum_length = 4, edge_length = 3)
return text if text.length < minimum_length or text.length <= edge_length*2
edge = '.'*edge_length
mid_length = text.length - edge_length*2
text.gsub(/(#{edge}).{#{mid_length},}(#{edge})/, '\1...\2')
end
@ryanwood
ryanwood / gist:6076809
Created July 25, 2013 03:59
ActiveAdmin Error
NameError: uninitialized constant ActiveAdmin::BaseController
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/namespace.rb:200:in `eval'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/page_controller.rb:1:in `<top (required)>'
(eval):1:in `register_page_controller'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/namespace.rb:200:in `eval'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/namespace.rb:200:in `register_page_controller'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/namespace.rb:71:in `register_page'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin/application.rb:159:in `register_page'
~/.rvm/gems/ruby-2.0.0-p247@moonclerk/gems/activeadmin-0.6.0/lib/active_admin.rb:80:in `register_page'
~/projects/moonclerk/app.moonclerk.com/app/admin/dashboard.rb:1:in `<top (required)>'
∴ rc
Loading development environment (Rails 4.2.2)
[1] pry(main)> c = Camera.find 40
Camera Load (0.8ms) SELECT "cameras".* FROM "cameras" WHERE "cameras"."destroyed_at" IS NULL AND "cameras"."id" = $1 LIMIT 1 [["id", 40]]
#<Camera:0x007fe278278d98> {
:id => 40,
:property_id => 6,
:name => "Brooklyn",
:manufacturer => "Browning",
:model => "34",
Jun 07 13:26:53 moonclerk-production app/worker.2: 4 TID-gnbjf1wj4 WARN: Work still in progress [#<struct Sidekiq::BasicFetch::UnitOfWork queue="queue:default", job="{\"class\":\"NotificationDeliveryWorker\",\"args\":[10244225,870],\"retry\":true,\"queue\":\"default\",\"jid\":\"5a7e5da1e5c01e2bae91e019\",\"created_at\":1528402585.6521993,\"enqueued_at\":1528402585.6522868}">, #<struct Sidekiq::BasicFetch::UnitOfWork queue="queue:default", job="{\"class\":\"NotificationDeliveryWorker\",\"args\":[10244227,12906],\"retry\":true,\"queue\":\"default\",\"jid\":\"c889f9e1fc4ec71cd6709c1d\",\"created_at\":1528402593.1283786,\"enqueued_at\":1528402593.1284351}">, #<struct Sidekiq::BasicFetch::UnitOfWork queue="queue:default", job="{\"class\":\"NotificationDeliveryWorker\",\"args\":[10244224,870],\"retry\":true,\"queue\":\"default\",\"jid\":\"7cedc98a9c1e0276b2b9f594\",\"created_at\":1528402585.6383643,\"enqueued_at\":1528402585.638433}">, #<struct Sidekiq::BasicFetch::UnitOfWork queue="queue:default", job="{\"class\":
@ryanwood
ryanwood / multi_io.rb
Last active November 28, 2018 15:31
MultiLogger
# So we can log to STDOUT and a file at once. ;)
class MultiIO
def initialize(*targets)
@targets = targets
end
def write(*args)
@targets.each {|t| t.write(*args)}
end