Skip to content

Instantly share code, notes, and snippets.

View jumski's full-sized avatar
🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");

Wojtek Majewski jumski

🐴
For the lack of a nail, throw new HorseshoeNailNotFoundException("no nails!");
View GitHub Profile
@jumski
jumski / spec_helper_with_headless_chrome.rb
Created April 20, 2012 16:26
rspec around hook for runnign selenium_chrome with headless gem in capybara
c.around(:each, :js => true) do |example|
if Capybara.current_driver == :chrome
headless = Headless.new
headless.start
end
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@jumski
jumski / suggestions.js.coffee
Created May 25, 2012 07:10
Bakcbone jQuery Autocomplete View
#=require antykwariusz
#=require jquery-ui
class Antykwariusz.Suggestions extends Backbone.Collection
initialize: (options) ->
@term = ' '
@model = options.model
@modelUrl = (new @model).url
url: => "#{@modelUrl}?term=#{@term}"
@jumski
jumski / why_isnt_this_the_default.rb
Created June 6, 2012 13:25 — forked from tpope/why_isnt_this_the_default.rb
Raise an error on missing assets
Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do
class MissingAssetError < StandardError; end
def digest_for_with_presence_check(logical_path)
unless asset_environment[logical_path]
raise MissingAssetError.new("#{logical_path} doesn't exist")
end
digest_for_without_presence_check(logical_path)
end
alias_method_chain :digest_for, :presence_check
@jumski
jumski / deploy.rb
Created June 15, 2012 10:57
simple capistrano multistage
# put this in deploy.rb, set proper values and remove all "set" and "role" calls that are here from the global namespace
desc "Run tasks in staging enviroment."
task :staging do
set :keep_releases, 3
set :rvm_ruby_string, 'ruby-1.9.3-p0-falcon'
set :deploy_to, "/home/deploy/#{application}"
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@jumski
jumski / gist:3040290
Created July 3, 2012 15:03 — forked from zolrath/gist:2305333
tmux status line from wemux example.

For a tmux status line as seen in the example image for the wemux project: wemux

The session on the left in the example screen shot uses a patched font from the vim-powerline project. Inconsolata-dz, you beautiful creature.

To duplicate the left status line add the following lines to your ~/tmux.conf

set -g status-left-length 32
set -g status-right-length 150
@jumski
jumski / decorator_reloader.rb
Created July 11, 2012 14:28
Rails 3: reload custom files at each request (or in console using reload!)
if Rails.env.development?
decorator_paths = Dir['app/**/*_decorator.rb']
decorators_reloader = ActiveSupport::FileUpdateChecker.new(decorator_paths) do
decorator_paths.each { |path| load path }
end
ActionDispatch::Callbacks.to_prepare do
decorators_reloader.execute_if_updated
end
source 'http://rubygems.org'
gem 'rails', '3.2.6'
gem 'mysql2'
gem 'stringex'
gem 'geocoder'
gem 'activeadmin'
gem "rails_email_validator"
gem 'has_scope'
gem 'responders'
gem 'abacus_count'
@jumski
jumski / install.sh
Created July 16, 2012 21:32 — forked from cloud8421/install.sh
Install tmux 1.6 on Ubuntu 10.04
wget -q -O - https://raw.github.com/gist/2204072/install_tmux_1.6_on_ubuntu_10.04.sh | sudo bash