xargs saved my day

So I was doing my regular job, writing new queries to test out my team’s new databases on Vertica. And suddenly my senior manager sends out an email to all in the team asking an estimated disk space requirement for each of our work. I had to find out how much space the raw data files for a complete history that were used to load my databases occupy on disk. ...

February 6, 2013 · 6 min · 1112 words

Emacs - Copy Line

To get the equivalent of kill line command in emacs for copying purposes, I use the following code snippet. Just copy paste it in your .emacs file. (defun copy-line (arg) "Copy lines (as many as prefix argument) in the kill ring" (interactive "p") (kill-ring-save (line-beginning-position) (line-beginning-position (+ 1 arg))) (message "%d line%s copied" arg (if (= 1 arg) "" "s"))) (global-set-key "\\M-k" 'copy-line) If \C is your control key then \M is your alt key. So generally by default your kill line can be done by \C-k Now you can also copy a line by doing: \M-k I don’t remember where I got this bit of code from, I lost those tabs when Firefox crashed. ...

October 2, 2012 · 1 min · 130 words

Surrogate keys v/s natural keys

I am currently working on a database design problem. I work in the financial domain and I deal with data related to benchmarks and securities. The problem with such databases are that each security has multiple identifiers in the real world. They could be Uniquely identified by a SEDOL, CUSIP or ISIN or the many other type of identification standards available. This lead me to the question of designing the tables using a surrogate keys but I was still not sure how my team would react as they had already design loads based on real world identifiers and named it security_id. Unfortunately security_id could be a SEDOL, a CUSIP or ISIN or whatever depending on what region or benchmark the security belongs to. That isn’t really a reliable identifier. And hence to avoid annoying the guy in my team who does data loading I redesigned my queries to do some intelligent identifier resolutions. This cost us a lot. Queries that would perform in barely 500ms now take about 1500ms. ...

July 18, 2012 · 3 min · 472 words

Static in C++

Hey, its been a really long time. I couldn’t get my adsense account approved. It seems I need more content. If only I spend enough time blogging. Everyone gets busy once in a while. And everyone forgets that they have a blog. Especially ones like mine, where people rarely visit. Anyways, that’s relevant to what I wanted to make note of here. I was working on a minor change in my company’s C++ code base. Its a simple one for anyone who knows C++. But I don’t do much C++. The last time I remember writing real C++ code was during my university days. I mean my bachelors degree. During my masters I worked solely on Java based stuff for my projects and for a coursework, I just opted to do something in ASP .NET, just to get a feel of it. Coming straight back to the point. Static is an overused keyword. Literally it would mean something that doesn’t change. But in C++, this keyword has special meanings, depending on the context it is used. Static can be used for three purposes. One use is to have a variable defined that has a lifetime of the whole program. That is once you declare it static and initialize it, then that variable’s value can be accessed from anywhere in that program. That variable’s allocation is cleared up only when the program closes or quits. And it helps prevent re-initialization. If I were to write something like this: ...

July 18, 2012 · 4 min · 736 words