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

Custom launcher in Ubuntu 11.10

Run this on terminal

gnome-desktop-item-edit ~/Desktop/ --create-new

Drag the desktop item that was created to the Launcher.

MySQL dump only one table without structure or only data

mysqldump -u USER -p -h SERVER DATABASE TABLE --skip-triggers --compact --no-create-info --complete_insert > path/to/save/your/dump.sql

Sum Businnes Day with PHP

function sum_business_day($date, $days) {
 
	list($year, $month, $day) = explode('-', $date);
 
	$business_day = 0;
	$add_day = 0;
 
	while ($add_day < $days) {
 
		$business_day++;
 
		$wday = gmdate('w', strtotime('+' . $business_day . ' day', mktime(0, 0, 0, $month, $day, $year)));
 
		if ($wday != 0 && $wday != 6) {
 
	            $add_day++;
		}
	}
 
	return gmdate('Y-m-d', strtotime('+ ' . $business_day . ' day', strtotime($date)));
}
Page 7 of 10« First...56789...Last »