Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@wilsonsilva
wilsonsilva / duplicate_pg_database.sh
Last active August 29, 2015 13:59
Duplicate Postgres Database
su - postgres
pg_dump -f /tmp/dump_name.sql -U postgres current_database_name
psql -f /tmp/dump_name.sql new_database_name
@wilsonsilva
wilsonsilva / nginx.repo
Created April 27, 2014 15:30
nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
@wilsonsilva
wilsonsilva / arpwatch
Created May 26, 2014 21:27
Arpwatch configuration
# -u <username> : defines with what user id arpwatch should run
# -e <email> : the <email> where to send the reports
# -s <from> : the <from>-address
# -i <interface> : override the default network interface
OPTIONS="-u arpwatch -e wsilva -s 'root (Arpwatch)' -i wlp3s0"
@wilsonsilva
wilsonsilva / cls.sh
Last active August 29, 2015 14:02
Reset Command Line
# Create an alias for the command (an abbreviation)
alias cls='echo -en "\ec"'
# Usage:
cls
@wilsonsilva
wilsonsilva / install_ruby.sh
Created July 23, 2014 17:44
Install ruby and rubygems from source
# TODO: Use variables for the versions
# TODO: Accept command-line arguments and install everything
# Install Ruby
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
tar xvzf ruby-2.1.2.tar.gz
cd ruby-2.1.2
./configure --prefix=/usr
@wilsonsilva
wilsonsilva / set_timezone.sh
Created July 29, 2014 10:25
Set timezone in CentOS
# Sets the timezone to Europe/Lisbon
sudo mv /etc/localtime /etc/localtime.bak
sudo ln -s /usr/share/zoneinfo/Europe/Lisbon /etc/localtime
@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