dreaming 'altruism' in all
Thursday, November 24, 2011
Tuesday, September 21, 2010
Google presents Shaastra Online Programming Contest 2010!
Please visit Shaastra website to know details and register.
I will strongly recommend to my college friends who enjoy the coding in C/C++, participate in such contest.
For practice you can register yourself on SPOJ one of the best choice of programmers globally.
As you know, me and my friends in JSS, Noida conducted similar contest, ONPC' 09 in C, C++ and JAVA last year, which was was very successful ( more than 250 teams from 11 countries).
I hope my friends in JSS will continue this glory this year!
Go and register, you will definitely enjoy the contest, it is a 4-6 hour contest on this Sunday !!!
Thursday, July 29, 2010
Getting USB storage device (Pen Drive) serial from mount label in Linux
In this post I will describe how to get this.
Your pen drive is mounted automatically as soon as you insert. (You can also mount manually; if not). By default it mounts in /media. To see:
# ls /media
Output can be like this
Disk MyDisk Disk2
"Disk", "MyDisk", "Disk2" is your device's mount labels.
And now run the script given in the last of this post using following command:
# sh vscript.sh '/media/Disk'
Notice the command line argument. It's your devices path where it is mounted. Give the path of the device which serial you want. "vscript.sh" is the name of the shell script given below (To run it with .sh extension ).
-------------------------------------------------------------------
-------------------------------------------------------------------
# This script takes the mount label as command line argument
# and print the serial of the USB mass storage device
# Author: Vishwesh Kumar Yadav
# Date: 28/05/2010
#Step1- Get mount Label of target device
label=$1
echo "Mount Label is : $label"
#Step2- Set device name in variable retrieved from df -h or /proc/mounts
sd=`df -h | grep "$label" | cut -d ' ' -f 1 | cut -d '/' -f 3`
echo "Device is : /dev/$sd"
#Step3- Get SCSI channel id
#I use rev command as in some OS like ubuntu and suse one extra
# parameter before every line exist in dmesg command.
#So I was unable to correctly cut exact field count.
sid=`dmesg | grep -nA 1 ": $sd" | tail -1 | cut -d ':' -f 1 | rev | cut -d ' ' -f 1`
echo "SCSI ID : $sid"
#Step4-Get Serial from /proc/scsi/usb-storage/
serial=`cat "/proc/scsi/usb-storage/$sid" | grep Serial | cut -d ':' -f 2`
echo "Serial is : $serial"
---------------------------------------------------------------------
---------------------------------------------------------------------
Above script is tested on following linux distros:
Ubuntu 10.04
Fedora 8,11 and 13
openSUSE 11.3
Mandriva Linux 2010.1
Linux Mint 9
PCLinuxOS 2010.07
CentOS 5.5
Please let me know, your experiences of getting serial. And your feedback on this post. Also please share if you test it on other unix/linux flavours.
Thanks.
Getting USB device serial in Linux
USB is a SCSI device. As per USB specification USB devices have
ProductID, VendorID and Serial. (Some Local pen drives may not have this serial). Serial of the USB device is unique and never change even you format the storage device.
In Linux you can get this information very easily by following ways:
Method 1:
# cat /proc/bus/usb/devices
You will get listing of all the USB devices something like this:
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=058f ProdID=6387 Rev= 1.41
S: Manufacturer=JetFlash
S: Product=Mass Storage Device
S: SerialNumber=WVIAZIUI
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Notice the 6th line containing "SerialNumber=WVIAZIUI"
Method 2:
# ls /proc/scsi/usb-storage
You will get name of the directories containing usb information for each usb storage device like:
4
Now,
# cat /proc/scsi/usb-storage/4
You will get output like this:
Host scsi4: usb-storage
Vendor: JetFlash
Product: Mass Storage Device
Serial Number: WVIAZIUI
Protocol: Transparent SCSI
Transport: Bulk
Quirks:
Notice the 4th line containing "Serial Number: WVIAZIUI"
As you can see it is very easy to get USB storage device serial in Linux but if you have more than one USB storage devices (Pen Drives) inserted in the system then
how to identify the serial of the particular device is a little bit tricky. In my next post I will describe step by step description of my shell script to get the serial of given device.
All methods given above and my script is tested on following Linux flavours:
Ubuntu 10.04
Fedora 8,11 and 13
openSUSE 11.3
Mandriva Linux 2010.1
Linux Mint 9
PCLinuxOS 2010.07
CentOS 5.5
Wednesday, April 1, 2009
What is Right to Information?
Right to Information includes the right to:
- Inspect works, documents, records.
- Take notes, extracts or certified copies of documents or records.
- Take certified samples of material.
- Obtain information in form of printouts, diskettes, floppies, tapes, video , cassettes or in any other electronic mode or through printouts.
"information" means any material in any form, including records, documents, memos, e-mails, opinions, advices, press releases, circulars, orders, logbooks, contracts, reports, papers, samples, models, data material held in any electronic form and information relating to any private body which can be accessed by a public authority under any other law for the time being in force.
"record" includes:
a) Any document, manuscript and file
b) Any microfilm, microfiche, and facsimile copy of a document
c) Any reproduction of image or images embodied in such microfilm (whether enlarged or not); and
d) Any other material produced by a computer or any other device;
An applicant cannot ask for opinions/advice/views under the RTI Act, unless the opinion/advice/view is already on "record".
However, under Section 4(1)(d), an applicant can ask for "reasons" behind a administrative or quasi judicial decision of a public authority, especially if he is a "affected person".
Saturday, March 28, 2009
How do Search Engines Work?
Search engines do not really search the World Wide Web directly. Each one searches a database of web pages that it has harvested and cached. When you use a search engine, you are always searching a somewhat stale copy of the real web page. When you click on links provided in a search engine's search results, you retrieve the current version of the page.
Search engine databases are selected and built by computer robot programs called spiders. These "crawl" the web, finding pages for potential inclusion by following the links in the pages they already have in their database. They cannot use imagination or enter terms in search boxes that they find on the web.
If a web page is never linked from any other page, search engine spiders cannot find it. The only way a brand new page can get into a search engine is for other pages to link to it, or for a human to submit its URL for inclusion. All major search engines offer ways to do this.
After spiders find pages, they pass them on to another computer program for "indexing." This program identifies the text, links, and other content in the page and stores it in the search engine database's files so that the database can be searched by keyword and whatever more advanced approaches are offered, and the page will be found if your search matches its content.
Many web pages are excluded from most search engines by policy. The contents of most of the searchable databases mounted on the web, such as library catalogs and article databases, are excluded because search engine spiders cannot access them. All this material is referred to as the "Invisible Web" -- what you don't see in search engine results.Sunday, August 17, 2008
Achievments of INDIA
Democracy n our Constitution r biggest achievments
1- Maintaining democracy till now is biggest achievment and maintaining "United India" inspite of diversity and maintaining secularism are big achievments.
2- Liberlisation of 1991 which leads to our economical success and some great success in
IT, Telecom, Software, Engineering, Pharmacy etc.......
3- Victory of 1971 war is great success because it was a war for freedom of Bangladesh and inspite of victory leaving 10000 soldiers alive !
4- Nuclear test and Nuclear deal r also great success.
5- Producing so many talents that In NASA, IBM, Microsoft, Google, No of Doctors in US, UK are more than 33 %. IIT, IISc and IIM r intitutes which produce such talents...
Before Azadi
1- The great men like Mahatma Gandhi, Mahatma Buddha, Mahavir swami, Samrat Ashok The Great, Aryabhatta, Chanakya (Kautilya), Chandragupta Maurya, Charak, Bhaskaracharya, Vivekanand, Akbar The Great, Kalidas.
All of these great peoples made India "Viswa Guru".
2- "Bhagvad Geeta" is a book which is the most influencing book of the world in all the era.
3- Our culture and civilization is oldest and greatest.
Conclusion -
From 3500 BC to 1800 AD we are the great economy and prosperous in culture and civilization of the world. And in 21st century we regain it and lead the world !!
Jai Hind ! Jai Hind !
Vandemataram Vandemataram Vandemataram.