Entries Tagged 'Never forget' ↓

Tarring and untarring stuff

Creating a new tar:

tar zcvf new.tar.gz the_folder_i_want_to_tar

Exploding the tar:

tar zxvf new.tar.gz

Backup and restore a MySQL database

Backup:

mysqldump -u user -p database_name > dump.sql
(Enter password)

Restore:

mysql -u user -p new_database_name < dump.sql
(Enter password)

How to set up a remote Git repository

On the remote server:

mkdir repository.git
cd repository.git
git --bare init

On the developer’s machine:

mkdir cool_app
cd cool_app
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin ssh://user@server:port/full/path/to/repository.git
git push origin master

More…

Run a single test on a Ruby on Rails application

The number of tests in the app I’m developing it’s getting really big. Sometimes, I just need to run a single test and not all of them. I only need to remember this line:

ruby -Itest test/unit/availability_time_test.rb

Convert string to integer in Javascript

var s = "1337";
alert(parseInt(s) * 2);

Time Javascript operations

Sometimes I need to time how long a Javascript operation takes. It’s very easy if you are using jQuery.

   console.time("longOperation");
   for (var i=0; i<1000; ++i){ var j = i*i; } //do something complicated
   console.timeEnd("longOperation");

Then, you’ll see the result in the Firebug console:
Time Javascript operations