Subscribe:

Ads 468x60px

Friday, August 31, 2012

Useful Linux Commands

Here I am documenting few useful linux terminal command:


  1. Command to report system disk space usage:
    [osao@slc01nga ~]df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/xvda2           195592588 177362320   8294652  96% /
    tmpfs                  3931448       368   3931080   1% /dev/shm
    /dev/xvda1             1007896    124588    832108  14% /boot
    slcnas411:/export/home1/osao
                         16106127360 8378327360 7727800000  53% /home/osao
    10.246.4.40:/vol/ade_infra/prod/LINUX.X64
                         100663296   5784768  94878528   6% /usr/dev_infra/platform
    10.246.4.37:/vol/ade_infra/prod/GENERIC
                         100663296   5784768  94878528   6% /usr/dev_infra/generic
    slc1001nap:/vol/local/x86_64/redhat/60_prod/packages
                         1132462080 1087278784  45183296  97% /usr/local/remote/packages
    slc1001nap:/vol/local/linux/redhat/packages
                         1132462080 1087278784  45183296  97% /usr/local/redhat/packages
    Command to see these in summarised short form
    [osao@slc01nga ~]df -lhk
  2. Command for knowing all services running on a machine
    [osao@slc01nga ~] nmap localhost     (in place of localhost you can give other live machine also in your intranet)

  3. Command for knowing a port number for service running and Process ID (pid)
    [osao@slc01nga ~]netstat -anp | grep 9000  (it will search a service running on port no. 9000)
    The following two command will also do the same:
    [osao@slc01nga ~] lsof -w -n -i tcp:8080
    [osao@slc01nga ~]  fuser -n tcp 8080
  4. Command for knowing Directory/File size
    [osao@slc01nga ~]du -hs
  5. Command for searching particular string in particular files in regular expression form
    For ex. here we are searching in all files whose name end contains .jspx or .jsff and file contains text "encoding"
    [osao@slc01nga ~]grep -H -r -n -i --color "encoding" . --include='*.[j][s][fp][xf]'
  6. Perl Command to replace all occurences of string to other string
    the format is
    [osao@slc01nga ~]/usr/bin/perl -p -i -e "s/string1/string2/g"  
    For Ex. for converting all occurences of "ReSult" to "" We will invoke the command
      [osao@slc01nga ~] /usr/bin/perl -p -i -e "s/ReSuLt/$Result_Count<\\/font>/g"






Thursday, August 30, 2012

All about File System and Pendrive formatting


For long time, I have been delaying the proper understanding about all types of filesystems we see while formatting disk-drives/pendrives. But today I decided to drill down, investigate and better document it one place taking some 1/2 an hour. So, here it is.

How to format disk-drive/pen-drive in windows/linux

It's almost same in both OS, right click on the drive -> Format->Start->Ok
But in between we come across 4 options for Filetypes . In Windows-XP/windows7 (FAT, FAT32, NTFS and exFAT) and in Linux(FAT, ext2, ext4 and encrypted FAT). We will not see FAT and FAT32 if our drive memory is > 32 GB. So what is the difference between these file systems and which one should we choose? Let’s look at the advantages of each.

Various Filetypes

Advantages of NTFS  over FAT & FAT32:

  • read/write files > 4 GB and up to maximum partition size. (So, if your jump drive stores oftenly HD movies or big setup file > 4GB. NTFS is best suited.)
  • In NTFS partition memory created are > 32GB.
  • Better file compression filesystem used, hence better space management.
  • better space management = less fragmentation.
  • allows more clusters on larger drives = less wasted space.
  • add user permissions to individual files and folders (Windows Professional).
  • on-the-fly file encryption using EFS (Encrypting File System in Windows XP and 7).

Advantages of FAT & FAT32 over NTFS:

  • compatible with virtually all operating systems.
  • takes up less space on USB drive.
  • less disk writing operations = faster and less memory usage.

exFAT Compared To FAT & FAT32:

  • read/write files larger than 4 GB.
  • create drive partitions larger than 32 GB.
  • better space management = less fragmentation.

Wednesday, August 8, 2012

List of Comments in all Programming/Scripting language

