2009
11.23

Comparing the contents of a directory between two revisions:


svn diff --old=path/to/changed/dir@OLD_REV_NO --new=path/to/changed/dir@NEW_REV_NO
svn diff --old=path/to/changed/file.extension@OLD_REV_NO --new=path/to/changed/file.extension@NEW_REV_NO

This comes in very handy when comparing Production environment with Development environment.

2009
11.20

If you are logged into terminal on a remote server and about to perform an action which might affect all logged in users, for example changing MySQL root password, restarting the http server, etc. Use this command to send a broadcast message. This message is displayed on all the logged in users terminal with highest priority.

That’s it!

Lets take a case where you want to send absurdly long message. All you have to do is store it in a file and call the wall command like this:


>> wall `cat my_message.txt`

Note: You will be tempted to use it a chat application, but don’t.

2009
11.19

MySQL: Turn on query logging

By Satish Natarajan

  • Edit /etc/my.cnf
  • Add the line log=/var/lib/mysql/query.log

That’s all – you can see each query on the dev machine – helps you debug queries…

2009
11.19

Getting some special character in the mail?

By priyabrata

Are you getting some unwanted/special characters in mail by a mail program,that you have coded.?

It is a problem with some email clients who can’t handle long lines in the body of emails.The easiest way to fix ,is to put a line break character in strategic locations so that lines aren’t so long.

for example:
I wrote a mail program and in my mail body I was getting some extra characters like  “!#<td” etc.
I solved it ,by replacing my table structure that I used as a message body by replacing  ‘</td></tr>’ with ‘</td>’.”\n”.’<td>’.

2009
11.12

Rails Crontab with “whenever” gem

By subhash

INTRODUCTION

gem “whenever“  provides you with the valid cronjob syntax and also writes / updates the crontab file for you.

Installation

1.  $ gem install whenever

2.  Add below line to your config/environment.rb

  config.gem 'whenever', :lib => false, :source => 'http://gemcutter.org/'

3. Go to your applications root directory and run the below command
   $ wheneverize .

This will create a "config/schedule.rb" file for you.

EXAMPLE "config/schedule.rb"

set :environment, :development
set :path, "/var/www/MyApp"

# Scheduled Hourly
every 4.hours do
 command "/usr/bin/your_command"
 end

# Scheduled Daily
 every 1.day, :at => '12:00 am' do
 runner "MyModel.yourmethod"
 end

# Scheduled Weekly
 every :monday, :at => '11:00 pm' do
 rake   "your:rake:task"
 end

Consider the above as the contents of your config/schedule.rb file.

Now go to your root directory of your application(MyApp in my case),
and run the below command.

$ whenever

The above command will output valid syntax for the crontab as below.

0 0 * * * /var/www/MyApp/script/runner -e development "MyModel.yourmethod"

0 0,4,8,12,16,20 * * * /usr/bin/your_command

0 23 * * 1 cd /var/www/MyApp && RAILS_ENV=development /usr/bin/env rake your:rake:task

gem "whenever" also writes the above content for you in your crontab file,
You can do this by running below command

 $ whenever --update-crontab

you can see the above tasks in your crontab file by running "crontab -e".


2009
11.11

cat /etc/redhat-release

2009
11.11

you can add this to application.rb
filter_parameter_logging :card_number, :card_cvv, :password, :password_confirmation.

2009
11.08

When migrating from older databases to new version of MySQL. If the old database at some point had used latin1 charset and it was not properly upgraded – you will see strange characters due to latin1 – UTF8 charset issues.

A simple hack is to open the import file and add  the line

/*!40101 SET NAMES latin1 */;

Note: you replace the line that says utf8