Saturday, 4 April 2015

Out of context advertising

Why would I be interested in obituary speeches when I am looking for time zone differences ?

Even facebook goes down

Yeah, it is an event to be noted.

Saturday, 28 March 2015

Bad user experience on fortune.com

Experience in mobile and web should be different
While reading an article on Fortune, I found the reading space so annoyingly reduced. I guess in attempts to make a consistent mobile and web experience people are failing badly.

Saturday, 14 February 2015

Ola on the rise

The website being broken can mean either business is not moving or it is moving too fast. For Ola, the case is the latter.

Monday, 5 January 2015

Disruption in taxi business

Earlier taxi's used to be rather costly. Auto-rickshaws would be around half the price. So spending a little more time in travel and saving some money was a good option. However, looking at the fare charts of Ola and Taxi For Sure, it seems they are snatching away the market from auto-rickshaw drivers as well as from old taxi services.

Negotiating with auto-rickshaw drivers is a hard-learned skill. However as companies like Ola and Taxi For Sure are gaining market, the skill is becoming useless. The disruption in the market is achieved by use of technology to reduce wait time for taxis as well as customers.

The pain points that these technologies are addressing are:
1. Time spent in negotiation is cut off.
2. Taxi drivers are on an average better behaved than auto-rickshaw drivers.
3. Scheduling pickups is easier.
4. Payment is easy if you have a digital wallet with the taxi service.

Some issues that I face usually in Hyderabad are:
1. The driver does not know Hindi and I don't know Telugu so we are stuck on the communication part.
2. The time shown by these car service apps does not take into account the traffic.
3. The drivers usually don't know how to read maps. They need guidance to reach the pickup point and sometimes take long routes.
4. The mobile phone network is not consistent.

Often I find the driver knows a landmark near him and a landmark near my pickup point and because of language problem, I can't explain to him which way (possible shortcut) to take. So, instead of trying hard to explain, I tell him to start on the route he knows or a general route. Then I start tracking him to find where he is and call him back to tell him what to do.

Disruption in this market space is really a nice improvement. It is beneficial to customers as well as drivers. I hope to see this industry flourish.

Saturday, 16 August 2014

Finding the file or device pointed to by a file descriptor

I had been noticing that Firefox starts off with around 400mb and reaches around 1.4 gb as I keep using it throughout the day. Also, CPU utilization clocked at 25% on my i7. So, I thought of trying to mess around in the hope of finding something interesting. I found the pid using the following.

ps aux | grep firefox

I ran an strace to try and see what was keeping it so busy.

strace -p <pid_of_firefox_process>

This is what I got.

poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
getrusage(RUSAGE_SELF, {ru_utime={17387, 398261}, ru_stime={821, 999917}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={17387, 438261}, ru_stime={821, 999917}, ...}) = 0
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
write(18, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])
read(17, "\372", 1) = 1
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 0) = 0 (Timeout)
recvmsg(4, 0x7fff427b9fb0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=17, events=POLLIN}, {fd=19, events=POLLIN}], 4, 4294967295) = 1 ([{fd=17, revents=POLLIN}])

Now, I wanted to know the files pointed to by file descriptors 4, 5, 17, 19. To look those use, I read that I can use /proc filesystem. So, I just tried simply looking it up there.

ls -l /proc/<pid_of_firefox_process>/fd

The files turned out to be as follows:
  • 4 - a socket
  • 5 - anon_inode:[eventfd]
  • 17 - a pipe
  • 19 - another socket
Any suggestions are welcome. I will keep looking into the issue.

Wednesday, 16 July 2014

Invoke a rake task multiple times from another

To invoke a rake task within another, one can do the following:

Rake::Task['namespace:task_name'].invoke

However, if you need to run a task multiple times, the following will not work.

n.times do
    Rake::Task['namespace:task_name'].invoke
end

It only executes the task once. This behaviour is useful when you are loading dependent tasks. For example, if there are two tasks that depend upon :environment task, this behaviour ensures :environment is loaded only once. However, the above code is written with a different intension. To make it work correctly, the rake task has to be re-enabled. The way to do it is as follows:

n.times do
    task = Rake::Task['namespace:task_name'].invoke

    task.reenable
    task.invoke
end

Thursday, 5 June 2014

Writing files in a specific encoding in Ruby

Recently, I was trying to create PDF files of barcodes. I was using barby gem for generating barcodes. When I tried to write the generated PDF, I found that the PDF string was in ASCII-8BIT encoding while my console was in UTF-8 which was causing Ruby to attempt writing in UTF-8 encoding causing errors. So, to write to the file in ASCII-8BIT, I had to specify that while opening the file. I achieved that using the following and I could write to the file correctly.

f = File.open("test.pdf", "w:ASCII-8BIT")
f.write the_pdf_string
f.close

Sunday, 25 May 2014

Compiling in Emacs

I use Emacs for development in C. I was trying out some algorithms and I had used some functions from math.h. I had included the header of course. However, when I wanted to compile I knew I would have to use the -lm flag to include math.h in the compilation. I use M-x compile for compilation. It usually asks me to enter the name of the executable to be built. In that same line, I added the CFLAGS=-lm part to the end of that line and the compilation worked fine. So instead of

make -k application

my compilation command looked like the following.

make -k application CFLAGS=-lm