I think, therefore I am

The guy was trying to figure out if he could prove that he existed, cause it was trendy then to try to prove what all existed and whether or not anything actually existed at all. They had a lot of time on their hands.

He decided that the proof of his own existence was in the observation that he thought – had a mind that could think. So he decided that because he could think, he must exist.

I think, therefore I exist, equivalent to say, I think, therefore I am.

On a side note, this very guy once walked into a bar and ordered a drink. Bartender brought him a drink. After a while the barkeep noticed his glass was near empty. And the bartender asked for another drink?

I think not, said Rene.

And Rene disappeared!

The guy was Rene Descartes.

http://en.m.wikipedia.org/wiki/Cogito_ergo_sum

Heating Problem with My Thinkpad

Lately, my laptop was heating up a lot. Even with an idle machine it was getting very hot quickly. For once, I thought that it a hardware issue. But doing a little investigation, I found an application in the task manager consuming 100% CPU. This was some buggy application that came with my hTC phone.

Infinite looping in one or other form are mostly the type of bugs that cause 100% consumption of CPU. I once faced such a bug with Qt while calling the function paint() in the paint-handler. Causing infinite recursive function calls. Paint calling the paint-handler and paint-handler calling paint again.

Virtual Address Space Randomization

Randomizing the Virtual Address Space of a process means randomly arranging the address positions of stack, data, executable text, heap libraries etc in an address space. It makes sure that system is secure with respect to various types of attacks based on the knowledge of address locations of key data structures of a virtual address space of a process.

All in all, it is a security measure to make attackers life difficult.

One may need to disable it in some scenarios  For example for using the benchmark tool Filebench, one has to disable it for getting stable results.

sudo su
echo 0 > /proc/sys/kernel/randomize_va_space

Dot Language and Graphviz

Many times, need arises to draw graphs (the graphs from Graph Theory). One can draw these in any paint or drawing software. But what about complex graphs and graphs that are being generated on runtime i.e. dynamically? How does one represent and visualize them?

Dot language and Graphviz is one option to do so. Dot language for representation and Graphviz for visualization.

Dot Language

It is a language for defining directed and undirected graphs. It is human readable, plain text language that describes graphs.

Graphs are nothing but a set of nodes and a set of edges connecting the nodes. Dot language lets you tell the same. For example following dot file represents a complete graph of  four nodes.


graph complete_4 {

// nodes with labels
node1 [label=foo];
node2 [label=bar];
node3 [label=baz];
node4 [label=qux];

// edges
node1 -- node2;
node1 -- node3;
node1 -- node4;
node2 -- node3;
node2 -- node4;
node3 -- node4;
}

The definition could not have been any simpler. One first define the graph name then nodes and then edges connecting nodes.

Look at the manual for various options like size, shapes, type of edges etc.

Graphviz

Graphviz is a collection of libraries and softwares for handling and manipulating dot files. Following command creates a PNG file from a dot file that is defined above. Following this is a final graph visualization generated.

dot graph.dot -Tpng -ograph.png

NFS: Successful Mount but Permission Denied on Access

Lately, I faced an issue with NFS server. I exported something on the server and mounted the same on a client. Mount was successful but accessing the mount threw “Permission Denied” error. I was unable to list or change directory to the mounted directory.

It happens because of the issues with User ID mappings between client and server. A particular user of the client may not have permissions for the exported directory on the server.

There are multiple ways to get around this. One can use no_root_squash and then use the root user to access the mount. Or one may set permissions of the directory on the server to 777. I would would advise to read about UID mappings in the NFS man page and make decision knowingly.

Following is the description of User ID Mappings given in man page of NFS exports.

User ID Mapping

nfsd bases its access control to files on the server machine on the uid and gid provided in each NFS RPC request. The normal behavior a user would expect is that she can access her files on the server just as she would on a normal file system. This requires that the same uids and gids are used on the client and the server machine. This is not always true, nor is it always desirable.
Very often, it is not desirable that the root user on a client machine is also treated as root when accessing files on the NFS server. To this end, uid 0 is normally mapped to a different id: the so-called anonymous or nobody uid. This mode of operation (called ‘root squashing’) is the default, and can be turned off with no_root_squash.

By default, exportfs chooses a uid and gid of 65534 for squashed access. These values can also be overridden by the anonuid and anongid options. Finally, you can map all user requests to the anonymous uid by specifying the all_squash option.

Here’s the complete list of mapping options:

root_squash

Map requests from uid/gid 0 to the anonymous uid/gid. Note that this does not apply to any other uids or gids that might be equally sensitive, such as user bin or group staff.

no_root_squash
Turn off root squashing. This option is mainly useful for diskless clients.

all_squash
Map all uids and gids to the anonymous user. Useful for NFS-exported public FTP directories, news spool directories, etc. The opposite option is no_all_squash, which is the default setting.

anonuid and anongid
These options explicitly set the uid and gid of the anonymous account. This option is primarily useful for PC/NFS clients, where you might want all requests appear to be from one user. As an example, consider the export entry for /home/joe in the example section below, which maps all requests to uid 150 (which is supposedly that of user joe).

Odd Keypad of Lenovo Thinkpad Edge

A couple of months back, I purchased a laptop for personal use. I found Lenovo Thinkpad Edge E430 satisfying my requirements. It has been doing good. I would suggest for other too.

The only annoying thing I could find in it is it’s keypad. Two things specifically:

  • Placement of Ctrl and Function key: The Ctrl and Fn keys are swapped in the keypad different from the normal laptop keypads.
  • F1, F2, F3,…F12 keys: These keys have been made to use with the Function key pressed. And special keys like Volume, brightness etc can be used with out the Fn key. Usually, it is opposite.

Well the good thing is that one can change this behavior. One can swap Ctrl and Function keys and also make F1, F2 etc keys by default. Reboot your laptop and go to boot menu and check the desired options from there.

Automating Proxy Settings Changes

I have to switch my proxy settings daily, depending upon being at work or home. I created two batch files to enable/disable the same.

Note that this applies to the global aka Internet Explorer proxy settings.

ProxyEnable.bat

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /d "http://www.server.name/proxy" /t REG_SZ /f

ProxyDisable.bat

REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /f

Save Paper: Booklet Printing

Saving paper is important, very important! More paper you save, less trees will be cut. Trees are good for environment. Therefore saving paper will indirectly impact environment.

I have been using the feature of Booklet printing of Adobe Reader for a long time. It lets you print multiple page document as a nice handy booklet. It prints 4 pages per sheet, 2 pages per side and printing both sides. You need to fold the pages and it results in a booklet of half the size of original sheet in tray. A4 sheets will give you A5 size booklet.

Consider the savings, for printing 4 pages you require 1 sheet. And do the math for 100 page document, you require only 25 sheets! Moreover, I find the resulting booklet easy to handle and read.

You can find the option of booklet printing in Page Scaling option of Print dialog.

This feature is helpful only if you have the number of pages more than two. For one page use simple print, for two pages you can use the print-on-both-side and for three and more one should use this feature.