Monday, July 20, 2009

Open source comes to rescue, yet again!

I had purchased a Linksys WRT54GS v5 wireless router from the US three years back for my home network that had 2 laptops and 2 desktops. I had hoped to connect all the computers nicely to share the DSL Internet connection as well as bring all the PCs on a local LAN using this single device. But this damn router used to get hung unpredictably and reboot itself quite often. Moreover, whenever the mains used to go off, which is quite often in Pune due to everyday load shedding, the router rebooted repeatedly and had to be cooled down for at least 5 mins. Hence, I could never trust it while doing Skype conference calls with customers or for important downloads. Since it had the latest firmware when I bought it and Linksys support forums didn't help with the problem, I had to live with it for quite a while. I became used to connecting directly to the DSL modem for important network conversations and using this device when I needed Internet access from the laptops. This went on for an year and half when I again checked for firmware upgrades. Linksys had one and I upgraded my router to the latest firmware. But no luck. I decided to throw away this device and get a new one. Somehow I never got around to buying a new one, probably because my laptop usage at home had gone down significantly.

Recently, I came across DD-WRT, an open-source firmware for a lot of wireless routers, that had received some excellent reviews. So, I decided to give it a try. This past Saturday morning, I flashed the router with DD-WRT using this excellent tutorial. I'm happy now that most of the problems with the router are resolved except one: the router freezes completely if I don't have any network traffic for sometime (for e.g. a lunch break). This problem is easily resolved by power-cycling the router. Hope this problem gets resolved in the next release of the firmware.

Update 30th July 2009: DD-WRT has an FAQ that already talks about steps to solve the freezing problem. After doing those changes to the config, my router has been stable as a rock for last week through all the Skype calls, download sessions and shared DSL accesses. I'm very happy!

Monday, July 13, 2009

Third Chimpanzee

Jared Diamond's The Rise and Fall of the Third Chimpanzee is a wonderful book, throws excellent light on many aspects of human life that most of us either don't understand or take for granted: who would guess that the ability to speak and formulate a language would make the humans the conquerors of all continents despite their obvious weaknesses against the nature and beasts?

The book covers a lot of interesting topics: evolution of homo sapiens, spread of humans outside Africa into Europe and far away lands, how and why languages and art came into existence, destructive abilities of humans causing extermination of not only other species and nature but of its own tribe. It has quite a few interesting tidbits on quirky habits of many animals, such as the art displayed by the bowerbird in building its nest to attract mates, and many extinct species of birds, mammals and other animals who would have been fantastic to look at today.

It finally makes a very poignant point about why we should all be worried about conservation and that we haven't lost it all if we decide to act now.

Wednesday, June 10, 2009

God Delusion

I just finished reading this book "God Delusion" by Richard Dawkins. Its an interesting book to say the least. But it also makes you think a lot, question your long held beliefs, feel unsettled and look at the world with a new mindset. Whether you believe in God or not, when you start thinking about the possibility of a God-less world, it takes you into many uncharted territories. You suddenly can't blame fate or rest assured that God will one day make things better. No life-after-death forces you to rethink your actions. While it does not make you any more evil, it makes you question your benign attitude to many rituals.

The book doesn't convert you to an atheist overnight, though there are people who claim to have become one after reading the book. But it surely gives you an insight into how religion affects other parts of the world. Worth reading.

Friday, December 05, 2008

Hiring an effective sales rep

What do you look for in a good sales rep? How do you discern a smart talking parrot from one who would actually bring in money? And how do you go about hiring one in Pune?

What does it take to sell software to Indian small and medium enterprises?

Me facing these questions these days.

Wednesday, October 31, 2007

Useful VIM commands and Linux Tips

These are a random "how to"s collected over a long period of time. Some I figured out, others I read/found/googled. Some may have become outdated now. Uploading it here so that its easily accessible:

----------------------------------
Autoindenting a file:
:0
=:$

Removing blank lines:
:g/^$/d

with tabs and spaces:
:g/^\s*$/d
-----------------------------

1. Finding and removing of files using find command:

find . -name -print -exec rm '{}' \;

2. Grep'ing through files
grep -r

3. How to search for a string in a selection of files (-exec grep ...)
find . -exec grep "www.athabasca" '{}' \; -print

4. Find and Replace an Expression

# This one liner will search all text files in the current
hierarchy looking for an expression:

# 1) find all files

# 2) xargs ensures standard input doesn't overflow. I use xargs
instead of -exec because -exec has been very unreliable across
different vendor Unix implementations.

# 3) file determines file types

# 4) grep traps for text files

# 5) cut the file name from output of the grep

