Posts

Showing posts from 2017

Today I Learned (TIL)

Today I Learned (TIL) is a series of posts that contain bit sized information that I learned and found to be worthy of sharing with others and keep as a note to myself. For the last couple of years, I had been devoting most of my time in building the start-up, Zycada Networks , that I co-founded. It makes me happy to share my knowledge. So I would like to get back to the habit of writing blog posts regularly on interesting stories, tips-and-tricks, new ideas, technology trends, etc. TIL is one part of doing it.

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!

Aligning text in emacs

Aligning text like a table is often a useful task. I use this workflow to make the text tidier. For instance when I have two columns of text of varying width, aligning them makes it easier to read. Steps: 1) Select the region you would like to align (C-x h will select the entire buffer) 2) C-u M-x align Thats it. The selected region would have been aligned based on the first line of the region. Example: Before: what? who? hello      world After: what? who? hello world By default only the space is used as a delimiter. If you would like to perform a little sophisticated alignment, you can make use of the align-regex function. city, population new york, 8.49M san francisco, 0.85M