Posts

Showing posts with the label TipsAndTricks

TIL: Sort human friendly values

Sorting numeric values in the input is easy. It just takes "sort -n". But what if the input contains human friendly units. For intance, "5G", "3M", "4K", etc. There is a flag to recognize and sort based on the human friendly units: "-h". Incorrect: du -h | sort -nr Correct: du -h | sort -rh Caveat: "sort -h" works only on upper-case units. "K" will be treated as kilos, but "k" will not be!

Adding META tag to your blogger page layout

When I wanted to submit my blog for Google AdSense, I had to first confirm the ownership to my blog. It can be proved in two ways: either by adding a META tag in the HEAD section or by adding a HTML file in the site. Since I have my blog in the blogger.com, the easiest way for me to confirm my ownership is to add a META tag in my blog layout. It is very easy to add this tag. Follow these steps. Login to your blogger account Click on Layout and then Edit HTML Search for the following phrase: all-head-content . This is the line that tells the blogger engine as to what needs to be included in the HEAD tag. Just before this line, not just before all-head-content, but before the line , include your meta tag. Most likely you will be including a META tag that looks like: meta name = 'verify-v1' content= "Some base64 encoded string" / > Save your changes and view your blog and confirm that your new META tag appears on the header. Remember that though you specify name and...

Saving a file being viewed in less

Sometimes I have a long sequence of command line pipes that end in less command. For e.g. cvs log main.c | egrep "^revision " | less So what is the best way to save the contents that are being viewed in less? You cannot view those contents by typing the letter "v". If you do so you will get an error message saying "Cannot edit standard input (press RETURN)". The solution is simple. First type "g" to go to the beginning of the file. Then type "|". Then you will be prompted for the "mark:" and enter "$" (which denotes the end of file). Then you can enter a command for which the entire contents of less will be piped. For e.g. I will give the following: cat > /tmp/savefile.txt Thats it! You have saved the contents to the file /tmp/savefile.txt. Now you have a problem. Since you have moved to the beginning of the contents, you might want to go back to the same place where you were before saving the contents. Just typ...

Absolutely cool dbx commands

Have you ever used dbx to debug a program? Its really cool. I have been using dbx for more than 6 years now. I am hoping that I will write a full fledged tutorial on using dbx (before it is dead and deep buried :-) Here are a few things which I felt absolutely essential to any programmer using dbx. edit and fix examine assign set follow_fork_mode and set follow_fork_inherit commands Most of the time I find that people who are new to dbx exiting the dbx session just to make a small fix. Well, you don't really have to exit, recompile and start a new dbx session. You can use a combination of edit and fix commands. If you simply give edit, dbx will open the current file in the editor set by EDITOR environmental variable(vi is default). If you wish to edit a specific file, you can give that file's name as an argument to the edit commend. You don't have to give the full path, as dbx is smart enough to find out the full path of the known files. (Give files command to find out wha...

Opening control panel from command prompt

How do you go to a tab in control panel directly from command prompt? Under the system32 directory, you will find a few *.cpl files. Running these files will take you directly to the control panel tab corresponding to them. For e.g. appwiz.cpl will take you to "Add/Remove Programs" tab in control panel. You can get a complete list of these files from this Microsoft Knowledge Base article . It saves a lot of time especially when you are running in a lesser privileged account and want to switch to admin account to install/uninstall programs.

Icon next the URL in IE and FireFox

Many a times I have wondered how some of the sites have an icon appearing before their URL in the address bar. But for some reason there is no icon appearing if I visit my personal page. I recently figured the answer for this while visiting this site . There was a side note appearing in that site, taking me to the Microsoft's article on how to make this icon appear. Hope you would find this useful and interesting. Apart from that, I find ZYTRAX site extremely useful in many ways. They have excellent tutorials on LDAP and DNS. There is a lot more to read about from that site.