Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@wilsonsilva
wilsonsilva / british
Last active August 29, 2015 14:04
My notes on the british accent
http://www.lbc.co.uk/
both - beuth
talking - toukin
naughty - nouty
no - neu
so - seu
you - yeu
cant - cânt
daughter - douter
@wilsonsilva
wilsonsilva / post-receive.sh
Created September 16, 2014 22:28
post-receive hook for the production and staging environments
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "production" == "$branch" -o "master" == "$branch" ]; then
git --work-tree=/var/www/tracker/production/ checkout -f $branch
cd /var/www/tracker/production/
# Install any packages, if needed
npm install
# Restart the application. Note: the application uid should be 'app'
@wilsonsilva
wilsonsilva / migrations.rb
Created February 11, 2015 13:59
Rails Migration Cheat Sheet
bundle exec rails g migration AddUserRefToProducts user:references
# Generates
class AddUserRefToProducts < ActiveRecord::Migration
def change
add_reference :products, :user, index: true
end
end
@wilsonsilva
wilsonsilva / read
Created March 24, 2015 11:38
Read process output
sudo tail -f /proc/<pid>/fd/1
example: sudo tail -f /proc/2394/fd/1
@wilsonsilva
wilsonsilva / small_spec.rb
Last active October 13, 2015 11:39
RSpec one liners
describe User do
subject { create(:user, name: 'Wilson Silva', activated: true) }
it { is_expected.to be_activated }
its(:name) { is_expected.to eq('Wilson Silva') }
end
@wilsonsilva
wilsonsilva / dts
Last active August 29, 2015 14:25
Deploy current branch to staging using capistrano
#!/bin/sh
export BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
echo "Deploying $BRANCH to staging"
cap staging deploy
@wilsonsilva
wilsonsilva / remove-old-branches.sh
Last active August 29, 2015 14:27
Deletes all local branches that are already merged into master
#!/bin/bash
git branch --merged master | grep -v 'master$' | xargs git branch -d
@wilsonsilva
wilsonsilva / crazy_method.rb
Created December 11, 2015 10:25
Crazy Ruby Method
def self.❨╯°□°❩╯︵┻━┻
puts 'Calm down, yo.'
end
@wilsonsilva
wilsonsilva / undo_last_commit.sh
Created June 21, 2017 15:47
Undo last commit but keep changes
# https://stackoverflow.com/a/44672195/3013522
git reset --soft HEAD~1
describe '#educate' do
 it 'increments the education level by 1' do
  expect { person.educate }.to change { person.education_level }.from(1).to(2)
  end
end