Sunday, December 18, 2011

DataTable doesn't support CheckState values

DataTable (related to DataSet) doesn't parse CheckState values when a column of CheckState data type is added using the Visual Studio designer.

Friday, December 16, 2011

Handling CellClick event suppresses CellDoubleClick event.

Sri Guru Gauranga Jayate

In DataGridView, if one handles the CellClick event, CellDoubleClick event doesn't fire.

Om namo shridharaya.
Sri Guru Gauranga Jayate

DataGridView CellFormatting event is funny. As per the MSDN, the ConvertEventArgs argument has a property 'Value' that holds the unformatted value and must be set to the formatted (converted) value inside the event handler. But for DataGridViewCheckBoxColumn, this property had a fixed (constant) value irrespective of the underlying value of the DataGridView cell.

Om namo shridharaya

Wednesday, December 14, 2011

tableAdapter.Update method is 2-way

Sri Guru Gauranga Jayate

tableAdapter.Update method implies not just saving the dataset to the database but also retrieval of any autoincrement (identity) key values to the dataset after saving it to the database. In other words there's no need to call tableAdapter.Fill method to get the identity key values.

Om namo sridharaya.

Thursday, October 6, 2011

Mounting an ISO file in linux

mount -o loop disk1.iso /mnt/disk

Jaya Srila Prabhupada, Sathguru Bhagawan Sridhara Swamy Maharaja

Monday, May 16, 2011

What I learned yesterday...

Yesterday was Sri Narasimhadev's appearance day. A lot of obstacles got cleared!!

1. gimp - multiple layer editing. When a layer is pasted, it's in floating state; right click and say new layer.

2. Java - new BufferedReader(new FileReader("hari.txt")) - efficient read operation

3. when interviewing, check for behavioral aspects first. Behavioral aspects include things like team work, hunger to learn and resourcefulness. (we need people who can stay with us and not just run after money.)

4. jQuery - a good JavaScript library - decreases coding for all kinds of JavaScript tasks.

5. jQuery UI - another JavaScript library built on top of jQuery. Good for animations and interactive GUI

Saturday, April 16, 2011

Display UUID of disks in Debian

Jaya Srila Prabhupada.

The command is: blkid

Jaya Sri Sathguru Bhagawan Sridhara Swamy Maharaja

Wednesday, April 13, 2011

What I learned the last week

Jaya Srila Prabhupada (most merciful savior)

TCP/IP programming in Windows.

Started with my own classes ServerSocketFactory and ClientSocketFactory which encapsulated the TCP/IP api of .NET. One more class NetworkSocket encapsulated the Socket api of .NET

Learned by mistakes.

First mistake was that I bound the listening socket to the localhost (SockAddress.Local) instead of binding to SocketAddress.Any

I learnt that one can chain readers like this:
new StreamReader(new NetworkStream(new Socket(adr_family, sock_type, proto_type)));

Now writing or reading from a reader object writes to the underlying stream!

The client used to ask for something by sending a string of characters with a newline trailing and I was trying to receive it without expecting a newline. Sometimes it was the other way round. Both should settle on one scheme. When we call the 'ReadLine' method on a StreamReader, it doesn't return until it sees a newline. The ReadLine method always returns a string that was read from the stream (here socket).

What happens when you are trying to read from a connected socket but the remote socket is closed, the Receive method (analogous to 'recv' in unix socket programming) returns immediately with zero bytes. Analogously if we are using the 'ReadLine' method on a StreamReader of a socket, the ReadLine method returns immediately with a null value (and NOT a null string).

Jaya Sathguru Bhagawan Sri Sridhara Swamy maharaja.

Monday, March 28, 2011

Using 'du' command to leave out other filesystems

Jaya Srila Prabhupada.

du -hsx /home

this command leaves out other filesystems that may have been mounted in the filesystem heirarchy starting at /home.

Jaya Sathguru Bhagwan Sridhara Swamy Maharaja.

Backing up home folder

Jaya Srila Prabhupada

cp -vrx /home /home/ghd/mnt-backup

Because we use the -x option, this command doesn't copy contents from other filesystems that may have been mounted in the filesystem heirarchy starting from /home.

Jaya Sathguru Bhagwan Sridhara Swamy Maharaja.

Thursday, March 17, 2011

Conditional Expression in C

Jaya Srila Prabhupada



A conditional expression is of the form:
expression ? expression_true : expression_false

Yes, the conditional expression involves the ternary operator!

