Tag Archives: quick

Learning Saturday – III

There are no secrets to success. It is the result of preparation, hard work, and learning from failure. – Colin Powell

Happy Learning.


Hungry Saturday – II

It was great week.

Happy Learning.

Setup SSH alias

This is easy tip. But I never knew in so many years.

Tip : How to open remote shell without typing the full server and user detail. Its like SSH alias.

Open the ssh folder.

cd /home/ganu/.ssh/
touch config
vi config

Then add the following lines in the config file

Host host1
Host host2

Then save this file and just type

ssh host1

It will ask for password. And you are done.

Happy Bash.

Quick Perl Interview Points

Some years ago when I was planning for job change one of my close friend Deepak told me if you want to crack Perl interview just revise these points. I called these as bullet points.

Just revising these points for my reference and for your help.

This is no particular order and written as mentioned by him over the phone 🙂

  • Referencing – de-referencing of data types – scaler, hash, array
  • pack – unpack
  • string – split. while,
  • pop,push,shift,unshift
  • array – add variable..
  • hash print
  • data read from hash.
  • sorting – numeric or normal
  • file handing
  • DB connection.
  • path module.
  • use warning, use strict, dbi, cgi, dump
  • perl mysql connection
  • regular expression – all small example
  • adding module how to..
  • use
  • require
  • my or local diff.
  • package
  • why we use 1 in package.
  • little oops in perl
  • @ISA
  • command line in perl
  • /usr/bin/perl
  • CGI T
  • use dignostic
  • how to debug
  • perl -d
  • cpan to cgi.
  • pass by value , pass by reference
  • environment variable
  • data type of return value.
  • how to know that array has unique value
  • how to run system command from perl, how many ways. 4-5 ways. diff between each
  • spacial variable
  • comments in regular expression
  • what are the default error
  • what is slurp mode
  • file hander, opearion, third argument
  • how to escape
  • apache
  • sorting – numeric or normal
  • regular expression – all small example
  • adding module how to..

I will keep adding new point as and when I will get.
Comment your points.

Happy Perl.

Groovy: Use findAll to fetch string from long string.

How to use findAll() in groovy, when you have to find some specific string from string.

def name= 'this#   is to%% te$st ^in*d~~ all $$from CCa s<>>ng, this is basi?><:"{}cally fetch only interested thing.'
def name1 = ''
def findName = name.findAll(/[A-Za-z\s+]/).each{name1 += "${it}"}
println findName
println name1

We can also use

def findName = name.findAll(/[A-Za-z\s+]/)
def name1 = findName.join('')

This code will fetch only sting and space and give output in name1.

Output –

[t, h, i, s,  ,  ,  , i, s,  , t, o,  , t, e, s, t,  , i, n, d,  , a, l, l,  , f, r, o, m,  , C, C, a,  , s, t, i, n, g,  , t, h, i, s,  , i, s,  , b, a, s, i, c, a, l, l, y,  , f, e, t, c, h,  , o, n, l, y,  , i, n, t, e, r, e, s, t, e, d,  , t, h, i, n, g]
this   is to test ind all from CCa sting this is basically fetch only interested thing
BUILD SUCCESSFUL (total time: 1 second)

Program has many ways to do.
Happy Programming.

How to get Google Page-Rank from Perl Script

Today got good package by which directly we can get the google page rank.

This is the easiest way to find the google page rank from Perl Code.

I tried this code in 2 ways
1. By list in the code
2. By putting the site from command prompt.

use warnings;
use strict;

use WWW::Google::PageRank;
my $pr = WWW::Google::PageRank->new;

my $page = $ARGV[0];