I always find it difficult to remember the syntax of different programming/scripting languages I learnt/know. And most common syntax is Comments in various programming/scripting language. So, here I am documenting them all.
Comments are used to embed/put programmer/human-readable comments/tips/suggestion/annotations in the source code of a computer program. Those comments are generally significant to programmers but typically ignorable to compilers and interpreters.

  1. Java
    1. One liner:  // comments
    2. Multi liner: /*  first line
                           second line
                           third line
                      */

  2. Ada
    1. One liner:  -- comments
    2. Multi liner: -- first line
                       -- second line

  3. C#
    1. One liner:  // comments
    2. Multi liner: /*  first line
                           second line
                           third line
                      */

  4. C++
    1. One liner: // comments
    2. Multi liner: /* first line
                           second line
                           third line
                       */

Monday, August 6, 2012

How to find IP Address and Geographical Location of Website

Yes, it's very much possible.
There are 2 methods for finding IP Address of website.

Method 1:
Go to Command Terminal. Invoke command "ping "
for ex. I passed command "ping www.google.com"

 
Whenever we ping the domain name of any website, the ping packet goes to the website and returns the acknowledgement packet with the IP Address of the website. Many famous/giant Web sites do not return replies(acknowledgement) to ping commands because lot's of ppl keep trying for this(like I tried in example "ping www.google.com"). So to avoid unnecessary traffic, they write a bot, not to reply back to pings,  but the site IP address can usually still be obtained. This "ping" technique will fail if the website is not-hosted/blocked/temporarily down/unavailable or if the server/computer used to perform the ping is not connected to the Internet.
You can also try typing only the IP Address in URL address bar of browser, it will work ! because it makes interface with DNS in between.

Saturday, August 4, 2012

How to take complete webpage screenshot in Chrome and Firefox


How to take complete webpage screenshot in Chrome, Firefox and Explorer


Conventional Methods

  • Pressing Fn+Prnt Scrn  keys together will give you complete screenshot of what is visible in monitor (and not the complete website )
  • Pressing Alt+Prnt Scrn keys together will give you screenshot of Current window and not the taskbar, battery status, time, volume like things in up/down of the control window

For Complete webpage screenshot

Source Code Formatter for bloggers blogspot websites

This is the free Source code formatter you can use, Paste your HTML/XHTML/XML code into textbox and click "Format Source Code" button. The obtained Formatted Source Code you can paste in your website/blog as it is, to see it in Previewed form as shown below. (Just in case if this UI in some browser doesn't work, please get it done at http://usefultechtalk.blogspot.in/2012/08/how-to-add-html-posts-in-website-or.html)
Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code
[Please like/share/comment if you find it useful !!]

How to add HTML Code in Website or Blogs



How to add HTML Code in Website or Blogs

Long back, I came across a doubt about how to add html/xhtml or other markup tags as it is in any blog or website. because web browser by default interpret it as normal tag and render it as normal html form(we want in text form). There are few methods.

Method 1)

Go to this free website Simplebits.com
In the "Enter Markup" textbox enter the html code which you want to see as it is in text form in your website/blog. Click Process. You will find in "Cut n Paste" textbox similar code (with converstion of  < as "& lt;"  > as "& gt;" new-line as <br/>). Paste this in your blog/website.



That's Done ! 

Symbolic Link for htdocs in Linux XAMPP


Creating Symbolic Link for htdocs in Linux XAMPP

As we know, the http://localhost in the web browser maps to the content of htdocs directory of /opt/lampp/htdocs and this htdocs directory doesn't have read/write permission(only limited to root). Many people(I also) tried to change the permission by invoking in terminal as root:
chmod -R 755 /opt/lampp/
but it creates issues:
 you will be stuck at splash.php (the language selection screen) when navigating to localhost!
and also it's troublesome to keep changing permissions in /opt/lampp/htdocs directory for various .html and .php files for testing. 
So, how to get rid of this ???
One popular solution is, to create symbolic link of htdocs to another directory at desirable place and change it's permission.
Essentially this means that your projects will technically exist in this new folder which will reside in your Home folder, but XAMPP will treat it as if it were located within htdocs.

Step 1.) Make a directory at any desirable location.
mkdir ~/test
Step 2.)Create symbolic/soft link
sudo ln -s ~/test /opt/lampp/htdocs



Enter root's password (if root password is not set, then set it using command "sudo passwd root")

How to add Share,Like or Recommend buttons in Blogs or Website

How to add Share Like Recommend Buttons in Blogs or Website


Social networking has became important these days and if you are a blogger, website developer then it becomes penultimate to give your blog/website a social plugin touch to enhance page and hit counts.Adding this facebook share button will show a neat count of how many times your post has been shared and will also allow your readers to share it.
I went through plenty of blogs/tutorials to add buttons of facebook but at last found that they are all old and problematic, the best method is to use iframe tag of html.