Jaya Sri Sathguru Sridhara Swamy Maharaj.

Wednesday, March 16, 2011

Sorting the output from 'ls' command when filenames have numbers

Jai Srila Prabhupada.

Many times filenames contain numbers of arbitrary length - file1, file2, ..., file9, file10, file11, ..., file19, file20, file21, ... so on. When we run the 'ls' command, the output is sorted based on dictionary order and not in the way shown above.

Use the following command:
ls | sort -V

Note that we are calling 'ls' without any arguments, otherwise it won't work.

Jaya Sathguru Bhagawan Sri Sridhara Swamy Maharaja.

Friday, March 4, 2011

Why some Linux distros install to extended partitions



Jaya Srila Prabhupada

Some Linux distros including openSUSE create an extended partition on the hard disk before installing the OS on to it. Also the partition numbering starts from 5 and not from the next available number. For example, if I have one partition on the hard disk namely sda1 and I am installing openSUSE on it, the latter creates an extended partition sda2 and logical partitions starting from sda5 (sda5, sda6, and so on). One may wonder why the logical partitions didn't start from sda3.

The reason is extra convenience that one gets when one needs to add a partition. For example, if another (primary) partition is added to the disk described above, the new partition will be numbered as sda2 and the extended partition that was previously numbered as sda2 becomes sda3. However, and this is the important point, none of the logical partitions need to be renumbered; they still start from sda5. Thus no changes need to be made to the boot loader (e.g. GRUB) and fstab entries in the installation.

Jaya Sathguru Bhagawan Sridhara swami maharaj.

Saturday, February 26, 2011

Live USB



Jaya Srila Prabhupada

Making a live USB stick is simple. Make sure that the USB stick is not mounted before trying this.

dd_rescue /path/to/image.iso /dev/sdX

where /dev/sdX is the actual device. It can be known in openSUSE by running the following command:

ls -l /dev/disk/by-id/*usb*

PS: Unfortunately this method is specific for openSUSE and may not work when creating a USB installer for other distros. Each distro has its own way of creating a USB installer.

Jaya Sathguru Bhagwan Sridhara swamy maharaj.

Saturday, February 19, 2011

Irrational Numbers - another display of Krishna's genius



Jai Srila Prabhupada

Recently something had spurred in me a lot of interest for Math. I came across the concept of irrational numbers. You can create an irrational number in a number of ways. One of which I know is by taking the square-root of a number. There is also a ready to use irrational number - the pi.

Thinking of the pi made me appreciate the creative genius of Lord Krishna. The definition of the pi is: The number that you get when you divide the circumference of a circle by its radius. Fascinating isn't it? Just think of it. Draw a circle. Find its circumference. Then divide it by the circle's radius. And lo; you get a number that's having infinite digits with no repetition. That means you just can't express the pi using pen and paper like you do for other (rational) numbers. What special property that the circumference of a circle has that gives this special number - the pi - the irrational nature? We can only appreciate the genius of Krishna whenever we look at the pi.

Jaya Sathguru Bhagwan Sridhara swamy maharaja.

Saturday, February 12, 2011

Shortcut Keys in Evince



Jai Srila Prabhupada

I found two undocumented shortcut keys in Evince. To expand a node in the page index pane (on the left of the reading pane), highlight the node and press space bar. To collapse the node, press the '/' key in the number pad section of the keyboard.

Jai Sathguru Bhagwan Sridhara Swamy Maharaja.

Saturday, February 5, 2011

finding disk usage using 'grep' and 'du'



Jai Srila Prabhupada.

Today I was trying to find how much disk storage space was being used by files on my system. I used the following command to find disk storage space used:
du -hc / > usage_details.txt
Now I needed to analyze the information captured in the text file that got created in the above step. During my analysis, I did find that knowing the disk usage for a particular folder was easy, as the 'du' tool captures the disk usage folder-wise when used with the -c option as shown above. But, now I wanted to find the disk usage only for the top level folders i.e. /home, /tmp, /var, /usr etc. I resorted to using the 'grep' command in the following way:
grep -v "\/.*\/.*" usage_details.txt
The text within quotes is a back-slash, forward-slash, period, asterix and again the same set of characters. Here 'grep' is called with the -v option which means negation of the match condition - if the text read by 'grep' doesn't match the pattern, then print it to the standard output. That was a pretty nifty feature, eh!

Jai Sathguru Bhagavan Sridhara swamy maharaj.