Checks and Balances

December 19, 2016

I don’t get it. The judiciary in India gets to pass arbitrary laws that intuitively seems like it should be a part of the legislature (and arguably illegal, but hey, they get to decide what’s legal).

And the legislature continues to make seemingly unconstitutional rules with demonitization, and the judiciary isn’t stepping up to stop it or slow it down?

What happened to good old fashioned checks and balances?


Values

November 27, 2016

People: fight for core values of freedom, not for superfluous virtuosity, even if the costs are high.

If a government tries to add censorship to the internet saying that it’s for preventing “extreme” pornography, fight it. Otherwise they’re soon going to have a database of every website you visit.

If a government demonitizes a large amount of money claiming to remove black money and corruption, and in the process removes your presumption of innocence and treats everyone a criminal until proven innocent, fight it. No amount of money is worth giving the government more power to treat you as a criminal at their whim.

If someone says an election can be rigged and asks for checks and balances, SUPPORT IT. You should’ve supported it back then (I did), and you should support it now. Checks and balance are necessary for a democracy, whether or not it’s your favorite candidate at stake.


All these dead links

November 16, 2016

All these dead links in my “blogroll”. I almost don’t want to remove it for nostalgia’s sake. In memory of a past time, where the “blogosphere” was relevant.

Perhaps it still is, but the dead links don’t seem to suggest that.

I’ve picked “The Old Reader” as my new feed reader for now.

(Oh, and it doesn’t look like WordPress has changed in half a decade either. It’s a bloated piece of junk, but it brings back memories and I think I’ll stick with it.)

(Oh, and I still love my blog’s tagline. Probably the only time in my life that I’ve ever been clever.)


Hello.

November 16, 2016

I need a place to disagree.


Simplicity is Profound

August 1, 2011

[Warning: tech stuff.]

So I’ve been thinking over a very simple technique for a couple of weeks now, that is so brilliant in its simplicity that I wonder why I haven’t come across this before, and why nobody ever suggested something like this in my programming career.

I feel like going into a rant of them imperative programming, and then into the beauty of functional programming, unit testing, lisp and some other things made in heaven, but then, I am aware that good programmers already know, and the others don’t care, so there would be no point in all that.

But for its simplicity this is beautiful code:

The problem: when you’re into the whole functional programming ideology, you tend to have multiple nestings of function calls. func1(func2(func3))). And then one fine day, comes along a bug, and you’ve got to find the value that func2 returns.

What do you do?

A normal Java or C++ programmer (who, I can still imagine nesting functions three levels deep), will just pull out that func2 and store it in a variable, and print it and then pass it to that func1.

Maybe I’m wrong, but in my reasonably short life of programming, I’ve never seen anyone do it better. I wish to be less arrogant, but I’m hurt and and upset that none of you good programmers decided to teach me the better way.

If this were elisp, define a function like:

(defun deb (obj)
   (message "%s" obj)
   obj))

Did you see what I did there? Maybe some ruby code (which already has exactly this function — but less advertised — and you should use it):

def p(obj)
  puts obj.to_s
  obj
end

And then some Java:

<T>T p(T t) {
  System.out.println(t.toString())
  return t
}

What this provides you now, is that you can debug anything anywhere, with minimum surgery. func1(p(func2(func3()))). It’s brilliant once you get used to it. You’ll find that it’s not just for things like func1(func2(..)), you can use it with just about any kind of weird syntax that your language defines for you.

So. Didn’t you know this, or am I just too young and have a lot of learning to do?


Don’t be evil

February 23, 2011

I just read this article on TechCrunch: http://techcrunch.com/2011/02/19/this-is-business-not-personal/

It depresses me.

For full disclosure, I just finished reading Into the Wild, and like when I watched the movie years ago, I’m still intoxicated by its indirect sermons of freedom and all that.

The corporate life depresses me sometimes. Google pulled it off for about 15 years, they kept their values strong. When they said Don’t be Evil, it wasn’t marketing propaganda, they really meant it. And it did them real good. And everybody loved them. You don’t have to pinpoint why you love them, there’s just this respect. This trust. Whether you’re on the inside or the outside. You start believing in the cloud.

Despite the fact that you loved your freedom as a geek from the first wrote that first printf statement. Despite the fact that you enjoyed the rare email from the rare grateful user of your open source code. (Users are ungrateful, but that doesn’t matter.) Money is evil. Job security even more so. Sometimes I think it’s easier to give it all up and live life on the road. Geek style. You know, in the hope that someday some biographer writes your biography, Into the code or something like that. Starved while optimizing an n^2 loop, they would write, for the good of mankind.

I could go on and on.

The cloud is like the life McCandless in the book despised. How does a programmer go back to his roots? Live off the real code on a real machine, on a real operating system.

How can business and real geeks live harmoniously? Google almost pulled it off. Almost. At least for fifteen years. By the way, I no longer work at Google, but all disclaimers about not representing my employer or anything like that still apply. Corporate requirements, I wouldn’t have needed that if I were writing code that I pushed to Github.