my @sites = (
if(!$page) {
  foreach(@sites) {
	  print "$_ : ";
	  print scalar($pr->get($_)), "\n";
} else {
  print "$page : ";
  print scalar($pr->get($page)), "\n";

2 Ways to run this code

ankur@ankur:~> perl googlerank.pl
http://www.yahoo.com : 9
http://www.wordpress.org : 9
http://www.wordpress.com : 9
http://www.labnol.org : 6
ankur@ankur:~> perl googlerank.pl http://www.apple.com
http://www.apple.com : 9

This is the simplest code, we can change based on requirement.

Happy Perl.

Quick Nokia E72 Tips and Shortcut Keys

After Google I got some quick tips. all together.

[Left softkey] + [Right softkey]= Keylock

Longpress on the homescreen:
[ctrl]= Switch Profile To Silent/General
[0]= Opens The Browser
[sym]= Switching Bluetooth On/Off
[*]= Activate Voice Control For Music (Artist/Song Name)
[Space bar]= Torch On/Off
[Homekey]= Show All Open Applications
[Left Selection Key]= PlayUnread Messages
[Right Selection Key]= Activate Voice Control For Applications & Contacts
[end key]= Deactivate Data Connection (if applicable)

[Shift]= Caps Lock On/Off
[Shift]+[Return]= Selecting Notes/Messages
[Shift]+[up/down on the d-pad]= Selecting Several Notes/Messages
[Shift]+[left/right on the d-pad]= Highlighting Text
[Shift]+[C]= Copy
[Shift]+[V]= Paste
[Shift]+[A]= Select All
[FN]= Num Lock On/Off
[FN]+[Space]= Text Input Options & Symbols
[sym]= Select Symbols

[0]= Go To Homepage
[1]= Show Toolbar
[2]= Search
[3]= Previous Page
[4]= Save As Bookmark
[5]= Keypad Shortcuts
[6]= Reload
[7]= Full Screen
[8]= Page Overview
[9]= Go To Web Address
[*]= Zoom In
[#]= Zoom Out
[enter]= Select

Real Player
[*/2]= Fullscreen/Normal Screen
[#]= Sound On/Off
[D-pad/Scroll up/down]= Volume Up/Down
[D-pad left/right] = Fast Forward/Rewind
[enter] = Play/Pause

[send key]= Send Image
[enter]= Select
[backspace]= Delete

Ovi Maps:
[0]= Go To My Position
[1]= Map Mode
[2]= Tilt Map Down
[3]= 2D/3D Map Switch
[4]= Rotate Map Anti-Clockwise
[5]= Align Map North
[6]= Rotate Map Clockwise
[8]= Tilt Map Up
[*]= Zooming in
[#]= Zooming out

Press – Press and Release
Press and Hold – Press for 1-2 seconds and then release
Keyboard lock and release – Right softkey and then Left softkey
Display time, date, missing call and profile name when the E72 in screen save mode (Black) – Press and hold the middle navigation key.

Call voice mail – Press and hold 1
Call contact – Start typing the name of contact person
Fast dialing to contact – Press and Hold 2-9
Open call log – Press and hold call key
Contacts – Press Contacts key
Create new contact – Press and hole contacts key

Start web browser – Press and Hold 0 key
Hangup data connection – Press and hold end call key

Activate General profile and back to Silent profile – Press and Hold Control Key
Turn front flashlight on – Press and hold space key (with flashlight symbol)
Turn on/off bluetooth – Press and hold Symbol key

Voice commands
Messages reader – Press and Hold left softkey
Voice commands – Press and hold right softkey
Start music voice search – Press and hold * (Star key)

Application screen and back to home screen – Press Home key
Calendar – Press Calendar key
Create Meeting – Press and Hold calendar key
Email – Press Email key
Create new email – Press and Hold email key

Quick Other Tips
*#06# displays the IMEI – the serial number – of your phone. On the box of your device there should be the same number on the little sticker on one side of the box.
*#0000# displays the firmware and its date. Additionally there is the type (e.g. RM-159) and the name of your phone. This menu also gives you, if you own a N96, 5800, N85 and some other devices, the chance to update your firmware over the air.
*#92702689# (*#war_anty) displays the “warranty-menu” of your phone. Actually, in S60 it shows the time you spent on calls already.
*#2820# (*#bta_#) displays the bluetooth-address of your device. Every device has another bluetooth-address (works just if it has Bluetooth!).
*#62209526# (*#mac_wlan#) displays the MAC-address of your phone (works just if it has Wireless Lan!).
By pressing 0 (zero) for three seconds on the home-screen you easily can open the web browser.
By pressing the Menu/Home key for three seconds you open the task manager, which shows all opened applications.
Holding # for three seconds on the home screen you change the active profile to silent or back.
In the File manager, Photos application or Gallery you can sent your files really easily by pressing the green-answer key. Once you done that a lists pops up and you can decide whether you want to sent the file via e-mail, Bluetooth, upload it to a service or sent it as a message .
NOTE: The following codes can RESET your phone to the factory settings, all data on it will be deleted!
*#7780# (*#rst_#) does a soft-reset to your phone.
*#7370# (*#res_#) does a hard-reset to your phone.

Happy Calling.

setup django quick install

All this text and help provided by

Get the live code from live code base.

ankur@ankur:~> svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

Python interpreter can load Django’s code.
There are various ways of accomplishing this.
One of the most convenient, on Linux, Mac OSX or other Unix-like systems, is to use a symbolic link:

ankur@ankur:~> python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
ankur@ankur:~> ln -s `pwd`/django-trunk/django /usr/lib/python2.6/site-packages/django

This simply lets you type django-admin.py
from within any directory, rather than having to qualify the command with the full path to the file.

ankur@ankur:~> ln -s `pwd`/django-trunk/django/bin/django-admin.py /usr/local/bin

Now we don’t have to run python setup.py install,
because you’ve already carried out the equivalent actions in above steps.

ankur@ankur:~> mkdir django-code
ankur@ankur:~> cd django-code/
ankur@ankur:~> django-admin.py startproject mysite
ankur@ankur:~/django-code> ll
total 4
drwxr-xr-x 2 ankur users 4096 2010-09-18 12:09 mysite
ankur@ankur:~/django-code> cd mysite/
ankur@ankur:~/django-code/mysite> ll
total 24
-rw-r--r-- 1 ankur users    0 2010-09-18 12:08 __init__.py
-rwxr-xr-x 1 ankur users  546 2010-09-18 12:08 manage.py
-rw-r--r-- 1 ankur users 3386 2010-09-18 12:08 settings.py
-rw-r--r-- 1 ankur users  482 2010-09-18 12:08 urls.py
ankur@ankur:~/django-code/mysite> python manage.py runserver
Validating models...
0 errors found

Django version 1.3 pre-alpha SVN-13861, using settings 'mysite.settings'
Development server is running at
Quit the server with CONTROL-C.
[18/Sep/2010 02:11:07] "GET / HTTP/1.1" 200 2051

At Says

It worked!
Congratulations on your first Django-powered page.

moment of pride – ticket booking throught IRCTC

Case: Ticket Booking for diwali, Need train ticket for 3rd november, 2010 and ticket are available from today aka 5th August, 2010.

Train: Aravali Express 9707


  • At 0800 Hrs – Booking is not allowed IRCTC says you can book ticket after 8 AM, may be my watch is fast. Hold On you Breath…
  • At 0805 Hrs – Oh!! its showing the seats available total seats avail is around 400.I am ready with Quick Book Facility. Fast.Fast..Fast…
  • At 0807 Hrs – Clicked on quick book and payment is done. Good.Good..Good…
  • At 0808 Hrs – Payment is success fully done, and WTF it shows the error page from IRCTC. Prayed to GOD. 😦 Shit.Shit..Shit…
  • At 0809 Hrs – OMG!! Tickets are booked, thanks to Lord. Got only UB and SU. OMG.OMG..OMG…
  • At 0810 Hrs – WTF! Just checking the further status. The ticket status is now WL 156. Oh!Oh!!Oh!!!
  • At 0815 Hrs – Service Unavailable. 😦 😦 😦

Tickets are booked. Its like moment of pride. 😛

Happy Journey.

WWW-Web Site Essentials

I was reading a book couple of months back.

That book contains what are the fields you require for a good website. I noted down the points.

  • Testimonials
  • Promotions/offers
  • Photo Gallery
  • Blog
  • A good domain name
  • A good hosting company
  • CMS
  • Content update facility
  • Social media integration
  • RSS
  • Newsletter
  • Sitemap
  • About Us Page
  • Contact Us Page
  • Location Page
  • Client List / Affiliate List
  • Site Backup Facility
  • Site Analytics
  • Email Processes
  • Press Releases
  • Download
  • Search site
  • Notifications.
  • Security

Huff!! That contain so many things. This is not all.

If a site has all these things then this is complete site for ready for users.
Then it depends that what are the target users and who will use the site.
Based on that dynamic content can be added into the site.

Happy Web.

quick ffmpeg audio-video encoding usage help

o from last 2-3 days I spent my so much time on file conversion with ffmpeg and mencoder.

After work done, I got some good links to follow for my future help and for all other readers.

The command what I tried for my use is like this

For High Quality and FFMPEG and libx264 vcodec i used this.

/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-b 1M -bt 4M -vcodec libx264 -pass 2 -vpre hq -acodec libfaac
-ac 2 -ar 44100 -ab 192k -threads 0 -s 552x311 -bufsize 200000000
-f flv -y /home/ganu/public_html/flvideo/316x.flv

Finally I used this this is working fine.

/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-r 30000/1001 -b 2M -bt 4M -acodec libfaac -ac 2 
-ar 44100 -ab 192k -s 552x311 -f flv -y /home/ganu/public_html/flvideo/316x.flv
/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-f image2 -ss 00:00:1 -s 120x90 -vframes 2
-y /home/ganu/public_html/tmp/thumbs/316/%08d.jpg

For metadata injection i used like this.

/usr/bin/flvtool2 -Uv

So first say the file 316.mp4 is converted to 316x.flv. And after flvtool2 the meta information is injected and final file will be 316.flv

So this is how, the flv conversion is done.

Happy Programming. 🙂

gnome-blog for wordpress.com blogs

This post will prove that, what I am writing from gnome-blog is successfully updated and uploaded.

editing again to say its success, and some more changes.

Directly this will not support ???.wordpress.com blogs. So for that in the preferences set

Blog Type : Self-Run Other
Blog Protocol : MetaWeblog
XML-RPC URL : http://{blogname}.wordpress.com/xmlrpc.php

Actually I am talking about this – gnome-blog

Happy Quick Blogging. 😀

PHP & MySQL quick search bookmarklets

If you want to quick search to MySQL, here is the fast quick bookmarklet


And the same goes for PHP too same like above…


Happy Programming. 😀

Find last day of the month in PHP

Yday I was working with dates and got the situation to get the last day of the month so got this piece of code.

date(’Y-m-d’,strtotime(’-1 second’,strtotime(’+1 month’,strtotime(date(’m').’/01/’.date(’Y').’ 00:00:00′))));

And this piece of code will gv you the last day of the your corrent month. 

tags: , , ,

%d bloggers like this: