Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Gustavo Matias gumatias

🏠
Working from home
View GitHub Profile
@gumatias
gumatias / find_and_replace_all.sh
Last active Apr 19, 2018
[Find and replace strings in directory] bash shortcut to find and replace a string across all files under a specified dir #Utilities
View find_and_replace_all.sh
find . -type f -name '*.js.coffee' -exec sed -i '' s#find#replace#g {} +
View gist:9919357

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@ryanb
ryanb / abilities.rb
Created Sep 15, 2012
How you can break up large Ability class in CanCan
View abilities.rb
module Abilities
def self.ability_for(user)
if user.admin?
AdminAbility.new(user)
else user
MemberAbility.new(user)
else
GuestAbility.new
end
end
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created Mar 23, 2012
Rspec Rails cheatsheet (include capybara matchers)
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

View gist:1637874
# ~/.gitconfig from @boblet
# initially based on http://rails.wincent.com/wiki/Git_quickstart
[core]
excludesfile = /Users/oli/.gitignore
legacyheaders = false # >git 1.5
quotepath = false
# http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
pager = less -r
# if ↑ doesn’t work, try: pager = less -+$LESS -FRX
@3dd13
3dd13 / generate_ssh_keys.rb
Created Jan 20, 2011
chef recipe to generate ssh key for a user
View generate_ssh_keys.rb
define :generate_ssh_keys, :user_account => nil do
username = params[:user_account]
raise ":user_account should be provided." if username.nil?
Chef::Log.debug("generate ssh skys for #{username}.")
execute "generate ssh skys for #{username}." do
user username
creates "/home/#{username}/.ssh/id_rsa.pub"