Category Archives: Quick Tutorial

How to hard reset Android LG P690, when touch is failed.


I am using LG-P690.

Today suddenly touch stopped working.  I am not able to do anything. Anything means anything. All my account are active and I am clueless what to do.

Before giving this phone to support I want to reset everything.

Objective : How to hard reset if your LG P690 touch is not working.

LG_P690

When the phone is fully off mode, press and hold the Home key + Volume down key + Power key. After some time say 5-10 seconds. You will get LG logo that time release the power key.

And when it will show the hard reset screen then release all the other keys.

And then take a deep breath and wait and finally your phone will be in same state when you have bought the same.

 

Happy Android.

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
  User=ganu
  Hostname=some.server.com
Host host2
  User=user2
  Hostname=some.host.server.com

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.

Drupal Bullet Points


I have used Drupal in 2008-2010 and worked on Drupal5 and Drupal6.

I am just collecting some keywords during my learning.

Drupal
Node
Content
Content Type
CCK
users
annonomouse user
logged in user
Roles and Permissions
role based permission
Single Sign on
blocks
modules
drupal plugin software
hook system
extensible
event driven system.
Drupal core
Drupal contributed
menus
menu paths
Drupal pages
Drupal index.php
clean urls
themes
site configutaiion..
error reporting…
status report
cron
performance
caching

Now I am not using Drupal, but which my work. This framework was awesome for CMS structure.

Happy Drupal.

How to enable Apache mod_rewrite in openSUSE


I got a situation where my Apache mod_rewrite module was not enabled for my openSUSE machine.
Here is the simple way to do it.

First check which apache modules are enabled in your machine.

ankur@ankur:/srv/www/htdocs> grep "^APACHE_MODULES" /etc/sysconfig/apache2
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5"

Second Change the apache2 config for modules and restart your apache.

ankur@ankur:/srv/www/htdocs> sudo vi /etc/sysconfig/apache2
ankur@ankur:/srv/www/htdocs> sudo /etc/init.d/apache2 restart
Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) done

Finally, chech you module is installed.

ankur@ankur:/srv/www/htdocs> grep "^APACHE_MODULES" /etc/sysconfig/apache2
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5 rewrite"

huh!! Its working.

Happy Apache.

Installing Groovy-Grails on Ubuntu


Now a days I am working with Groovy/Grails. This is really awesome language. Installing this in Ubuntu is very easy and this can be done very fast and in easy way. So how I installed Groovy/Grails up and running.

First install openjdk and groovy. Since in ubuntu these 2 packages are already available. So install it via apt-get.

sudo apt-get install openjdk-6-jdk
sudo apt-get install groovy

java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)

groovyConsole

Now for installing Grails. We need to install via binary zip file.
Get the latest Binary Zip file and save to some of your location.
Unzip the folder and move to /usr/share/grails/
I just moved grails to /usr/share/ because ubuntu install Groovy at /usr/share/groovy so making the similarity.

Now Set the JAVA_HOME and GRAILS_HOME path for your profile. Since we are installing Grails via zip binary so we need to tell the system that where is Grails and where is JAVA.

Open ~/.profiles file and add these lines at the top.

JAVA_HOME=/usr/lib/jvm/java-6-openjdk
GRAILS_HOME=/usr/share/grails
PATH=$PATH:/usr/share/grails/bin
export JAVA_HOME PATH
export GRAILS_HOME PATH

And logout and login again and do

printenv

This will show you that Grails path is set for our profile.

Now just say

ganu@ganu:/usr/share/grails$ grails
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Use ‘grails help’ for more info or ‘grails interactive’ to enter interactive mode

DONE !! WOW.

How to check where Groovy-Grails combination is working.

Go to your development Grails folder.

