Convert Ruby 1.8 to 1.9 hash syntax
nnoremap <Leader>: :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc<CR>
class Test::Unit::TestCase # Or ActiveSupport::TestCase if you are using Rails | |
# This is a debugging utility to find slow tests. | |
# Usage: rake FIND_SLOW_TESTS=true test:units | |
unless ENV["FIND_SLOW_TESTS"].blank? | |
alias_method :old_run, :run | |
def run(*args, &block) | |
start_time = Time.now | |
old_run *args, &block | |
test_time = Time.now - start_time | |
puts "\nSLOW TEST: #{self.name}, #{test_time}s" if test_time > 0.5 |
#!/usr/bin/env ruby -w0 | |
# | |
# Using Pomodoro app by iUgol | |
# http://itunes.apple.com/en/app/pomodoro/id417574133?mt=12 | |
# | |
require "rubygems" | |
require "appscript" # gem install rb-appscript | |
include Appscript |
source 'https://rubygems.org' | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
gem 'rails', github: "rails/rails" | |
gem 'arel', github: "rails/arel" | |
gem "rack", github: "rack/rack" | |
gem "sprockets", github: "rails/sprockets" | |
gem "sprockets-rails", github: "rails/sprockets-rails" | |
gem 'coffee-rails', github: "rails/coffee-rails" |
#embed this in your body tag | |
# %body{body_data} | |
def body_data | |
{ | |
:"data-controller" => params[:controller], | |
:"data-action" => params[:action], | |
:"data-id" => params[:id], | |
:"data-parent-controller" => parent_controller, | |
:"data-parent-id" => params["#{parent_controller.to_s.singularize}_id".to_sym] |
#!/usr/bin/env bash | |
branch_pattern="^## (.*)$" | |
git_status=`git status -sb` | |
if [[ $git_status =~ $branch_pattern ]] | |
then | |
echo ${BASH_REMATCH[1]} | |
fi |
From a (mostly) Ruby on Rails developer.
After doing the below everything seems to work (some of it worked before doing anything), including Ruby, Gems, RVM, Homebrew, VirtualBox/Vagrant VMs, Pow, tmux, git, vim.
/usr/local
to avoid super slow install, per option 1 in https://jimlindley.com/blog/yosemite-upgrade-homebrew-tips/: sudo mv /usr/local ~/local
/usr/local
, per option 1 in https://jimlindley.com/blog/yosemite-upgrade-homebrew-tips/: sudo mv ~/local /usr
add_index :attachments, :parent_id | |
add_index :attachments, :asset_id | |
add_index :domain_names, :user_id | |
add_index :domain_names, :event_id | |
add_index :event_memberships, :user_id | |
add_index :event_memberships, :event_id | |
remove_index :attachments, :parent_id | |
remove_index :attachments, :asset_id | |
remove_index:domain_names, :user_id | |
remove_index:domain_names, :event_id |
config :my_app, :twitter_api, | |
client: Twitter.SandboxClient |
class User < ActiveRecord::Base | |
attr_accessible :name | |
has_many :admin_memberships, class_name: "Membership", conditions: {role: 'admin'} | |
has_many :editor_memberships, class_name: "Membership", conditions: {role: 'editor'} | |
def admin? | |
admin_memberships.exists? | |
end |