I do see a lot of incoherent blabber up there. But I’m working for a startup now. I don’t have time to edit stuff. Take what you want from it. Just to be entirely clear, since I’m talking of multiple things there, I’m criticizing: the cloud, corporates, programming for money, and life in general.


Elisp, CapsLock, X11, and total awesomeness.

July 21, 2010

I like Emacs is that I can customize it to the way I want it. I can figure out inefficiencies in my daily workflows and processes and solve it using e-lisp. The inefficiency I tried to solve today, turned out to be interesting becase a) it was a very simple requirement that b) was a very non-general requirement and therefore difficult to find online, and c) turned out to have a fairly simple solution. Some of the ideas here can be useful in themselves.

First things first, my emacs setup is as follows: I use GNU screen, with a text-based emacs, I use emacsclient for speeding up things. I use rxvt-unicode as my X11 terminal emulator. When at work, I use the above. When at home, I do SSH to my work system, and run “screen -dR” and get back my entire system as it is. (Although it doesn’t matter for this post, but I’m sure some of you are curious: I use “C-z” as my Screen escape character.)

Now, the problem I’m trying to solve: I tend to use Caps Lock every now and then for SHOUTING_OUT_LOUD, and I sometimes forget to turn it off, and therefore I waste time backspacing every now and then. I need to solve this.

(Another digression for the hardcore Emacs fans out there: yes, I haven’t swapped CapsLock and Ctrl, and I don’t ever intend to. I use a ThinkPad keyboard on my desktop, and a ThinkPad keyboard on my — well, ThinkPad, which has a Ctrl key slightly to the right, which makes it very accessible. Really, I think swapping CapsLock and Ctrl is stupid.)

How would I solve this? I think the following works: I would like to change the color of my cursor when my CapsLock is turned on.

The cursor color

First let’s figure out how to change the cursor color. If I were using X11, I would’ve called set-cursor-color and everything would look great. However, Emacs does not support changing the cursor color on a text terminal, and this is my first roadblock.

The reason it doesn’t support — as far as I understand — is that changing the terminal cursor color is a non-standard terminal capability. However rxvt-unicode and xterm do have this non-standard support. Try this from a urxvt:
echo -ne '\033]12;red\007'

You’d think we’re almost done, but this doesn’t yet solve my problem. Unfortunately GNU screen doesn’t support this escape sequence. But we can work around that: GNU screen has a [again, non-standard] escape sequence to send an escape sequence to the host terminal. So now, we have an escape sequence to change the cursor color from within GNU screen:
echo -ne '\033P\033]12;red\007\033\\'

It’s entirely possible that we can get GNU Screen to support the previous escape sequence directly by correctly playing with some termcaps and stuff like that, but I don’t have enough knowledge about those to do that, so let me just solve my own problem.

Finally, let’s write an e-lisp function to change the color of the cursor:


(defun noronha-set-cursor-color (color)
 (send-string-to-terminal (concat "33P33]12;" color "0733\\")))

And now all we need to do is test if the CapsLock is on and off and … uh oh.

CapsLock

It turns out, that there’s no way of figuring out whether the CapsLock is on or off, from within a terminal. This is because the terminal does not send any information when the CapsLock key is pressed. What now?

But then Xorg does have information about the CapsLock key. For instance, on Debian/Ubuntu install x11-xkb-utils, and run “xkbvleds”. So it seems possible that running Emacs in X might provide some functionality for reading the CapsLock state. But that still wouldn’t solve my inefficiencies.

So here’s my solution: if we can keep an xkbvled kind of daemon running separately with the X display information, we can read off the CapsLock state from that. Here’s how to do that:

First: “apt-get source x11-xkb-utils” and patch the file xkbutils/xkbvleds.c. What we’d like to do is, uncomment the code that displays the window, and add a small printf that displays the state of the CapsLock key in the event loop: “1” if it’s on, and “0” if it’s off. This is left as an exercise, it is not hard.

Now we have a program that displays the state of the CapsLock key everytime it changes. It does not need to continuously poll the X server and so runs efficiently.

Now we need e-lisp that reads this asynchronously. This turned out to be fun for me since it was the first time I was dealing with processes — and that too asynchronous processes from elisp.


;; my patched version of xkbvleds
(setq xkb-daemon-command "/home/noronha/builds/x11-xkb-utils-7.5+1/xkbutils/xkbvleds")
(setq xkb-process nil)

(defun noronha-set-caps-state (state)
 (cond
  ((= state ?0)
   (noronha-set-cursor-color "black"))
  ((= state ?1)
   (noronha-set-cursor-color "blue"))))

