Timezone issue with cron

If your cron job timing does’t match with the server time zone for example. You have set the cron to run at 12:30 PM, but when you see the cron log the time show say 3:40 PM. So to run your cron job as per your time zone Say if you are in India, your cron job should run as per Indian time. So you have to add the following line before your cron job line.

CRON_TZ=”Asia/Kolkata” ## This is the important line
03 18 * * * wget http://www.abc.com/test.php >> /var/www/html/abc/logs/test-`date +\%Y\%m\%d`.log

`date +\%Y\%m\%d` => This will create the log as per date month and year wise. Date format enclosed by tick (`) sign

validate zipcode pincode on keypress using jquery

How to validate and restrict unwanted character for zipcode or pincode field using jquery

$(document).ready(function () {
$(‘#pincode’).keyup(function () {
var $th = $(this);
$th.val($th.val().replace(/[^0-9]/g, function (str) {
return ”;
}));
});
});

drupal clean URLs not working? with tilde sign

If your site is developed in Drupal and your URL looks like this:

If your site URL looks like this:

http://[domain name OR IP Address]/~[accountname]/anyFolder/

Example
http://example.com/~xyzaccount/somefolder/
http://xxx.xxx.xxx.xxx/~xyzaccount/somefolder/

Then you need to set RewriteBase!in your .htaccess file that looks like below

RewriteBase /~xyzaccount/somefolder

Force HTTPS url with .htaccess

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don’t put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

create high quality video using ffmpeg

You can use the open source ffmpeg program to convert a media file from low quality to high quality format

[shellprompt]# /fullpath/to/ffmpeg/ffmpeg -i source.mp4 -c:v libx264 -crf 19 destinationfile.flv

OR

[shellprompt]# /fullpath/to/ffmpeg/ffmpeg -i source.mp4 -c:v libx264 -ar 22050 -crf 28 destinationfile.flv

Parameter explained
-crf XX is the quality of the video you are looking for. It’s between 0 and 51 (but between 17 and 23 it’s a reasonable range and the lowest the number is, the better quality the video is going to be).

For the -ar 22050 it’s for adjusting the audio sample range (audio quality). You can choose 11025, 22050 or 44100.

For many other example and details explanation refer Tutorial for FFMPEG

convert video from one format to another using ffmpeg

You can use the open source ffmpeg program to convert a media file from one format to another.

Below is an exmple:

[shellprompt]# /fullpath/to/ffmpeglibrary/ffmpeg -i InputFile.FLV OutputFile.mp3

There are various other options you can use to specify the attribute of the output file.

Here are few of the examples code http://linuxers.org/book/export/html/593

create video thumbnail using ffmpeg

You can use the open source ffmpeg program to extract a frame to use as a thumbnail for a video.

Below is an exmple:

[shellprompt]# /fullpath/to/ffmpeglibrary/ffmpeg -i InputFile.FLV -vframes 1 -an -s 400×222 -ss 30 OutputFile.jpg

-i = Inputfile name
-vframes 1 = Output one frame
-an = Disable audio
-s 400×222 = Output size
-ss 30 = Grab the frame from 30 seconds into the video