Skip to content

Instantly share code, notes, and snippets.

@jbodah
jbodah / sym_link
Created October 27, 2014 17:13
unix symbolic link
@jbodah
jbodah / gist:c286e1e992596616b8b3
Created October 23, 2014 19:53
vim substitute current word
" maps substitute command to sub out the current word for quick refactorings
nmap <leader>re :%s/<c-r>=expand("<cword>")<cr>/
@jbodah
jbodah / gist:2dd6e0e6dd5e1b7b5f94
Created October 23, 2014 19:02
recursive subdirectory grep
# grep all files in this directory (and subdirectories) that end in .rb and contain 'guests = self.guests'
grep -r 'guests = self.guests' . --include \*.rb
@jbodah
jbodah / gist:2811d7d8f5ba1f15fcb9
Created October 22, 2014 22:14
ruby ctags gen
ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)
@jbodah
jbodah / pidfile kill
Created October 22, 2014 17:31
kill from pid file
kill $(cat tmp/pids/server.pid)
@jbodah
jbodah / kill_pg_listeners
Last active August 29, 2015 14:07
kill all postgres listeners
ps xa | grep postgres: | grep "backupify_development" | grep -v grep | awk '{print $1}' | xargs kill
@jbodah
jbodah / base_wrapper_exception.rb
Created October 20, 2014 23:20
Ruby exception wrapping
# A generic error that implementations can use to wrap their exceptions with
class BaseWrapperException < StandardError
def initialize(e = nil)
super e
return self unless e.present? && e.is_a?(Exception)
# Preserve the original exception's data
set_backtrace e.backtrace
message.prepend "#{e.class}: "
end
end
@jbodah
jbodah / rubocop.yml
Created October 16, 2014 20:39
my rubocop.yml
# Inherits everything else from defaul Rubocop config
Metrics/LineLength:
Max: 100
Style/SpaceBeforeBlockBraces:
Enabled: false
Style/SpaceInsideBlockBraces:
Enabled: false
@jbodah
jbodah / Guardfile
Last active August 29, 2015 14:07
my guardfile
# require 'guard/plugin'
#
# module ::Guard
# class BackupifyTest < ::Guard::Plugin
# def run_all
# end
#
# def run_on_changes(paths)
# paths.each do |path|
# raise :task_has_failed unless system "ruby -Itest #{path}"
@jbodah
jbodah / rails_test_routes.rb
Created August 6, 2014 18:13
Dynamically add controller routes
setup do
# Setup a route for our fake controller
Rails.application.routes.draw do
get "/readonlymodetest/foo" => "DOMAIN/read_only_mode_test#foo"
get "/readonlymodetest/foo_with_write" => "DOMAIN/read_only_mode_test#foo_with_write"
root :to => 'pages#show', :id => 'home'
end
end