Skip to content

Instantly share code, notes, and snippets.

View filipebarcos's full-sized avatar

Filipe Costa filipebarcos

View GitHub Profile
@filipebarcos
filipebarcos / start_postgres.sh
Created June 26, 2012 03:23
Script to Run PostgreSQL on my Mac
#! /usr/bin/env bash
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl start -D /Library/PostgreSQL/9.1/data
@filipebarcos
filipebarcos / stop_postgres.sh
Created June 26, 2012 03:24
Script to Stop PostgreSQL on my Mac
#! /usr/bin/env bash
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl stop -D /Library/PostgreSQL/9.1/data -m fast
@filipebarcos
filipebarcos / .bash_profile
Created June 29, 2012 20:19
My .bash_profile configuration
#export
export EC2_HOME=$HOME/.ec2/ec2-api-tools
export MAVEN_HOME=$HOME/Desenvolvimento/apache-maven-3.0.3/
export RUBY_HOME=/usr/local/Cellar/ruby/1.9.3-p125
export PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:/usr/local/mysql/bin:$RUBY_HOME/bin:$EC2_HOME/bin:$PATH
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="4;33"
export CLICOLOR="auto"
export PS1='\n[\u] \[\033[1;33m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\] \n\$ '
@filipebarcos
filipebarcos / Tutorial.md
Created October 28, 2012 04:50
Create an Automator Services to open files and folder on VIM

If you use VIM you are like me, uses VIM as IDE, this workflow can be useful for you. I create an workflow using Automator to open the selected folder on Finder to be opened using VIM.

  1. Go to Automator and create a new Service
  2. Go to Actions/Utilities and select "Run Apple Script"
  3. On Services options, select the following options:
    1. Service receiver selected FOLDER AND FILES in FINDER.APP
  4. Copy the following apple script and save it.
  5. Voila! Test it and be happy ;)
@filipebarcos
filipebarcos / checking_ckeckboxes.js
Created October 29, 2012 16:21
Check all checkboxes in a form
$.each($('input:checkbox'), function(key, elem) {
$(elem).attr('checked', 'checked');
});
@filipebarcos
filipebarcos / hash.rb
Created November 14, 2012 02:41
symbolize keys for hashes
class Hash
def symbolize_keys
self.inject({}) { |acc, elem| acc.merge!(elem[0].to_sym => elem[1]) }
end
def deep_symbolize_keys
self.inject({}) do |acc, elem|
acc.merge! elem[0].to_sym => elem[1].class == Hash ? elem[1].deep_symbolize_keys : elem[1]
end
end
@filipebarcos
filipebarcos / version.rb
Created August 7, 2013 13:47
Figure out which SQLite3 version your sqlite3 gem is getting
database = SQLite3::Database.new('your_database.db')
version = database.execute("SELECT sqlite_version() AS 'SQLite Version';").flatten # it returns [['3.x.x']]
@filipebarcos
filipebarcos / what_i_did.sh
Created August 14, 2013 20:21
After vito failure to install postgres (9.1) in Ubuntu 12.04
# when I tried to start postgres, I had an error telling me there were no postgres clusters created
# so I had to create one using the `pg_createcluster` command, like the following
pg_createcluster 9.1 main --start
#after creating the cluster, it will start the server because of `--start`
#so I had to change to postgresql user
sudo su - postgres
#to change it's pasword, doing `psql -d <database_name> -U <username>
psql -d postgres -U postgres
bash -l -c 'rbenv local 1.9.3-p125 &&
gem install brakeman --no-ri --no-rdoc &&
brakeman -o brakeman-output.tabs --no-progress --separate-models &&
rbenv local --unset'
#! /bin/bash
#with your postgresql setup up, with you postgres user too, let's do this o improve your postgresql performance
cd ~
wget http://pgfoundry.org/frs/download.php/2449/pgtune-0.9.3.tar.gz
tar -zxvf pgtune-0.9.3.tar.gz
cd pgtune-0.9.3
#first parameter is where your postgresql.conf is
./pgtune -i /etc/postgresql/9.0/main/postgresql.conf -o ~/postgresql.conf.pgtune --type Web
cp /etc/postgresql/9.0/main/postgresql.conf /etc/postgresql/9.0/main/postgresql.conf.bkp