Skip to main content

Posts

Letting Go

Today as i was going through Hacker News , i came by a very, very interesting article. Friends Without Benefits . Somehow, i was touched by this article.  Its written by a woman about her relationship with a man she loved since she was 22, and how, finally, she could let go of it. All of us have relationships that we need to 'let go' of. Let me talk about mine. I had a friend. My best friend. I loved him like my brother. I cared about him. It hurt me when he was hurt, physically or otherwise. He was a little peculiar, but, then again, so was I. Things went great till the end of that common phase of our life. After that, we went our separate ways. We lost touch for a brief interval. We did get back in touch again. But I was always the one reaching out. Maybe i just realised it now? Maybe it just started now? Maybe it was always that way? But maybe I was seeing something that was not there? I decided to keep an account of my interactions with him. Just so that...

A word on todo lists

I have always felt that if If I remember to do things, it must be really important. But sometime, after juggling a profession, home, hobbies and still remaining sane, I think lists are the perfect companions to the improvements in our life.  Their most important use in in saving time and having order in life. When we juggle 3-4 different things and all have almost the same priority, it becomes difficult to remember things. So how do I maintain lists? One. I list things out to do in locations. Two. I list tasks under people. Why? Because it is relevant. Contexts, relevance has been almost shot out of the sky when it comes to todo lists. So I make lists by places or people, whichever would be better for me. This works perfectly. For me. Now. Before I clearly remember that striking things off the list made me feel powerful, so I used to make lists, do all the things in them one by one, and then strike then off. This could be the use of the list. Even now, if I cannot find in...

Wicktionary Bookmarklet

A bookmarklet is defined by Wictionary as "A small piece of JavaScript code stored as a URL within a bookmark". I have been using bookmarklets to make my life easier from a long time. Some that I use regularly are [Read Now] : This makes it really easy for me to read pages which are unreadable. [Google Translate] : Translates pages [Mobilise This] : Formats the page for mobile viewing by Google. [Acronym lookup] : This helps me find the meanings for abbreviations. The links in [] brackets are bookmarklets. Just drag them to your bookmark bar. I picked these up from these two pages. There is also a whole website dedicated to them bookmarklets. As a developer, what i like about bookmarklets is that they are coded in JavaScript and i can meddle with them till my heart's content, without worrying about breaking anything. However, i wanted a bookmarklet that would allow me to look up meaning of words. Wiktionary was my open dictionary of choice. They d...

Addition of lightbox to my blogger template

Since i have started regularly blogging, i have felt the need for a small subpage or popup kind of feature where i can briefly explain things that do not need a dedicated blog post and where links to external pages would be 'a bit too much'. I decided to use the lightbox effect for this. It would be the perfect solution to my problems. After a little googling, i came up with 2 amazing and simple implementations, one by Abhinay Rathore, this uses CSS and javascript, and the other is by Emanuele Feronato, which almost all css and even the minimal js is used to manipulate the css. As I am extremely lazy and also was not entirely happy with both the implementations, i decided to mix the 2 and get my own lightbox. Abhinay's solution was something i found unnecessarily complex and Emanuele's solution was not elegant enough. My own solution is midway between these two and is satisfactory for personal reasons .( Yeah, click on the link. I already found a use for my new ...

Line/Bar Graphs using Canvas in HTML5

<canvas id="tutorial1" width="350" height="200" style="border: 1px solid black;"> <script> var canvas = document.getElementById('tutorial1'); var ctx = canvas.getContext('2d'); ht = canvas.height; wt = canvas.width ; var data = {}; data.gtype = 'line'; data.title = 'hey! title goes here'; data.data = [['Q1',10],['Q2',20],['Q3',30],['Q4',40],['Q5',25]]; ctx.drawCross = function (x,y){ this.beginPath(); this.moveTo(x + 5, y + 5); this.lineTo(x - 5, y - 5); this.closePath(); this.stroke(); this.beginPath(); this.moveTo(x - 5, y + 5); this.lineTo(x + 5, y - 5); this.closePath(); this.stroke(); } ctx.fillStyle = "Red"; ctx.beginPath(); ctx.moveTo(40,10); ctx.lineTo(40,ht-40); ctx.lineTo(wt-10,ht-40); ctx.stroke(); ctx.closePath(); /* draw title*/ len = ctx.measureText (data.title); ctx.fillText(data.title, (wt -...

Array magic in JavaScript

I was trying to create a queue to collect all the element related functions to run after the elements had been created. As I was Googling, I came by this snippet . var calls = []; function executeNext(next) { if(calls.length == 0) return; var fnc = calls.pop(); fnc(); if(next) { executeNext(true); } } /*To call method chain synchronously*/ calls.push(callMe3); calls.push(callMe2); calls.push(callMe1); executeNext(true); /*To call method chain asynchronously*/ calls.push(callMe3); calls.push(function(){ callMe2(); executeNext(false); }); calls.push(function(){ callMe1(); executeNext(false); }); An array was a perfect fit with the built in push() and pop() function. I also needed something that would work the pop() till the array was empty. As Douglas Crockford says in his wonderful book ' JavaScript: the good parts ', arrays are actually (slightly disguised) objects. So one can simple add to the native methods that the array var...