(defun noronha-process-caps (process output)
 (mapc 'noronha-set-caps-state (string-to-list output)))

(defun noronha-start-monitoring-caps (display)
 (if xkb-process (delete-process xkb-process))
 (let ((process-environment (cons (format "DISPLAY=%s" display) process-environment)))
  (setq xkb-process (start-file-process "xkb-daemon" "xkb-daemon" xkb-daemon-command)))
 (set-process-filter xkb-process 'noronha-process-caps))

(noronha-start-monitoring-caps ":0")

And, yes, it works.

(Finally we need to restart the xkbvleds program when we connect using “ssh -X” and then run screen. I haven’t done this yet, but that final step is simple: write a wrapper over screen that calls emacsclient and runs (noronha-start-monitoring-caps "$DISPLAY").)


I need this post to sleep

June 1, 2010

[EDIT: This isn’t right. Sleep grogginess. Confusion. I hope I can come up with a correct-er post soon.]

I am immature and stupid, but I’m rebellious and still learning from life.

I hope this’ll make sense to my future self when he needs it: Morality is subjective. You did right. They won’t understand.


Verizon and its absolutely crappy customer service

March 29, 2010

I really haven’t seen anything as bad as Verizon’s customer service. This blog post is not lessen my frustration, but just to get back at them, I’ll make sure that none of my readers ever take a Verizon connection ever.

Now, there’s this theory, that for every internet provider, or wireless provider, there’s at least some person who thinks that they’re the worst company in the world. For Verizon, I’m one such person.

Here’s my story.

First around January 13th, I applied online for an internet connection with Verizon. Well, that connection never came (some credit issue? But they could’ve mailed me that something was wrong.) This was my first experience with Verizon customer service. Here’s how it works: you call up their number, they keep wasting your time asking lots of questions, and trying to avoid having to get a customer service rep speak to you (“you want to speak to an agent, but it may be faster to solve your problem here.. followed by the menu repeated“). After that, when you final press 0 a couple of times to keep confirming that “Yes, Dammit I do want to speak to a real person”, you’re told that they’re currently experiencing lots of load and it maybe a while before I can get to an agent. And they thank me for my patience.

And it is quite a frikking while. And after that quite a frikking while, I am also sometimes (right now) told that their offices for my location are closed. (9.30am.)

Couple of other times, when you do get them, they do everything possible to transfer you to somebody else (“New york region”, “tech support”).

Anyway, so the first connection that I applied for on January 13th never got connected, and eventually I had to apply for a new connection over the phone around Feb 8th or so. This was the only pleasant conversation I had with their agents, but mind you … be ready to talk for an hour on the phone for this.

Also, they take your credit card number for automatic payments.

So then, a week later I get my equipment. But my internet doesn’t work.

So now begins this whole drama of me calling them up, them saying that they’ll send a technician who never shows up. (I instead get a phone call on the morning of the visit when I stay at home just waiting for him, saying that my “problem has been resolved.” Really?)

Eventually they tell me that they need to downgrade my connection speed to 3mbps, from the already not impressive 7mbps.

So then I walked into a Time Warner office, and got a blazing fast connection that weekend.

The Verizon drama wasn’t over. I still had to disconnect my service. They had already billed me for the first month, directly on my credit card. No notification mail of any sort.

Most of these companies have a 30 day return policy. So when I eventually got hold of a customer service rep to cancel my account, I was told that I can return the equipment and I’ll be refunded for the first 30 days since the internet never worked for me. Oh wow, I say to myself.

That never happened.

Instead I just got billed for a second month. (This despite having a confirmation mail from them that my service has been disconnected.)

I’m getting quite sick of the seeming pleasant automated woman asking me to say “Billing or payment, or press 1, say Tech support, or press 2….” I’m down over 200$ here already.

I usually avoid caps lock, this time I will use it: NEVER TAKE A VERIZON CONNECTION! YOU CAN CHECKOUT ANY TIME YOU LIKE, BUT YOU CAN NEVER LEAVE!


The CMI Online Judge needs you

October 11, 2009

I’m willing to pay a small amount (very miserly, but I hope there are some CMI undergrads who are in enough poverty to take me up on this offer) to get some work done on the CMI/IARCS Online Judge.

  • 50 USD for a new professional looking CSS and layout. This is important for me, since I’m on the job hunt, and I link to opc.iarcs.org.in on my resumes, I want it to look good again. No partial credit. The layout will also have to explain considerations as to what is placed where. (For example, currently “Logout” comes on the top menu, which is completely unintuitive.) 100% XHTML Strict. Javascript/AJAX can be allowed.
  • 90 USD for a specification and implementation of a tar-ball structure that almost completely defines a problem’s data. By this I mean, I should be able to create a tar-ball with all the input and output files, the problem statement, constraints etc, and just have to upload it to the judge, and the judge should be able to figure out all the parameters to the problem automatically. I have made few attempts toward this, but every time I miss something or the other, which makes it completely useless. 10 USD for a complete written specification, 60 USD for implementation via command line. 20 USD for implementing via web-uploads, with some sort of permission mechanism to allow owners to upload the problem, and edit it if required.

Alright, I know I’m being cheap, but I really can’t afford to pay you a lot more. As a consolation, you could use this as “open source development” experience on your resume.

5$ for a name for the CMI OPC Judge. (It is referred to by several names even within the code. I am planning on putting it up on Sourceforge or something, but I don’t have a name for it.)

Mail me if you’re interested.