ganu@ganu:~/grails$ grails create-app wpdemo
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Base Directory: /home/ganu/grails
Resolving dependencies...
Dependencies resolved in 2867ms.
Running script /usr/share/grails/scripts/CreateApp_.groovy
Environment set to development
...........
Executing tomcat-1.3.6 plugin post-install script ...
Plugin tomcat-1.3.6 installed
Plugin provides the following new scripts:
------------------------------------------
grails tomcat
Created Grails Application at /home/ganu/grails/wpdemo
ganu@ganu:~/grails$ cd wpdemo/
ganu@ganu:~/grails/wpdemo$ ll
total 28
-rw-r--r--  1 ganu ganu  178 2011-02-13 03:43 application.properties
drwxr-xr-x 10 ganu ganu 4096 2010-12-15 08:22 grails-app
drwxr-xr-x  2 ganu ganu 4096 2011-02-13 03:43 lib
drwxr-xr-x  2 ganu ganu 4096 2011-02-13 03:43 scripts
drwxr-xr-x  4 ganu ganu 4096 2011-02-13 03:43 src
drwxr-xr-x  4 ganu ganu 4096 2011-02-13 03:43 test
drwxr-xr-x  7 ganu ganu 4096 2010-12-15 08:22 web-app
ganu@ganu:~/grails/wpdemo$ grails run-app
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Base Directory: /home/ganu/grails/wpdemo
Resolving dependencies...
Dependencies resolved in 2986ms.
Running script /usr/share/grails/scripts/RunApp.groovy
Environment set to development
...........
Running Grails application..
Server running. Browse to http://localhost:8080/wpdemo
Groovy/Grails SEtup

Groovy/Grails SEtup

Happy Programming.

Server Administration on LAMP Stack


The common process flow for LAMP Stack projects and there server maintenance.

  • * Get the best deal from hosting company.
  • * Get the root access and direct unique ID by which you can directly talk to them for any query and emergency.
  • * Do some hardware configuration check such as –
    • # CPU Check, Memory Check, Disk Space, Memory Status, Swap Space
  • * Do some software configuration check such as –
    • # LAMP Stack configuration, need to install via source or via standard packages.
  • * Security checks. Server need to be optimized with security checks.
    • # Configure Software Firewall.
    • # Changing in default SSH port
    • # Disable direct root login
    • # Change root password strong
    • # Create user group and give access to only developers and maintainers.
    • # White-list only port 80 and 443.
    • # Authenticate mailing ports.
    • # Enable SFTP for file uploads for developers.
    • # Disable SVN Access.
  • * Do server monitoring.
    • # Enable and watch server logs.
    • # Enable and watch error logs.
    • # Enable and watch slow query logs.
    • # Install Awstats for monitoring server logs.
    • # Install and configure Nagios as alert mechanism.
    • # Watch and maintain server space, memory utilization, HTTP Service, CPU Load, SSH Service.
  • * Later work on server optimization.
  • * Optimize PHP and MySQL configuration based on need and requirement.

This list can have more option. If you find new things, give me comments.

Happy Server.

Drupal Interview Questions


So while working with Drupal Projects in my previous company. Me and my team prepared some Drupal Interview Question. This does not have everything but this will be for 1st round for sure. If you know these many question then I think you know Drupal For Sure.

Here is the list which is basic Drupal Questions.

  • Drupal Basics – Node, Module, Teaser, theme, Path, taxonomy, Patch, Region, Block, Menu
  • Installation of Drupal, steps and how to upload it on the live site from the local Machine.
  • Core Module in Drupal, their Names and their Functionalities.
  • Hook, Node Concepts
  • Functions and their Functionalities for – t() Function, l() function, Watchdog functions etc
  • Theme System in Drupal.
  • Themes and Theme Templates.
  • Theme Engines (Interface between the Drupal Core and the theme template).
  • Theme Hooks (Provide a way of interaction between the Modules and theme)
  • Theme Template structure and different sections as Page.tpl.php, node.tpl.php, block.tpl.php, box.tpl.php, etc
  • Derivative themes or Sub themes or Theme inheritance concepts that came into existence in Drupal 6, about it and its functionalities.
  • Steps to create a derivative theme and how to move for creating the theme from Derivative themes to a new theme right from scratch.
  • Theme function.
  • Where the Drupal theme functions are defined?
  • How the Drupal Theme functions can be overridden.
  • How to Implement the AJAX Effects on the Block modules in Drupal 6
  • Theme registration and the concepts in Drupal 6.
  • CCK modules and its importance with major functionalities.
  • How to create a Module.
  • How to insert the database table schema from the Modules when they are installed and remove the table scheme when they are un-installed (modules.)
  • User, Permission, Role in Drupal
  • How the Drupal database works?