First, what's an iframe tag ?
An iframe is used to display a web page within a web page. For ex. the following html code will render the below shown frame
 <!DOCTYPE html>  
 <html>  
 <body>  
 <iframe src="http://www.usefultechtalk.blogspot.in" width="600" height="400">  
  <p>Your browser does not support iframes.</p>  
 </iframe>  
 </body>  
 </html>  
Please note the widht and height


Here is small and crisp tutorial for how to add Like/Share/Recommend buttons in different forms

Log in to Blogger, go to Design / Layout > Edit HTML or if you are planning to implement in our website then open the .html page in any editor

Now you have options to add different social plugin tools as follows:



Like Button:

Step 1: Go to Facebook's Like Button plugin page:

Step 2: Post the complete URL of page in which you want to add Like button in "URL to Like"   textbox. for ex. if I paste the link of this blog there. http://usefultechtalk.blogspot.in/2012/08/how-to-add-sharelike-or-recommend.html and Press "Get Code".


Step 3: Please note that the first part of Javascript SDK "Plugin Code" (as show in below pic) will remain same for all plugins (Like, Share, Recommend, Comments etc). So, you just need to add it at the starting of your html page or blog open in HTML editing format.

Step 4: Add the second part of "Plugin Code" where ever you like to see the Like button. For ex. I added first part of "Plugin Code" at starting of these page and second part of "Plugin Code" here. Try to Click on Like Button.



Send Button: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Send Button plugin page:

Step 2: Post the complete URL of page in which you want to add Like button in "URL to Send"   textbox. for ex. if I paste the link of this blog there. http://usefultechtalk.blogspot.in/2012/08/how-to-add-sharelike-or-recommend.html and Press "Get Code".

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc)

Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Send Button.
For ex. I added the second part just after this sentence. Try it !



Subscribe Button: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Subscribe Button plugin page:

Step 2: The Subscribe button lets a user subscribe to your public updates on Facebook.There are two Subscribe button implementations: XFBML and Iframe. In the "Profile URL" textbox enter the Facebook profile link of yours or person who you want to subscribe (for example facebook profile URL for Mark Zuckerberg is http://www.facebook.com/zuck)  and Press "Get Code".

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc)

Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Send Button.
For ex. I added the second part just after this sentence. Try it !



Comments Button: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Comments Button plugin page:

Step 2: Post the complete URL of page in which you want to add Comments button in "URL to Comment on"   textbox. for ex. if I paste the link of this blog there. http://usefultechtalk.blogspot.in/2012/08/how-to-add-sharelike-or-recommend.html, Increase the "Number of Posts Visible" and Width as per your requirements and Press "Get Code".

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc)

Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Send Button.
For ex. I added the second part just after this sentence. Try Comment Hi/Hello !


Activity Feeds: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Activity Feeds plugin page:

Step 2: The Activity Feed plugin displays the most interesting recent activity taking place on your site. Since the content is hosted by Facebook, the plugin can display personalized content whether or not the user has logged into your site. The activity feed displays stories when users interact with content on your site, such as like, watch, read, play or any custom action. Activity is also displayed when users share content from your site in Facebook or if they comment on a page on your site in theComments box. The JavaScript SDK requires that you register your website with Facebook to get an App ID (or appId). The appId is a unique identifier for your site that ensures that we have the right level of security in place between the user and your website. In order to use the authentication methods, your app must be configured with an App Domain.

Step 3: Activity Plugin is only for the websites which are registered to/authorised by facebook. You need to send request for your website to facebook. Once you have App-Id you can use it in the Get Code box of the Activity Feeds plugin and "Get Code"

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc). You can get appId for popular websites like yahoo articles, stackoverflow etc. Here in the example you can see, I used Domain = "www.facebook.com" and AppID as 113869198637480 and "Get Code"


Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Send Button.
For ex. I added the second part just after this sentence and this is what you see based on your login(I see the same activity as shown in pic above :) ).


Recommend Button: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Recommend Button plugin page:

Step 2: It is again same as Activity Feeds where you will be needing AppID for the website/blog which you want visitors to recommend to others. For AppID you need to request to facebook as explained abvoe.




Like Box: (Very Attractive and Similar to Like Button implementation)

The Like Box is a social plugin that enables Facebook Page owners to attract and gain Likes from their own website. The Like Box enables users to:
  • See how many users already like this Page, and which of their friends like it too
  • Read recent posts from the Page
  • Like the Page with one click, without needing to visit the Page
