<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5567577962358842243</id><updated>2011-11-28T05:28:33.879+06:00</updated><category term='mobile'/><category term='linux'/><category term='travel'/><category term='dos'/><category term='java'/><category term='norway'/><title type='text'>Shihab's Blog</title><subtitle type='html'>Hasan Shihab Uddin</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-4700116743445410875</id><published>2008-04-17T12:26:00.005+06:00</published><updated>2008-04-17T12:57:30.242+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Update /etc/hosts with IP address assigned through DHCP</title><content type='html'>My &lt;code&gt;/etc/hosts&lt;/code&gt; file looks something like:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;127.0.0.1       localhost&lt;br /&gt;127.0.1.1       shihabpc&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;The host name &lt;code&gt;shihabpc&lt;/code&gt; should be mapped to my network's IP address; not to a loop back IP address like &lt;code&gt;127.0.1.1&lt;/code&gt;. This is some how mandatory for &lt;a href="http://en.wikipedia.org/wiki/Java_remote_method_invocation" target="_blank"&gt;RMI&lt;/a&gt; to work properly.&lt;br /&gt;But the problem is that I have used DHCP to assign IP address and that is changed from one boot to another. So I have to change the &lt;code&gt;/etc/hosts&lt;/code&gt; file every time my IP address changes.&lt;br /&gt;So, I have written a script to update &lt;code&gt;/etc/hosts&lt;/code&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;# /home/shihab/fixhosts.sh&lt;br /&gt;&lt;br /&gt;file=/etc/hosts&lt;br /&gt;interface=eth0&lt;br /&gt;&lt;br /&gt;ip=`ip addr show $interface`&lt;br /&gt;ip=`echo "$ip" | grep "inet "`&lt;br /&gt;ip=`echo "$ip" | cut -d "i" -f 2`&lt;br /&gt;ip=`echo "$ip" | cut -d " " -f 2`&lt;br /&gt;ip=`echo "$ip" | cut -d / -f 1`&lt;br /&gt;&lt;br /&gt;hostname=`hostname`&lt;br /&gt;&lt;br /&gt;found=0&lt;br /&gt;while read line&lt;br /&gt;do&lt;br /&gt;  if [ "`echo "$line" | grep $hostname`" != "" ]; then&lt;br /&gt;    line="$ip $hostname"&lt;br /&gt;    found=1&lt;br /&gt;  fi&lt;br /&gt;  if [ -z "$text" ]; then&lt;br /&gt;    text="$line"&lt;br /&gt;  else&lt;br /&gt;    text="$text\n$line"&lt;br /&gt;  fi&lt;br /&gt;done &lt; $file&lt;br /&gt;&lt;br /&gt;if [ found = 0 ]; then&lt;br /&gt;  text="$text\n$ip $hostname"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;echo -e "$text" &gt; $file&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;And added it as an &lt;code&gt;init.d&lt;/code&gt; script:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;# /etc/init.d/fixhosts&lt;br /&gt;&lt;br /&gt;case "$1" in&lt;br /&gt;start)&lt;br /&gt;    /home/shihab/fixhosts.sh&lt;br /&gt;    ;;&lt;br /&gt;stop)&lt;br /&gt;    # do nothing ;)&lt;br /&gt;    ;;&lt;br /&gt;restart)&lt;br /&gt;    $0 stop&lt;br /&gt;    $0 start&lt;br /&gt;    ;;&lt;br /&gt;*)&lt;br /&gt;    echo "usage: $0 (start|stop|restart|help)"&lt;br /&gt;esac&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;$sudo update-rc.d fixhosts defaults 99&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;That's it! :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-4700116743445410875?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/4700116743445410875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=4700116743445410875' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/4700116743445410875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/4700116743445410875'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2008/04/update-etchosts-with-ip-address.html' title='Update /etc/hosts with IP address assigned through DHCP'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-8605384442836219337</id><published>2007-08-12T10:13:00.000+06:00</published><updated>2007-08-12T12:45:57.729+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Close resource inside and only inside finally block</title><content type='html'>Always close any resource (network connection, database connection, file stream) inside and only inside finally block. Don't close it inside try block. What is the problem of closing it inside try block? consider the following example:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;try {&lt;br /&gt;  String fileName = ...;&lt;br /&gt;  InputStream input = new FileInputStream(fileName);&lt;br /&gt;  // read theContentOfTheFile&lt;br /&gt;  input.close();&lt;br /&gt;  retrun theContentOfTheFile;&lt;br /&gt;} catch (IOException e) {&lt;br /&gt;  // log the exception&lt;br /&gt;  return null;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If an exception is thrown while reading &lt;code&gt;theContentOfTheFile&lt;/code&gt;, the &lt;code&gt;FileInputStream&lt;/code&gt; will never be closed.&lt;br /&gt;&lt;br /&gt;A better solution but not totally perfect:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;InputStream input = null;&lt;br /&gt;try {&lt;br /&gt;  String fileName = ...;&lt;br /&gt;  input = new FileInputStream(fileName);&lt;br /&gt;  // read theContentOfTheFile&lt;br /&gt;  input.close();&lt;br /&gt;  retrun theContentOfTheFile;&lt;br /&gt;} catch (IOException e) {&lt;br /&gt;  // log the exception&lt;br /&gt;  return null;&lt;br /&gt;} finally {&lt;br /&gt;  if (input != null) {&lt;br /&gt;    try {&lt;br /&gt;      input.close();&lt;br /&gt;    } catch (IOException e) {&lt;br /&gt;      // do nothing&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;If no exception is thrown inside the try block, then before returning from the method the finally block will also be executed. That means we are trying to close the same stream twice. So, an exception will always be thrown form the &lt;code&gt;input.close()&lt;/code&gt; inside the finally block.&lt;br /&gt;&lt;br /&gt;The best solution:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;InputStream input = null;&lt;br /&gt;try {&lt;br /&gt;  String fileName = ...;&lt;br /&gt;  input = new FileInputStream(fileName);&lt;br /&gt;  // read theContentOfTheFile&lt;br /&gt;  retrun theContentOfTheFile;&lt;br /&gt;} catch (IOException e) {&lt;br /&gt;  // log the exception&lt;br /&gt;  return null;&lt;br /&gt;} finally {&lt;br /&gt;  if (input != null) {&lt;br /&gt;    try {&lt;br /&gt;      input.close();&lt;br /&gt;    } catch (IOException e) {&lt;br /&gt;      // do nothing&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;In this example the &lt;code&gt;input.close()&lt;/code&gt; is granted to be executed once and only once.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-8605384442836219337?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/8605384442836219337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=8605384442836219337' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/8605384442836219337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/8605384442836219337'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/08/close-resource-inside-and-only-inside.html' title='Close resource inside and only inside finally block'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-3844619933176301634</id><published>2007-07-24T22:28:00.000+06:00</published><updated>2007-09-01T22:48:14.400+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Use System.currentTimeMillis() instead of Date or Calendar</title><content type='html'>Always try to use &lt;code&gt;System.currentTimeMillis()&lt;/code&gt; instead of &lt;code&gt;java.util.Date&lt;/code&gt; or &lt;code&gt;java.util.Calendar&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;Why?&lt;br /&gt;&lt;br /&gt;Because of performance. &lt;code&gt;Date&lt;/code&gt; and &lt;code&gt;Calendar&lt;/code&gt; internally calls &lt;code&gt;System.currentTimeMillis()&lt;/code&gt;. So, why not use it directly?&lt;br /&gt;&lt;br /&gt;A BAD example:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;long currentTime = Calendar.getInstance().getTimeInMillis();&lt;/code&gt;&lt;/pre&gt;So, what does &lt;code&gt;Calendar.getInstance()&lt;/code&gt; actually do? Following lines are just copied from the source code of jdk1.5:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;public static Calendar getInstance()&lt;br /&gt;{&lt;br /&gt;  Calendar cal = createCalendar(TimeZone.getDefaultRef(),&lt;br /&gt;                                Locale.getDefault());&lt;br /&gt;  cal.sharedZone = true;&lt;br /&gt;  return cal;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private static Calendar createCalendar(TimeZone zone,&lt;br /&gt;                                       Locale aLocale)&lt;br /&gt;{&lt;br /&gt;  if ("th".equals(aLocale.getLanguage()) &amp;&amp;&lt;br /&gt;      ("TH".equals(aLocale.getCountry()))) {&lt;br /&gt;    return new sun.util.BuddhistCalendar(zone, aLocale);&lt;br /&gt;  }&lt;br /&gt;  return new GregorianCalendar(zone, aLocale);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public GregorianCalendar(TimeZone zone, Locale aLocale) {&lt;br /&gt;  super(zone, aLocale);&lt;br /&gt;  gdate = (BaseCalendar.Date) gcal.newCalendarDate(zone);&lt;br /&gt;  setTimeInMillis(System.currentTimeMillis());&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;Have you got it? &lt;code&gt;Calendar.getInstance()&lt;/code&gt; checks &lt;code&gt;TimeZone&lt;/code&gt;, &lt;code&gt;Locale&lt;/code&gt; and of course &lt;code&gt;System.currentTimeMillis()&lt;/code&gt;. So, it's an expensive operation.&lt;br /&gt;&lt;br /&gt;Another bad example:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Date date = new Date(System.currentTimeMillis());&lt;/code&gt;&lt;/pre&gt;Why is it bad? Because, it should be as simple as:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Date date = new Date();&lt;/code&gt;&lt;/pre&gt;And, here is the apidoc of default constructor of &lt;code&gt;Date&lt;/code&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Allocates a Date object and initializes it so that&lt;br /&gt;it represents the time at which it was allocated,&lt;br /&gt;measured to the nearest millisecond.&lt;/code&gt;&lt;/pre&gt;Yet, another bad example:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Date date = Calendar.getInstance().getTime();&lt;/code&gt;&lt;/pre&gt;Now, when should we use &lt;code&gt;System.currentTimeMillis()&lt;/code&gt;:&lt;br /&gt;When we need only the millisecond representation of the current time.&lt;br /&gt;&lt;br /&gt;When should we use &lt;code&gt;Date&lt;/code&gt;: When we need a date object representing the current time.&lt;br /&gt;&lt;br /&gt;When should we use &lt;code&gt;Calendar.getInstance()&lt;/code&gt;: When we need &lt;code&gt;TimeZone&lt;/code&gt; or &lt;code&gt;Locale&lt;/code&gt; specific information. Another use of &lt;code&gt;Calender&lt;/code&gt; can be for creating constant &lt;code&gt;Date&lt;/code&gt; object:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;public static final Date INDEPENDENCE_DAY;&lt;br /&gt;&lt;br /&gt;static {&lt;br /&gt;  Calendar calendar = Calendar.getInstance();&lt;br /&gt;  calendar.set(1971, Calendar.MARCH, 26);&lt;br /&gt;  INDEPENDENCE_DAY = calendar.getTime();&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-3844619933176301634?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/3844619933176301634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=3844619933176301634' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/3844619933176301634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/3844619933176301634'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/07/use-systemcurrenttimemillis-instead-of.html' title='Use System.currentTimeMillis() instead of Date or Calendar'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-3177421809341102253</id><published>2007-07-14T10:05:00.000+06:00</published><updated>2007-09-01T22:53:19.687+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Conncting to Grameen Phone EDGE/GPRS in ubuntu linux using Nokia 6300 USB modem</title><content type='html'>This is the first time I am using ubuntu linux. I am writing this post from the newly installed ubuntu in my home PC. So, this is how I have connected to Grameen Phone EDGE using my Nokia 6300 USB modem.&lt;br /&gt;&lt;br /&gt;Check the vendor and product id of your phone, To do this simply connect your phone in Nokia mode through the USB cable.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;$ lsusb&lt;br /&gt;Bus 004 Device 001: ID 0000:0000&lt;br /&gt;Bus 005 Device 003: ID 0421:04f9 Nokia Mobile Phones&lt;br /&gt;Bus 005 Device 001: ID 0000:0000&lt;br /&gt;Bus 002 Device 001: ID 0000:0000&lt;/code&gt;&lt;/pre&gt;Notice the ID &lt;code&gt;0421:04f9 Nokia Mobile Phones&lt;/code&gt;. Here &lt;code&gt;0421&lt;/code&gt; is the vendor id and &lt;code&gt;04f9&lt;/code&gt; is the product id.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;$ sudo modprobe usbserial vendor=0x0421 product=0x04f9&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;$ wvdialconf create&lt;br /&gt;Editing `create'.&lt;br /&gt;&lt;br /&gt;Scanning your serial ports for a modem.&lt;br /&gt;&lt;br /&gt;WvModem&lt;*1&gt;: Cannot set information for serial port.&lt;br /&gt;ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud&lt;br /&gt;ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud&lt;br /&gt;ttyS0&lt;*1&gt;: ATQ0 V1 E1 -- and failed too at 115200, giving up.&lt;br /&gt;Modem Port Scan&lt;*1&gt;: S1   S2   S3   &lt;br /&gt;WvModem&lt;*1&gt;: Cannot get information for serial port.&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 Z -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 +FCLASS=0 -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Modem Identifier: ATI -- Nokia&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 4800: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 9600: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 19200: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 38400: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 57600: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 115200: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 230400: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Speed 460800: AT -- OK&lt;br /&gt;ttyACM0&lt;*1&gt;: Max speed is 460800; that should be safe.&lt;br /&gt;ttyACM0&lt;*1&gt;: ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 +FCLASS=0 -- OK&lt;br /&gt;&lt;br /&gt;Found an USB modem on /dev/ttyACM0.&lt;br /&gt;create&lt;Warn&gt;: Can't open 'create' for reading: No such file or directory&lt;br /&gt;create&lt;Warn&gt;: ...starting with blank configuration.&lt;br /&gt;Modem configuration written to create.&lt;br /&gt;ttyACM0&lt;Info&gt;: Speed 460800; init "ATQ0 V1 E1 S0=0 &amp;C1 &amp;D2 +FCLASS=0"&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;This shows that a modem is connected at /dev/ttyACM0&lt;br /&gt;&lt;pre&gt;&lt;code&gt;$ sudo cat &gt; /etc/wvdial.conf&lt;br /&gt;[Dialer Defaults]&lt;br /&gt;Modem = /dev/ttyACM0&lt;br /&gt;Baud = 460800&lt;br /&gt;Init1 = AT&amp;F&lt;br /&gt;Init2 = AT E0 V1 &amp;D2 &amp;C1 &amp;S0 S0=0 +dr=1&lt;br /&gt;Init3 = AT+IFC=2,2;+CVHU=1&lt;br /&gt;Init4 = ATS7=60+DS=3,0;&amp;K3&lt;br /&gt;Init5 = AT+CGDCONT=,,"gpinternet"&lt;br /&gt;Init6 = ATS0=0&lt;br /&gt;ISDN = 0&lt;br /&gt;Modem Type = Nokia GSM Phone USB Modem&lt;br /&gt;Phone = *99#&lt;br /&gt;Username = any&lt;br /&gt;Password = any&lt;br /&gt;Stupid Mode = 1&lt;/code&gt;&lt;/pre&gt;Now just dial your connection.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;$ sudo wvdial&lt;br /&gt;--&gt; WvDial: Internet dialer version 1.56&lt;br /&gt;--&gt; Cannot get information for serial port.&lt;br /&gt;--&gt; Initializing modem.&lt;br /&gt;--&gt; Sending: AT&amp;F&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: AT E0 V1 &amp;D2 &amp;C1 &amp;S0 S0=0 +dr=1&lt;br /&gt;AT E0 V1 &amp;D2 &amp;C1 &amp;S0 S0=0 +dr=1&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: AT+IFC=2,2;+CVHU=1&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: ATS7=60+DS=3,0;&amp;K3&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: AT+CGDCONT=,,"gpinternet"&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: ATS0=0&lt;br /&gt;OK&lt;br /&gt;--&gt; Modem initialized.&lt;br /&gt;--&gt; Sending: ATDT*99#&lt;br /&gt;--&gt; Waiting for carrier.&lt;br /&gt;CONNECT&lt;br /&gt;~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&amp;} }*} } g}%~&lt;br /&gt;--&gt; Carrier detected.  Starting PPP immediately.&lt;br /&gt;--&gt; Starting pppd at Sat Jul 14 10:37:55 2007&lt;br /&gt;--&gt; Pid of pppd: 8383&lt;br /&gt;--&gt; Using interface ppp0&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; local  IP address 10.130.9.55&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; remote IP address 10.6.6.6&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; primary   DNS address 202.56.4.120&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;br /&gt;--&gt; secondary DNS address 202.56.4.121&lt;br /&gt;--&gt; pppd: H[18]&lt;br /&gt;--&gt; [06][08][10][12][06][08]&lt;/code&gt;&lt;/pre&gt;To disconnect press Ctrl+C.&lt;br /&gt;&lt;br /&gt;Enjoy&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;a href="http://warofwords.wordpress.com/2007/05/27/using-gprs-with-ubuntu-without-bluetooth-ankur-shrivastava-linux-usb-nokia-modem-internet/"&gt;http://warofwords.wordpress.com/2007/05/27/using-gprs-with-ubuntu-without-bluetooth-ankur-shrivastava-linux-usb-nokia-modem-internet/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://gentoo-wiki.com/Nokia_N60_series"&gt;http://gentoo-wiki.com/Nokia_N60_series&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.marzocca.net/linux/ubuntux31.html#gprs"&gt;http://www.marzocca.net/linux/ubuntux31.html#gprs&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-3177421809341102253?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/3177421809341102253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=3177421809341102253' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/3177421809341102253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/3177421809341102253'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/07/using-grameen-phone-edgegprs-in-ubuntu.html' title='Conncting to Grameen Phone EDGE/GPRS in ubuntu linux using Nokia 6300 USB modem'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>17</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-5415398355918080358</id><published>2007-06-08T23:02:00.000+06:00</published><updated>2007-08-12T12:48:31.015+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='dos'/><title type='text'>adding all jar files of a directory to classpath</title><content type='html'>how do you add all the jar files of your application's lib directory to classpath? probably as follows:&lt;pre&gt;&lt;code&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/activation.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/FTPProtocol.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/jai.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/jakarta-oro.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/jaas.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/log4j.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/mail.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/rmicb.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/Tidy.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/trove.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/xalan.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/xerces.jar&lt;br /&gt;set CLASSPATH=%CLASSPATH%;%LIB_DIR%/xml-apis.jar&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;but there is a easier way:&lt;pre&gt;&lt;code&gt;SETLOCAL ENABLEDELAYEDEXPANSION&lt;br /&gt;for %%f in (%LIB_DIR%\*.jar) do set CLASSPATH=!CLASSPATH!;%%f&lt;br /&gt;ENDLOCAL&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;note the &lt;code&gt;!&lt;/code&gt; sign around &lt;code&gt;CLASSPATH &lt;/code&gt;and don't miss &lt;code&gt;SETLOCAL/ENDLOCAL &lt;/code&gt;commands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-5415398355918080358?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/5415398355918080358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=5415398355918080358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/5415398355918080358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/5415398355918080358'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/06/adding-all-jar-files-of-directory-to.html' title='adding all jar files of a directory to classpath'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-6170980316115251833</id><published>2007-05-19T20:30:00.000+06:00</published><updated>2007-09-01T22:57:21.102+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>jgoodies validation (very easy!!!)</title><content type='html'>for last couple of days i was looking into jgoodies validation. but i found that it doesn't have enough quick start guide or simple sample code. the sample code provided with jgoodies are too complex. i have searched the net but i failed.&lt;br /&gt;then i asked hasan's help. he said, "give me the complex code, i will simplify it". then i think, why don't i do that. so here is my simple code.&lt;br /&gt;&lt;br /&gt;first assume you have a domain object as follow:&lt;pre&gt;&lt;code&gt;public interface User {&lt;br /&gt;  public String getUserName();&lt;br /&gt;  public void setUserName(final String pUserName);&lt;br /&gt;  public String getPassword();&lt;br /&gt;  public void setPassword(final String pPassword);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;and it's implementation &lt;code&gt;UserImpl&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;you also have a form with two text fields &lt;code&gt;mUserNameTextField&lt;/code&gt; and &lt;code&gt;mPasswordField&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;now first create a &lt;code&gt;Validator&lt;/code&gt; class&lt;pre&gt;&lt;code&gt;public class UserValidator extends AbstractValueModel&lt;br /&gt;    implements Validator, User {&lt;br /&gt;  private User mUser = new UserImpl();&lt;br /&gt;  public Object getValue() {&lt;br /&gt;    return this;&lt;br /&gt;  }&lt;br /&gt;  public void setValue(Object pObject) {&lt;br /&gt;    // never used&lt;br /&gt;  }&lt;br /&gt;  public User getUser() {&lt;br /&gt;    return mUser;&lt;br /&gt;  }&lt;br /&gt;  public void setUser(final User pUser) {&lt;br /&gt;    mUser = pUser;&lt;br /&gt;  }&lt;br /&gt;  public ValidationResult validate() {&lt;br /&gt;    ValidationResult result = new ValidationResult();&lt;br /&gt;    if (ValidationUtils.isEmpty(mUser.getUserName())) {&lt;br /&gt;      result.addError("User name is required");&lt;br /&gt;    }&lt;br /&gt;    if (ValidationUtils.isEmpty(mUser.getPassword())) {&lt;br /&gt;      result.addError("Password is required");&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;  }&lt;br /&gt;  public String getUserName() {&lt;br /&gt;    return mUser.getUserName();&lt;br /&gt;  }&lt;br /&gt;  public void setUserName(final String pUserName) {&lt;br /&gt;    mUser.setUserName(pUserName);&lt;br /&gt;  }&lt;br /&gt;  public String getPassword() {&lt;br /&gt;    return mUser.getPassword();&lt;br /&gt;  }&lt;br /&gt;  public void setPassword(final String pPassword) {&lt;br /&gt;    mUser.setPassword(pPassword);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;in the form class create there fields&lt;pre&gt;&lt;code&gt;private ValidationResultModel mValidationResultModel =&lt;br /&gt;    new DefaultValidationResultModel();&lt;br /&gt;private PresentationModel mPresentationModel =&lt;br /&gt;    new PresentationModel(new UserValidator());&lt;br /&gt;private JLabel mMessageLabel = ValidationResultViewFactory.&lt;br /&gt;    createReportIconAndTextLabel(mValidationResultModel);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;after initializing the form&lt;pre&gt;&lt;code&gt;Bindings.bind(userNameTextField,&lt;br /&gt;    mPresentationModel.getBufferedModel("userName"));&lt;br /&gt;Bindings.bind(passwordTextField,&lt;br /&gt;    mPresentationModel.getBufferedModel("password"));&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;here &lt;code&gt;"userName"&lt;/code&gt; and &lt;code&gt;"password"&lt;/code&gt; are the properties of your domain class.&lt;br /&gt;&lt;br /&gt;finally in the action handler for form submit&lt;pre&gt;&lt;code&gt;mPresentationModel.triggerCommit();&lt;br /&gt;UserValidator validator =&lt;br /&gt;    (UserValidator) mPresentationModel.getBean();&lt;br /&gt;ValidationResult result = validator.validate();&lt;br /&gt;mValidationResultModel.setResult(result);&lt;br /&gt;if (result.isEmpty()) {&lt;br /&gt;  // do your action handling here&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;isn't it very easy!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-6170980316115251833?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/6170980316115251833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=6170980316115251833' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/6170980316115251833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/6170980316115251833'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/06/jgoodies-validation-very-easy.html' title='jgoodies validation (very easy!!!)'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5567577962358842243.post-42855649823631118</id><published>2007-05-18T12:43:00.000+06:00</published><updated>2008-12-10T04:32:52.894+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='norway'/><category scheme='http://www.blogger.com/atom/ns#' term='travel'/><title type='text'>some photos from beitostølen, norway</title><content type='html'>in 23-25 march 2007 i went to beitostølen for a ski trip.&lt;br /&gt;here are some photos form there.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_pPHKBflyajY/RnVnkyj2r0I/AAAAAAAAAAs/itav8gOI4x8/s1600-h/cooking.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_pPHKBflyajY/RnVnkyj2r0I/AAAAAAAAAAs/itav8gOI4x8/s320/cooking.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5077078036675211074" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pPHKBflyajY/RnVnlCj2r1I/AAAAAAAAAA0/eV3g4ZTZw74/s1600-h/gossiping.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_pPHKBflyajY/RnVnlCj2r1I/AAAAAAAAAA0/eV3g4ZTZw74/s320/gossiping.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5077078040970178386" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_pPHKBflyajY/RnVnlCj2r2I/AAAAAAAAAA8/g8mD0kpVmjs/s1600-h/first_time_in_ski.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_pPHKBflyajY/RnVnlCj2r2I/AAAAAAAAAA8/g8mD0kpVmjs/s320/first_time_in_ski.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5077078040970178402" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pPHKBflyajY/RnVnlSj2r3I/AAAAAAAAABE/uSV2gCaARSY/s1600-h/skiing.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_pPHKBflyajY/RnVnlSj2r3I/AAAAAAAAABE/uSV2gCaARSY/s320/skiing.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5077078045265145714" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5567577962358842243-42855649823631118?l=shihabuddin.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://shihabuddin.blogspot.com/feeds/42855649823631118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5567577962358842243&amp;postID=42855649823631118' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/42855649823631118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5567577962358842243/posts/default/42855649823631118'/><link rel='alternate' type='text/html' href='http://shihabuddin.blogspot.com/2007/05/some-photos-from-beitostlen-norway.html' title='some photos from beitostølen, norway'/><author><name>Shihab</name><uri>http://www.blogger.com/profile/13981403515716629578</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://bp0.blogger.com/_pPHKBflyajY/Rvk6VwCepVI/AAAAAAAAAC4/AOigO8byngE/s320/s4020973-1.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_pPHKBflyajY/RnVnkyj2r0I/AAAAAAAAAAs/itav8gOI4x8/s72-c/cooking.jpg' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
