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/


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


[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

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

Set widget label from action file in symfony 1.4

In Action File


$this->form = new youFormclassname();

To set individual Label

$this->form->getWidget(‘widgetname’)->setLabel(‘widget Custom label’);

To set multiple field label

‘field_name_1’    => ‘Field 1 Custom Lable’,

‘field_name_2’    => ‘Field 2 Custom Lable’,



In Template File


<?php echo $form[‘field_name_1’]->renderLabel() ?>

Replace any text from html text by tag name with specific attribute in php

function replace_tag_with_specific_attr_type( $tagAttribute, $tagAttributeValue, $subjectStr, $tagName=null,$replaceStr ) {
if( is_null($tagName) )
$tagName = ‘\w+’;
$tagName = preg_quote($tagName);

$tagAttribute = preg_quote($tagAttribute);
$tagAttributeValue = preg_quote($tagAttributeValue);

$match_regex = “/<(“.$tagName.”)[^>]*$tagAttribute\s*=\s*”.


$result = str_replace($matches[3],$replaceStr,$subjectStr);
return $result;

Usage :
Say for Example

$ActualStr : ‘<div class=’bannerpicsd’ ><span style=”margin: 0px 0px 0px 0px; width: 540px;”>something</span><p style=”float: right; margin: -240px 0 0; width: 200px;”>This is the actual String</p></div>’;
$StrToReplaceWith = ‘This is the replaces str’;

Now you want to replace all the text inside the div tags with class name “bannerpicsd”  from $ActualStr with $StrToReplaceWith
Then you can do as below:

$replacedStr  = replace_tag_with_specific_attr_type(‘class’,’bannerpicsd’,$ActualStr,’div’,$StrToReplaceWith);
Result :
<div class=”bannerpicsd” >This is the replaces str</div>
Enjoy 🙂