Please give comments for more Drupal Questions.

Long back I have shard my PHP Interview Questions also.

Happy Programming.

how to delete space between characters or number in a openoffice cell


How to delete space between characters or number in a openoffice cell.
Searched a lot and finally got the answer like this ..

Suppose you have these kind of requirement then

  • A1 cell 111 222 333 will be 111222333
  • A1 cell Hey whats up will be Heywhatsup

For TEXT Use :
=SUBSTITUTE(A9," ","")

For NUMBERS Use :
=–SUBSTITUTE(A9," ","")

Happy Calc.

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.

#!/usr/bin/perl
use warnings;
use strict;

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

my $page = $ARGV[0];

my @sites = (
  'http://www.yahoo.com',
  'http://www.wordpress.org',
  'http://www.wordpress.com',
  'http://www.labnol.org'
);
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
ankur@ankur:~>

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

Happy Perl.

Quick Tutorial – How to zip and unzip files under unix environment


Linux support zip and unzip facility.
All you need to install zip and unzip via apt-get in your debian/ubuntu linux.
The same is available via yum or zypper.

Some examples for zip and unzip.

1. Creates the zip archive and put all the files of the current directory in the compressed form.

ankur@ankur:~> cd test/
ankur@ankur:~/test> ll
total 0
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 3.txt
ankur@ankur:~/test> zip zipthis *
 adding: 1.txt (stored 0%)
 adding: 2.txt (stored 0%)
 adding: 3.txt (stored 0%)
ankur@ankur:~/test> ll
total 4
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test>

This command will automatically put the zip extension when the process will done.

2. Now try for zipping the subdirectory also..
Here I have created the subdirector as “subtest”.

ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test> zip -r subzipthis *
 adding: 1.txt (stored 0%)
 adding: 2.txt (stored 0%)
 adding: 3.txt (stored 0%)
 adding: subtest/ (stored 0%)
 adding: subtest/sub1.txt (stored 0%)
 adding: subtest/sub2.txt (stored 0%)
 adding: zipthis.zip (stored 0%)
ankur@ankur:~/test> ll
total 12
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test>

To use unzip to extract all files of the archive pics.zip into the current directory & subdirectories:

3. Listing of your files from a zip folder.

ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test> unzip -l subzipthis.zip
Archive:  subzipthis.zip
 Length     Date   Time    Name
 --------    ----   ----    ----
 0  10-20-10 10:03   1.txt
 0  10-20-10 10:03   2.txt
 0  10-20-10 10:03   3.txt
 0  10-20-10 10:14   subtest/
 0  10-20-10 10:14   subtest/sub1.txt
 0  10-20-10 10:14   subtest/sub2.txt
 382  10-20-10 10:05   zipthis.zip
 --------                   -------
 382                   7 files
ankur@ankur:~/test>

4. To test about your zip archive that archive is OK or not:

ankur@ankur:~/test> unzip -tq subzipthis.zip
No errors detected in compressed data of subzipthis.zip.
ankur@ankur:~/test> unzip -tq zipthis.zip
No errors detected in compressed data of zipthis.zip.

5. Unzip your data

ankur@ankur:~/test> unzip zipthis.zip
Archive:  zipthis.zip
 extracting: 1.txt
 extracting: 2.txt
 extracting: 3.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

6. Now you want to extract only the specific files from your zip folder. You can use like this…

ankur@ankur:~/test> unzip zipthis.zip 1.txt
Archive:  zipthis.zip
 extracting: 1.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

7. To extract all files to some specified directory.

ankur@ankur:~/test> unzip zipthis.zip -d /home/ankur/test/
Archive:  zipthis.zip
 extracting: /home/ankur/test/1.txt
 extracting: /home/ankur/test/2.txt
 extracting: /home/ankur/test/3.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

8. Unzip files one by one with confirmation.

ankur@ankur:~/test> unzip -q subzipthis.zip
replace 1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace 2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace 3.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace zipthis.zip? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
ankur@ankur:~/test> ll
total 12
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

9. Zip and Unzip version and liceance.

zip -v
zip -L
unzip -v

10. Help from zip and unzip

zip -h
unzip -h
%d bloggers like this: