Posts

Showing posts from November, 2019

A day in Cambridge

Image
I am here in the UK on business. Arrived the morning of 17th. So are three colleagues of mine - the DBA, the Punjabi and the Naxal. On insistence of the Punjabi, yesterday, on the 24th of November 2019, we visited Cambridge - the university town. The Naxal had personal business and couldn't join. It was quite a visit and I learnt a lot about that place. It was fun - though most of the time towards the evening it was me insisting to return - much to the annoyance of the other two. The initial plan was for me to join the Punjabi at Finsbury Park and then hop on the train coming from Brighton. The DBA would get on the train at Hatfield and join us at Stevenage. It didn't work as planned because I was late. Chapter 1 - The Journey to Cambridge To get to Finsbury Park from 3 St Peters Mews, St Albans where I'm staying, one needs to walk down to the St. Albans City Station and get to King's Cross first. Then a Thameslink or tube will bring you to Finsbury Park St...

Balancing an AVL tree

Background - I got through college without having to learn this - I then thought AVL trees were an abomination. ok. AVL trees. What - AVL Trees are self balancing binary search trees Binary Search Tree ? - A search tree in which for any given node, nodes to its left are smaller than it and those on the right are larger. This makes it easy to search. The problem - What if a BST is skewed one side ? Let's say elements are inserted in the following order 2, 3, 4, 5, 6, 7. The tree one would get is:   2    \    3     \      4       \        5         \          6           \            7 In such a tree, it would take 6 steps to find 7 - which is O(n) worst time. Only if we were to get a tree that would resemble:     5    /\   3  6  / \  \ 2...

How to screw up while shell scripting

---written maybe 2 years ago and never posted --- posting it now --- Okay, in my past 3 months or so of doing shell scripting, I've screwed up more than in my whole career of 2.5 years. So I know quite a few things about screwing up. 1. Use rm -rf It's beautiful. It's fast. You can become terminator in a single Enter key. But of course even Terminators feel guilty after a while and hunt for undo rm -rf in Stack Overflow. 2. Use global environment variables Wow. It's so cool that you can export just about anything and use it wherever you want. Of course, anybody around can modify your variable. Why only you have all the fun ? 3. Quotes in variables ? Never bother Just sing along: MESSAGE=I have a dream..a song to sing.. Why bother doing: MESSAGE="I have a dream..a song to sing.." Quotes take effort to type 4. And then do something like rm -rf $myfilename*.processed So lovely that if $myfilename is undefined, it'll clean up everything ...