Dump MySQL database

Quick (one line) command for dumping a MySQL database to a gzipped file:
mysqldump dbname -u root -p | gzip -c | cat > dbname-backup_$(date +%Y-%m-%d).sql.gz

ctags support for MooseX::Declare

--regex-perl="/^[ \t]*(class)[ \t]+([^\ \t;]+)\s*[ \t]*[{;]/\2/c,class,classes/"
--regex-perl="/^[ \t]*has[ \t]+'([^\ \t;\(]+)'/\1/p,property,properties/"
--regex-perl="/^[ \t]*method[ \t]+([^\ \t;\(]+)/\1/m,method,methods/"

Measure test coverage for Rails application

add to Rakefile:
require 'rcov/rcovtask'
namespace :test do  
  namespace :coverage do
    desc "Delete aggregate coverage data."
    task(:clean) { rm_f "coverage.data" }
  end 
  desc 'Aggregate code coverage for unit, functional and integration tests'
  task :coverage => "test:coverage:clean"
  %w[unit functional integration].each do |target|
    namespace :coverage do
      Rcov::RcovTask.new(target) do |t| 
        t.libs << "test"
        t.test_files = FileList["test/#{target}/*_test.rb"]
        t.output_dir = "test/coverage"
        t.verbose = true
        t.rcov_opts << '--rails --aggregate coverage.data -x "/.gem/"'
      end 
    end 
    task :coverage => "test:coverage:#{target}"
  end 
end
run tests: rake test:coverage
If you are using Hudson you can install "Ruby metrics plugin" Rcov plugin parses rcov html report files and shows it on hudson with a trend graph.

Remote GIT repository

on remote server $ mkdir ~/myapp.git && cd ~/myapp.git now create new empty repository $ git --bare init or clone existing repository $ git clone --bare ~/myapp myapp.git
on local host,
you can clone repository from remote server $ git clone mylogin@myserver.com:myapp.git or add 'remote' to existing copy of repository $ git remote add origin mylogin@myserver.com:myapp.git
add to .git/config
[branch "master"]
  remote = origin
  merge = refs/heads/master
now you can simply git push and git pull.
exporting a git repository via http $ cd proj.git
$ git --bare update-server-info
$ chmod a+x hooks/post-update

Download streaming media

mplayer mms://url.to.video.file.wmv -dumpstream -dumpfile file.wmv

Edit video file using ffmpeg

ffmpeg -i file1.avi -vcodec copy -acodec copy -ss 00:10:00 -t 00:05:00 file2.avi where:
-i : input file
-ss : start time
-t : duration time
or
-vframes : count frame to record

rip cd audio to mp3

rip cd audio to disc cdparanoia -B with -B option cdparanoia will split the output into multiple files at track boundaries.

next, you can compress wav file to mp3 using lame lame -h -V 4 track01.cdda.wav track01.mp3 where:
-h Use some quality improvements. Encoding will be slower, but the result will be of higher quality.
-V Enable VBR (Variable BitRate) and specifies the value of VBR quality.