# 6) egrep the text files for expression $*

find . -type f -print | xargs file | grep -i text | cut -f1 -d: |
xargs egrep "$*"



# The above one-liner can be easily modified to other kinds of
# operations to text files.

# Consider the need to replace all instances of Linux with GNU/Linux....
#
find . -type f -print | xargs file | grep -i text | cut -f1 -d: | while read
file; do

vi $file >/dev/null 2>&1 </dev/tape 2>bckup.out
# The -newer option only finds files newer than bckup.out... that is,
only files that have been modified since the last backup. This makes
the command useful for doing incremental backups.

# Assuming you are root, and you do this from the / directory, this
should backup up everything on /. The / is preceded with a "." to
make sure that we can restore the tape to any directory... not just /.

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

Disabling ctl-alt-del
- comment out the trap CTRL-ALT-DELETE section of /etc/inittab
- the entry looks like
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
- uncomment the ca line

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

Disabling ctrl-alt-backspace base X shutdown
- add DontZap to ServerFlags section of /etc/X11/XF86Config file

-----------------------------------------------------------------------
SMB mounting windows share

Only root can mount smb partitions.
For mounting g: drive (shared as user on WinNT) on girnar on
/mnt/girnar/g, use the following command:
mount -t smbfs -o username=persist,password=persistent //girnar/users /mnt/girnar/g

Mounting using Persistent domain account name
mount -t smbfs -o username=persistent\\penguin,password=penguin,uid=500,gid=100
//osd3nas/Users /mnt/nas/
-----------------------------------------------------------------------
Converting plain text files to html using vim

The following command would create an html file out of file_name
input. This conversion would also retain the syntax coloring.

gvim -f +"syn on" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q"


e.g.
gvim -f +"syn on" +"so /usr/share/vim/vim58/syntax/2html.vim" +"wq"
+"q" Glossary

would convert Glossary into Glossary.html
-----------------------------------------------------------------------
Adding a Role in Pine
http://www.ii.com/internet/messaging/pine/changing_from/#vars

-----------------------------------------------------------------------
Creating multi-volume tape archive

E.g. tar -cMf kishore.tar -L 1024 /opt/music/mp3/kishore/
would create a tar file kishore.tar from /opt/music/mp3/kishore till
it reaches a size of (approx. 1024*1024) and if the directory is still
not completely archived, it will prompt for next volume:
Prepare volume #2 for `kishore.tar' and hit return:

To this question you should supply the name of the next archive like:
n kishore1.tar

Now tar will respond with:
Prepare volume #2 for `kishore1.tar' and hit return:

To this you respond with y (for yes) and

It would go on to prompt you for volume#3 and so on.

-----------------------------------------------------------------------
If the TERM env variable is not =vt100 and is =xterm, then the
coloring used is very weird. Change the TERM to vt100 in
.bash_profile.

-----------------------------------------------------------------------
Using tcpdump

To capture all packets originating or destined to host "girnar",

tcpdump -N host girnar > /tmp/girnar.dump

The -N option omits the domain name (intranet.pspl.co.in) in the
dump. We are redirecting the output to /tmp/girnar.dump here.

-----------------------------------------------------------------------
Using Ctags in vi

Generate tag file on all the sources by using ctags * in the directory.
A file 'tags' would be created in the current directory. An easy way to do
this is execute ctags -R in the directory. It will recurse through the
entire directory and generate tags for all the files.

To use the tags from vi:
- to jump to the definition of the keyword, place the cursor over it and
press ctrl-] (escape key for telnet)
- to jump back to the reference, press ctrl-t

If using telnet, then the escape key can be suppressed by using
telnet -E

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

To restore MBR from Windows

From command prompt, run
fdisk /mbr

Running /sbin/lilo should re-install LILO on MBR again after doing the
above step

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

For viewing RTF documents, use Ted. Its in /usr/local/bin/
Note the capital T in Ted. 'ted' won't work.

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

For enabling access control on any directory served by Apache:
- Create a .htaccess file in that directory with following contents
AuthType Basic
AuthName "By Invitation Only"
AuthUserFile /usr/local/apache2/conf/passwords
Require user persist

where 'persist' user is allowed to access this directory only if he
supplies proper password. The encrypted password is stored in the
'AuthUserFile'. The username/passwords can be created by using
htpassword utility that comes with apache and is in bin/ directory
of Apache config home.
- The Webserver user (nobody) has to have read permissions on
.htaccess and the password file

There is another way to enable this, through httpd.conf file. But I
have not tried it out.

-----------------------------------------------------------------------
How to get .rhosts working?