So, first you need to make a page in facebook(like fans page, followers etc) corresponding to your website/blogs
Step 1: Go to Facebook's Like-Box plugin page:

Step 2: Post the complete URL of page in which you want to add Like-Box button in "URL to Send"   textbox. for ex. if I paste the link http://www.facebook.com/imdb and Press "Get Code".

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc)

Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Like-Box for the page.
For ex. I added the second part of "Plugin Code" corresponding to the imdb facebook page just after this sentence. It will show you how many of your friends have liked that page(you need to be logged in in fb in current browser)


Login button: (Very Similar to Like Button implementation)

Step 1: Go to Facebook's Login Button plugin page:

Step 2: Select options "Show Faces", Rows and Width. Get Code

Step 3: If you have not already added the Javascript SDK part of "Plugin Code " in the beginning of page in HTML form then add it. (Only once we need to add and we can then add any FB plugins like/share/recommend/comment/register etc)
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=123050457758183";
and update the bold part, it's the appId of the facebook page.

Step 4: Add Second part of the "Plugin Code" to your html format where you want to see Log-in Button.
For ex. I added the second part just after this sentence. 


Registration button: 


The Registration plugin allows users to easily sign up for your website with their Facebook account. The plugin is a simple iframe that you can drop into your page. When logged into Facebook, users see a form that is pre-filled with their Facebook information where appropriate.

The registration plugin gives you the flexibility to ask for additional information which is not available through the Facebook API (e.g. favorite movie).

This eliminates the need to provide two separate login experiences.
Step 1: The Registration button can be implemented best using iframe tag

Step 2: Copy the code below to your blog/webpage in html format to see register button.
--------------------------------------------------------------------------------------------------------
<iframe src="https://www.facebook.com/plugins/registration?
             client_id=113869198637480&
             redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fecho%2F&
             fields=name,birthday,gender,location,email"
        scrolling="auto"
        frameborder="no"
        style="border:none"
        allowTransparency="true"
        width="100%"
        height="330">
</iframe>

--------------------------------------------------------------------------------------------------------

Step 3: Please not various attributes like width, heigth, stle, fraemborder and userinfo fields. You can change it. (For more details See Documentation Page )
For ex. I added the second part just after this sentence. 



Facepile Button: (Very useful and attractive for websites involving login options for user)

The Facepile plugin displays the Facebook profile pictures of users who have connected with your page via a global or custom action, or can also be configured to display users that have signed up for your site. The Facepile plugin displays the Facebook profile pictures of users who have liked your page or have signed up for your site. For this you need AppId of your page/website generated by Facebook.

Step 1: For more details Go to Facebook's Documentation Page for Facepile




Friday, August 3, 2012

Complete XAMPP setup in Windows





Complete Setup Steps for Linux Boxes (Please refer to previous post)
XAMPP= (X-Cross Platform, A-Apache, M-Mysql, P-PHP and P-Perl)

Here is step by step guide to install XAMPP in Windows environment from Scratch.
1. Downlaod  latest version of XAMPP from here. 
Downlaod


2. I am using Installer version(.exe file) of XAMPP to install it to windows.It will be easy for Newbies to install with installer version of XAMPP.Once downloaded click on installer.you get following screen. select the language and click on OK.

Complete XAMPP setup in Linux



What is XAMPP ?
XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - just download, extract and start.

This guide will provide you step by step to process to setup XAMPP in your Linux machine and configure it to run a website on localhost environment.

Step 1.) Download appropriate Xampp release (preferably latest).
 (Attention: If you download these files on a Windows system and you're running McAfee virus scanner you may get a false positive virus warning. This is a problem with McAfee and gzip-compressed files, it should be ignored.)

Step 2.) After downloading simply type in the following commands:
      (For installing any application at linux you need to Root access of the computer. In Ubuntu by default the root       account is not enabled.If you are installing it on ubuntu then you need to ebable Root access for it by following command. Open your terminal and type following and invoke sudo passwd root)
  1. Go to a Linux shell and login as the system administrator root:
    osao@osao-laptop:~$ su

  2. Extract the downloaded archive file to /opt: root@osao-laptop:/home/osao# tar xvfz xampp-linux-1.8.0.tar.gz -C /opt
    Warning 1: Please use only this command to install XAMPP. DON'T use any Microsoft Windows tools to extract the archive, it won't work.
    Warning 2: already installed XAMPP versions get overwritten by this command.
That's all. XAMPP is now installed below the /opt/lampp directory.