Monthly Archives: March 2012

mysqldump only schema

mysqldump -u [USER] -p [-h HOST] -d > /path/to/dump.sql

Execute sql files from terminal

on terminal

mysql -u [user] -p [-h host] [database] < /path/to/file.sql

on client

source /path/to/file.sql

or

\. /path/to/file.sql

Show/hide hidden files on Mac OS using terminal

show files

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

hide files

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder

Alias for cd ../ (terminal)

shopt -s autocd

Destroy Model on RoR

if you already create de table (rake db:create / rake db:migrate)

rake db:rollback

run this:

rails destroy model Modelname

Install database (RoR)

rake db:create
rake db:migrate
rake db:seed

Fix Workbench Error Code: 1175

just run this query:

SET SQL_SAFE_UPDATES = 0;

Get only number from a string

preg_replace('/[^\d]/', '', $str);

Install Ruby 1.9.3 with libyaml

wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar xzvf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure --prefix=/usr/local
make
make install
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar xzvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
make
make install

test

ruby -v
gem --version

untar files on terminal

tar -C path/to/folder -zxvf file.tar.gz
Page 1 of 212