- Create .rhosts file in $HOME
- Make sure it has 644 permissions (rw-r--r), OTHERWISE it give
permission denied error
- Make sure rsh is enabled through inetd (/etc/xinetd.d/rsh should
have disable=no)
- Restart xinted if required
- rsh hostname -l loginname command (DONT'T forget the command)

-----------------------------------------------------------------------
To run apache as root
- set environment variable CFLAGS to -DBIG_SECURITY_HOLE
- compile apache and install it
- change USERS in httpd.conf to root (nobody is default)

-----------------------------------------------------------------------
SSH based port forwarding
ssh -L port:host:hostport
-----------------------------------------------------------------------
Adding a route for specific host
For e.g. to add a route to smtp machine through bhageerath gateway:
/sbin/route add smtp.intranet.pspl.co.in gw bhageerath

----------------------------------------------------------------------
Adding authentication to Twiki
- Follow the documentation
- Pay attention to "AllowOverride All" option for the
section of twiki/bin folder
- Modify .htaccess appropriately

----------------------------------------------------------------------
Compiling gaim on RH 7.3
- Upgrade Glib to 2.0, GTK to 2.4
- GTK upgrade requires Pango1.4 with Xft which requires Freetype2.1.4,
fontconfig-2.2.2 and Xft-2.1.2
- For Xft, your require xrender-0.8 which requires render-8.0 which
requires one file (extutil.h) to be copied to
/usr/X11/include/extensions (I got the file from
http://mail.gnome.org/archives/garnome-list/2003-May/msg00234.html
after googling)

----------------------------------------------------------------------
Renaming several files at the same time

The following line would rename all the *.C files to *.cc
\ls *.C* | sed 's/\(.*\).C\(.*\)/mv & \1.cc\2/' |sh
----------------------------------------------------------------------
Configuring Linux client to use DHCP

In the file ifcfg-eth0 under /etc/sysconfig/network-scripts, set the
value of BOOTPROTO to dhcp:
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
----------------------------------------------------------------------
Encrypting files in VIM
Use the :X option. It asks for the encryption key.

Friday, January 13, 2006

New technology news site: Digg

Digg is a relatively new media site for tech stuff. Its being pitched as a worthy competitor to Slashdot. I'm already liking it. Having an option to Slashdot would be great!

Monday, November 07, 2005

Text files in Windows and Unix

This is the best explanation that I saw on the topic that bothers almost everyone who has dealt with text files on Windows and Linux. Picked up from: Knoppix FAQ.
----------------------
Excursion: Files under windows and UNIX: Two worlds collide!

Are you so old that you remember and used the mechanical typewriter? Maybe you still have one on your attic somewhere...
With such a mechanical typewriter, when you are at the end of the line, you had to pull a lever. Two things happened then mechanically. In two to three rattles the paper was transported up one or more lines (the line feed or LF) and then you pulled the lever through from the far right to the left and returned the carriage with the paper (the carriage return or CR).

In your PC and on your hard disk the characters of a text line are stored in ASCI encoded characters in successive bytes. To indicate the end of the line it is necessary to mark this in some way or another.

The first computer "screens" were no more than electromechanical controlled typewriters or TELEX terminals, so they had something like the carriage return / linefeed mechanism of the old typewriters in them. These mechanisms were controlled by the ASCI characters CR and LF. The MS_DOS and later on Windows developers simply used these ASCI characters to indicate the end of text lines in their text files. For instance if you type in Notepad under Windows the string abc def, then internally in the file the ASCI characters "abcCRLFdef" are stored. And when Notepad reads this it displays:

abc
def

The editor interprets the CRLF characters as indication that it has to start on the beginning of a new line. That 's the way it should be.

The UNIX developers (at the university of Berkeley) decided that actually only one character would do, as they always come in pairs, and moreover the electronics of the computer screens can handle this command perfectly on their own. So in Unix/Linux only the LF character is used. When vi / gvim reads the ASCI string "abcLFdef" then this shows correctly as:

abc
def

The big fuzz starts when you directly want to edit Linux text files under Windows or vice versa. When Notepad under Windows read the ASCI string: "abcLFdefLFghi" then it shows as:

abc
def
ghi

It still only does the linefeed and not the carriage return, so the next line does not start at the beginning of the line.

When vi / gvim reads a Windows file with the string: "abcCRLFdefCRLFghi" then it shows this as:

abc^M
def^M
ghi

It replaces the (invisible) ASCI control character CR by a pair of visible ASCI characters (^M) and starts due to the LF at the beginning of a new line.
So that's why you need this cumbersome translation between windows text files and unix text files, swapping CRLFs by LFs and vice versa.