http://akshaydewan.me/Ghost 0.7Fri, 22 Feb 2019 14:52:31 GMT60Imagine you have a couple of local commits, and you’re going on leave tomorrow. You can’t push the code, because the build just turned red. What do you? E-mail patches to your pair? Push on a branch?

But there’s another alternative.

Git is a distributed version control

]]>http://akshaydewan.me/one-neat-trick-to-avoid-sending-patches/dec8ca14-b69d-4650-aa17-d9c9dd8efb59Wed, 09 Aug 2017 03:01:03 GMTImagine you have a couple of local commits, and you’re going on leave tomorrow. You can’t push the code, because the build just turned red. What do you? E-mail patches to your pair? Push on a branch?

But there’s another alternative.

Git is a distributed version control system, but we hardly ever make use of the “distributed” nature of Git. You can share code with your pair directly. There is a package called git-daemon which comes bundled with Git. Here’s how you can use it:

Go to the directory one level above your repository and run:

git daemon --base-path=. --informative-errors --verbose --export-all

This will serve all git repositories in the current directory. Your pair can then pull code from you directly. E.g. git pull --rebase git://10.0.2.2/my-repo

One thing to keep in mind though: Git daemon does not have any authentication. DO NOT use this when connected to insecure networks. As long as you’re on a closed, secure LAN, you should be fine. And terminate the daemon as soon as you’re done.

Here’s a small script that will also print out your IP so that you can share it easily:

(The script is MacOS specific. You may have to change it to make it work for you).

You can save this script with the name git-serve (or something similar) and add it to your path. Then you can just run git serve from your working copy.

Hope this helps. And don’t blame me if you end up with messy conflicts :)

Do you know of any neat tricks for Git? Leave a comment!

]]>For those blissfully unaware, Antakshari is a singing game played by two or more teams. The starting team sings the first verse of a song, and the next team has to pick a song starting with the last letter of the previous team’s song. Songs cannot be repeated in]]>http://akshaydewan.me/solving-antakshari/14819dcf-7437-4833-a671-0de89da050feSun, 05 Mar 2017 10:01:50 GMTFor those blissfully unaware, Antakshari is a singing game played by two or more teams. The starting team sings the first verse of a song, and the next team has to pick a song starting with the last letter of the previous team’s song. Songs cannot be repeated in the game. For instance, if the first team sings a song starting with म ‘Ma’ which ends with न ‘Na’, the next team has to sing a song starting with न ‘Na’. Subsequently, none of these songs can be repeated. Scoring is ambiguous and varies during casual play, but we can assume that once a team is unable to pick a song within a reasonable amount of time, they lose a point. Usually, before this state is reached, humans tend to have several arguments about whether a song was already done, and move on to other games.

Expressing the problem

For the sake of this article, I will limit the game to two players. I’ll also consider English characters, though technically, any set of symbols can be used. Trying to express the game more formally:

Each song can be represented as a tuple with two symbols representing the starting and ending symbol. For example: (a,b) represents a song starting with ‘a’ and ending with ‘b’.

Now let’s define a bunch of sets:
S: Set of all songs
Sₓ: Set of all songs starting with a symbol x
K: Set of songs which have been exhausted (or killed, by singing them very poorly. Thus, ‘K’ for killed). When the game starts, K will be empty, and an element will be added after every turn.

For every turn t = (a,b), the next valid turn can be defined as some u, such that u ∈ Sb ∩ K'
(Meaning, the tuple u belongs to the set of songs starting with b, but not in K). Two distinct songs can be represented with the same tuple, but they won't be equal (so the Set representation may not be intuitive to work with).

We can also represent the set of possible moves as a graph, like so:

Strategizing

Let’s say that two players are playing to win, how can we determine the best possible move? Or can we determine what would constitute as a good move or a bad move?

One possible option would be to minimize the number of choices you give your opponent. In the graph above, let’s say we are at Turn 2 for Player 2. We have 5 options to pick from {(b,m), (b,n), (b,o), (b,p), (b,q)}. We can see that (b,n) will give Player 1 three choices in the next turn, and the rest are omitted from the diagram.

If one of the options, say (b,q) has zero choices, then we can simply pick that one and win, since Player 1 won’t have any moves left. On the other hand, if we don’t have a node with zero choices, we can simply pick the one which gives the least number of choices to the opponent.

But I don’t like this strategy because in a real game, things won’t work simply by minimizing the number of choices the opponent has. To elaborate, let’s say you have a choice between node A which has 3 popular songs vs. node B which has 5 obscure songs, the better choice would be node B, since your opponent would be less likely to remember the obscure songs.

Now let’s try to represent the obscurity (or popularity) of a song. We can simply say that it is the probability of a song being “known” and we will represent it with some p where 0 ≤ p ≤ 1. (A song with p=1 will be definitely known, and one with p=0 will be definitely unknown).

A song being “known” is a bit ambiguous, but let’s say we can come up with this value using a clever algorithm that looks at music charts, top-ten lists, revenue generated by the song, and so on. Heck, let’s even throw in the profile of your opponent in there. (e.g. if they’re really into a particular genre or artist, they may know the more obscure ones in that category as well). In the end, you have some value p which represents the likelihood of a particular song being remembered by your opponent.

Let’s re-look at a graph of moves, this time with probabilities added.

I’ve limited the number of nodes for the sake of brevity. Now let’s say we are at Turn 2 Player 2, we need to pick the next possible move between (b,n) and (b,p) (or any of the other potential options we have). In this case, we’d pick the one that has the total lowest probability of being known.

We can claim that the knowledge of songs is independent, but not mutually exclusive. (Typically, your knowledge of song A won’t affect your knowledge of song B (=> independent). Also, knowing song A and knowing song B are not like a coin-toss where only one of the two can occur (=> not mutually exclusive)).

So then, from the graph we can calculate the probability of knowing A or B or C as:
P ( A ∪ B ∪ C) = P(A) + P(B) + P(C) - P(A∩B) - P(B∩C) - P(A∩C) + P(A∩B∩C)
= 0.433
The formula can be extended for any number of nodes. (Although it would get ugly, and there’s probably a simplification available).

The other choice P(G) has a popularity of 0.8, which is greater and 0.433. So the better choice for Player 2 is to go with (b,n) even though it has more number of options for your opponent.

Looking at choices you’ll get back

To further complicate the problem, let’s say you are Player 2 at Turn 2, and instead of only looking at Turn 3, you also want to look at Turn 4, where it will be your turn to play again. Why would you want to do that? To ensure that you get back a set of choices that have a high probability of being known by yourself. That is, you shouldn’t drive yourself into a trap.

If Player 2 had chosen (b,n), (since it had the lower popularity score), then at Turn 3, Player 1 would most likely choose Node A (n,a) and Player 2 would find themselves in a soup, because the next set of choices have a combined popularity of only 0.2. On the other hand, if Player 1 chose node C, (even though that would be less likely), Player 2 would have no problem playing Turn 4, since the combined popularity is 0.9. Or if Player 1 chose (n,p), then Player 2 would lose!

It would make sense to add a safety heuristic to our algorithm. We could pick a safe popularity value such as 0.8 (or how much ever a player is willing to bet), and at no point should we pick a choice if the subsequent move would end up below our safety threshold.

Looking ahead will have diminishing returns. It would not make sense to compute all possible choices and look ahead more than a few turns. We can use conditional probability to calculate which branches of the graph to look into. For instance if Player 2 has a choice X and in the next turn, Player 1 ends up with A and B as possible choices subsequently, we can compare P(A|X) and P(B|X) and disregard the branch that have a low chance of occurring, again by defining some threshold.

Practical Considerations

While the formulations above make sense mathematically, they have very little practical applicability in my opinion.

If a human player is playing against a machine, the human is already at a disadvantage because she would have limited memory of songs, while the computer can look it up in fractions of a second, regardless of the strategy it employs. The computer would simply have a larger database.

If two computers are playing against each other, then the popularity score makes no sense - all the songs would be in their memory.

If two humans were playing, and one of them cheating by using a computer, then they wouldn’t be able to sing a song that the computer suggests if they didn’t know it. If both humans were cheating, it would be equivalent to two computers playing against each other, with the added confusion of the computers suggesting obscure songs that the humans aren’t aware of.

Nonetheless, if we keep the strategizing part aside, we can still answer some interesting questions like: What would be the longest and shortest possible Antakshari game?

And from a computational perspective, Antakshari turned out to be more complex than I had anticipated, more so if you consider strategizing. Building the graph of next possible moves in an optimal way would itself be an interesting challenge, albeit perhaps a solved one, since it does resemble other board games.

Conclusion

This was a fun little exercise I partially came up with while other humans were playing the actual game. If you have thoughts, comments, or if you notice any errors, do leave a comment.

]]>I recently came across a documentary about a native tribe in the Australian desert that first made contact with the outside world in the 1970s. It was a hunter gatherer tribe that was living in the stone age, while the rest of the world was getting computers in their homes.]]>http://akshaydewan.me/thoughts-on-human-civilization-and-progress/232b0549-f140-4da2-9077-589fd0afc34fWed, 08 Feb 2017 16:32:30 GMTI recently came across a documentary about a native tribe in the Australian desert that first made contact with the outside world in the 1970s. It was a hunter gatherer tribe that was living in the stone age, while the rest of the world was getting computers in their homes.

That got me thinking about the progress of human civilization. There are, to this day, a number of tribes that have not made contact with the outside world (and those that choose to live in isolation). A part of me always thought that humans, left to the elements, would naturally make progress. As intelligent creatures, we create tools, pass on our knowledge to our children, who then pass it in to their children. Along the way, new discoveries are made and added to the corpus of knowledge.

Which brings me to my first observation about uncontacted tribes -- they have no written language. Written language was a huge step forward for preserving knowledge. Without writing, the best people could do to pass on knowledge was using songs and poems. Clearly, that has its limitations. Along with written language, humans in many parts of the world also started experimenting with objects around them, and perhaps even started coming up with concepts of basic mathematics and geometry, creating a positive feedback loop for progress to happen.

But thinking, especially about abstract concepts, is an activity that requires leisure. Humans -- busy with gathering food, against the odds of nature -- wouldn't have had time to contemplate. Survival would have been the primary focus that would take up most of the time. What made the giant leap from "survival mode" to a bit of leisure? Agriculture!

And there were other major breakthroughs -- metal work, domestication, industrialization, medicine, computing and information -- and probably a lot of things in between.

What seems curious to me though, is that some chance events and discoveries have a huge impact and propel civilization forward.

I wonder what would be the next such event that would make civilization progress by several leaps? I'm hoping for cheap, clean energy for starters.

But the uncontacted tribes are still living in the stone age. Maybe they never discovered the right tools to create a rudimentary paper for writing. Maybe they environment they live in is so harsh that survival will always be a full-time job. In the amazon rainforest, there is literally no room for agriculture.

At this point, I have a question to pose -- is it ethical to leave these tribes as they are? What about the ones that chose to remain in isolation and rejected outside contact, such as the Sentinelese people? Basically, is the Prime Directive ethical?

While watching Star Trek, I felt that the Prime Directive was a pretty good way to go about things. (Of course, they violated it every once in a while to make for good television). But factoring in the angle of remote, uncontacted tribes, I'm beginning to think otherwise. Sure, I would want to preserve the knowledge that these people have about the plants and animals in their environment. Or the languages that they speak. Or the songs and fables they sing. But is it acceptable that that they die of diseases that can be cured? For the ones that rejected contact, is it alright that parents make this choice for their children?

Some of these tribes are so remote or deep in the rainforest, that very little aid can reach them. However, they do have the choice of moving out of their habitat. And I guess that they choose not to. Who would want to abandon their home, after all?

That brings me to the last topic I want to touch on -- cultures, beliefs, memes and how they affect progress.

I had read this somewhere (I don't quite remember where), and I have forgotten whether it is fact or fiction. But for the sake of this argument, it will suffice. There was a village that was facing famine. The soil had become infertile and nothing would grow. Curiously, there was a river flowing not too far from the settlement that had a plenty of fish. However, the people did not consider fish to be a form of food, and continued starving.

You may find that ridiculous, but picture this -- most of people in the western world do not consider insects to be food. Yet, insects are a perfectly good and abundant source of protein. Some day, insects may come to our rescue, provided we don't reject this source of food as ew, gross.

The interesting thing about beliefs is that we don't even realize what is holding us back. For a long time, people had a hard time accepting that germs cause diseases. Or what about that vaccination BS Americans keep arguing about? And what about organized religion?

Every once in a while, it might be a good idea to take a deep breath and re-examine our beliefs. You never know, it may bring about that leap forward in society.

]]>I managed to read a few good books last year, and thought of reviewing them. So here goes...

Jonathan Strange and Mr. Norrell

Author: Susanna Clarke
Genre: Fantasy
My Rating: ★★★★★

This one was recommended by a friend who has similar tastes, so I was quite sure I would like it.

]]>http://akshaydewan.me/2016-book-reviews/cd75d0ee-ccfb-4845-b1ff-73b7b54c71daSun, 08 Jan 2017 07:01:31 GMTI managed to read a few good books last year, and thought of reviewing them. So here goes...

Jonathan Strange and Mr. Norrell

Author: Susanna Clarke
Genre: Fantasy
My Rating: ★★★★★

This one was recommended by a friend who has similar tastes, so I was quite sure I would like it. And boy, was it amazing! Susanna Clarke has done a great job with the writing and the language. The story is wonderful, although I found it a bit slow at times. (It is a very long book too). Nonetheless, it kept me entertained, and every chapter brought in excitement. I won't divulge anything about the story, because I feel that it will be best experienced when you know nothing about it.

This book also has the potential to make a great TV show, and I believe there's already one on BBC One.

Did I mention that this book has a ton of footnotes? Makes it a whole bunch more fun. And for that reason, I'd recommend getting a hardcopy instead of an e-book. Footnotes are a pain to read on the Kindle.

Ready Player One

Author: Ernest Cline
Genre: Sci-fi
My Rating: ★★★★☆

This one is probably oriented towards the young-adult audience. Nonetheless, it was fun to read, especially if you're fond of technology, video-games and a hint of dystopia.

The book is fast paced, almost has a Hollywood blockbuster feel to it. If you grew up in the 80s or 70s, you may connect with a lot of the retro video-game and pop culture references.

Zen And The Art Of Motorcycle Maintenance

Author: Robert Pirsig
Genre: Philosophy, fiction
My Rating: ★★★★★

This book was recommended by a colleague. I'm glad I went ahead and picked it up. Because it's one of those books that expands your perception, or adds to the model of how you see things in the world. The last book that did that for me was The Selfish Gene by Dawkins, and it has been more than seven years since I read that one. So I thoroughly enjoyed reading this.

The story revolves around the author who is on a motorcycle trip with his son, and his thoughts during the trip. After all, there isn't much to do on a road trip other than thinking and observing. The narrative is unique and beautiful. There is a lot of discussion around the nature of art and science and technology, and I could draw a lot of parallels with software development.

This book rekindled my interest in philosophy. I'll probably be reading more in this area, and will surely re-read this book sometime in the future.

Domain-Driven Design: Tackling Complexity in the Heart of Software

Author: Eric Evans
Genre: Software, technology
My Rating: ★★★★☆

I picked up this book as part of a study group at work. In one of my older jobs, I saw a piece of software being build from scratch, and develop into an unmaintainable mess as we kept adding features and increasing complexity. I learnt a lot from that project, but one of the key missing elements was DDD.

Thanks to the book, and more so to the study group, I got a lot of answers to some of the questions that had bothered me about developing large, complex software systems. Concepts of DDD fit quite well with many of the modern paradigms of software development like microservices, functional-reactive patterns, messaging systems and so on.

Domain Driven Design should be a must-read for any software developer. Unfortunately, the book was also boring as hell. Eric Evans is not a good writer in the sense of keeping the reader engaged. If you do want to learn about DDD, I would suggest Vaughn Vernon. I found his work to be a lot easier to read compared to Evans.

That said, this is an important book, and the seminal book on DDD.

The Testament

Author: John Grisham
Genre: Fiction, Drama, Mystery
My Rating: ★★★☆☆

This book is about a crazy old rich dude who dies, leaves behind a lot of money and his greedy ex-wives and kids want everything for themselves. And then comes in the protagonist lawyer who'll save the day. Okay, that's probably a very crude synopsis of the book. But I found this book to be just "meh", not really my kind of book. The writing was pretty good though.

Below Another Sky

Author: Rick Ridgeway
Genre: Travel, Adventure
My Rating: ★★★★★

A colleague at work recommended this book and let me borrow his copy. I still haven't finished reading this, but thought I'd add this to the list.

This book is about Rick Ridgeway's journey through Nepal, Tibet and China. He's tracing back his journey to Minya Konka, where he lost his friend in an avalanche about twenty years earlier. His friend's daughter accompanies him, hoping to find her father's grave on the mountain.

This was the first time I read a book of this genre. Rick Ridgeway is an excellent and captivating writer. The book is a bit like a memoir, with Rick reflecting on this previous adventures, lost friends and how he has matured over the years.

So there you have it. Hoping for a lot of of good reading in 2017 as well. If you have any books to recommend, do let me know.

]]>There are times when we call a group of people uncivilized. Most often, this depends on your opinion. Others may have a different opinion and may very well call you uncivilized. For instance, I have been called uncivilized when I do not shave my beard for a few weeks.

But

]]>http://akshaydewan.me/on-being-civilized/584e0ea1-e30b-4702-8dbc-efa649923a8aSun, 06 Mar 2016 13:03:12 GMTThere are times when we call a group of people uncivilized. Most often, this depends on your opinion. Others may have a different opinion and may very well call you uncivilized. For instance, I have been called uncivilized when I do not shave my beard for a few weeks.

But is there any objective way to determine if a group of people are civilized? Can we determine this keeping aside our biases about race, religion or beard length?

A professor of economics once posed this question to his class. (My friend happened to be his student). The following is their take on it, with some of my own embellishments.

The method is quite simple - Game theory! Give the population a game theory problem. Give them an infinite number of iterations to solve it. Once they solve it, they are civilized. Take something like the Prisoner's dilemma. Here, the optimum solution for the prisoners is to cooperate. Given such a problem, would a population come to this optimum solution? How many iterations would it take?

Here's a more concrete example. A group of farmers, all sowing the same crop, has to sow their seeds just before the start of the Monsoons. The ideal date for this, let's say, is from the 1st of June until the 10th of June. Sowing early means that your crop will be ready for harvest sooner. But when your crop is ready, it will be attacked by birds, and the birds can destroy a lot of it. Therefore, if you're the first farmer to sow your seeds, you'll end up losing the most to birds.

As a result, you would want to wait for someone else to sow first, so that you can minimize your loss. However, if no farmer wants to sow first, they will delay, and you'll end up missing the ideal window for sowing. The 10th of June will be gone, and you will face a bigger loss anyway because you couldn't sow at the right time and take advantage of the monsoon.

The optimum state here is for all farmers to cooperate and agree to sow at the same time. This way, no single farmer would have to bear the brunt of the birds. Everyone would be able to sow at the right time.

In a civilized society, you will probably see a structured, governing, cooperative organization to handle matters like these. In an uncivilized society, you will see losses that could have been easily avoided if the farmers cooperated.

I find this model elegant and objective. You can narrow down on a particular problem and determine the civility of the population. It is possible for a society to be civilized in some matters - say farming - but not in others - say caste equality. You may also find that a tribal population is more civilized than your own society.

Another game that I am reminded of, and forced to play often is: driving in traffic. If the majority of the population cooperates, it would be a lot easier to drive in traffic. But if everyone drives like an asshole, then you're forced to drive the same way. How long before we become civilized drivers?

]]>When you've been programming long enough, you'll have some interesting stories to tell - about bugs that confounded you, crazy clients who didn't know what they wanted, or mad managers who wanted everything delivered yesterday.

Looking back, I can think of three fascinating bugs I've encountered. You encounter your typical

]]>http://akshaydewan.me/debugging-stories/c84972c2-c1d0-428a-8758-e9f961cf0677Sun, 08 Nov 2015 13:19:54 GMTWhen you've been programming long enough, you'll have some interesting stories to tell - about bugs that confounded you, crazy clients who didn't know what they wanted, or mad managers who wanted everything delivered yesterday.

Looking back, I can think of three fascinating bugs I've encountered. You encounter your typical timing-issues or framework idiosyncrasies every now and then, which can be quite hard to understand and fix. But these three bugs are a different species altogether.

Out of disk space

It appeared that one of our servers couldn't process any requests because it had run out of disk space. (At least that's what the web server logs said). It seemed strange, because we didn't have that much data on the server. Doing a df -h showed several gigabytes of free space remaining.

It was odd, but what was odder was the database we had in place. It generated a file for each record that it created. As a result, we ended up with a very large number of small files on the system.

As it tuns out, we had hit the maximum number of files that the filesystem would allow us to create! Running a df -i confirmed that we had run out of inodes. The obvious solution was to move to a better data storage mechanism. Alas, in that company, we never took the obvious solution. But that's the subject of another blog post ;)

The mystery of the disappearing card

We were working on an online poker game, which used virtual currency. I am thankful that we were using virtual money, considering the number of bugs we had in that piece-of-crap of a program.

So one day, the client complained that a card would disappear randomly in the game. For a long time, we couldn't replicate the issue - until it finally happened on a developer machine. It seemed completely random, and we couldn't narrow it down to a particular scenario.

Of course, to solve a bug, you first have to reproduce it. So one of the devs sat on his machine all day, playing poker while inspecting the network requests/responses and logs. He got to a point where he figured out that it was only the Ace of Diamonds that would disappear.

What was so special about the Ace of Diamonds that made it disappear? The network logs showed that the server was serving the response correctly. How the heck did it disappear? Clearly, the problem was not on the server. Even so, we decided to walk through the code again, debug it line-by-line just to ensure that the correct response was being served.

A couple of other people tried to replicate the issue. We found that it happened only on some of the boxes. Trying to narrow it down further, we tried different browsers. And that's when we realized what was happening.

The Ace of Diamonds had an image file which was named ad.png. The AdBlock browser extension decided that this was an advertisement and blocked the image.

To solve the problem, we simply renamed the file.

The slow Sudoku

Remember when Sudoku had become crazy popular around 8-10 years ago? I was in college at the time, and decided to build a Sudoku program for my project.

I built it in C++ using Qt for the GUI. I also came up with a rather crazy algorithm that used three-dimensional arrays instead of two-dimensional ones. (The third dimension was the model the small 3x3 minigrid).

Well, adding that extra complexity also added a lot of computational overhead, making my program very slow. Or so I thought.

After the program was complete, it took about 5-10 seconds to solve a puzzle on my home PC. But when I deployed it on the PC in my college, it took less than a second to solve it!

Now that didn't make any sense. My home PC was much faster - it was a Pentium-4 with 1.6GHz, whereas my college PC was only a Pentium-3 800MHz. I also had more RAM and a better graphics card. It just didn't make sense. This had to be solved!

Digging further, I started looking at log files and dmesg output on my home PC. I saw a strange message popping up whenever I ran my program: "CPU running in modulated clock mode". I searched online for what it meant - apparently, my CPU was running too hot and the kernel was throttling the speed to keep it cool.

I popped open my cabinet and saw that my CPU fan wasn't working. I replaced it, and my Sudoku became fast again!

]]>It's been more than fourteen years since I started using GNU/Linux. Fourteen years! That's a very long time. There are interns in my team who would have been toddlers starting school when I started using Linux. Damn, I'm old!

My first adventure was with RedHat Linux. I had purchased

]]>http://akshaydewan.me/linux-user-since-2002/e4d09cfc-f648-4f07-bcc2-dea444c84b0cSun, 20 Sep 2015 14:41:41 GMTIt's been more than fourteen years since I started using GNU/Linux. Fourteen years! That's a very long time. There are interns in my team who would have been toddlers starting school when I started using Linux. Damn, I'm old!

My first adventure was with RedHat Linux. I had purchased a book that came with a RedHat CD. The book had instructions on installation and everything else needed to get up and running. It also taught me the basics - permissions, user management, package management. I had a friend already familiar with Linux who guided me along the way - that helped a lot

That was probably the last version of RedHat until it split up into RedHat Enterprise and Fedora. Sure enough, I got that itch to try out a new distro and tried out some version of Fedora Core after that. It wasn't a stable release and kept crashing all the time. I got tired of it and installed Slackware, and continued using it for a couple of years. Slackware was great! It was also the time I compiled my own kernel. But it didn't have the latest and greatest software in its package manager, and I grew tired of compiling things from scratch. (I vividly remember compiling Gaim every time there was a new release out). After Slackware, I tried out a number of other distros until I finally settled on Ubuntu 5.04 (Hoary Hedgehog).

Ubuntu, IMO, has been a great distro, especially for newbies, and has contributed a lot to the popularity of Linux. (There are probably a few unnecessary forks that Ubuntu has made over the years, but let's leave that aside for now).

After using Ubuntu for many years, I grew tired of it and installed Arch Linux. Arch was another great learning experience. The simplicity and power of Arch was really impressive. It has a great community and an excellent Wiki.

Around this time, I had finally had the resources to beef up my machine into a gaming rig. Unfortunately, games did not run well on Linux at the time. I had always been dual booting all these years, but I found that I was booting into Linux very rarely. All my games were on Windows.

And finally, it's 2015. Steam has a number of games on Linux and the list continues to grow. A few months back, I decided to ditch Windows for good and moved to Linux permanently. I'm now running Ubuntu Gnome, which so far has been great and doesn't get in the way.

Linux has taught me a great deal, and continues to do so. I have also learnt the value of free and open source software. I dislike the walled gardens that our mobile operating systems are at this point. It feels that we are regressing into a period of closely controlled systems. While companies like Google and Apple are still innovating, I feel that there will come a point when this innovation will be stifled due to their lack of openness. We're already seeing consumers who will buy products from only one company (e.g. iPhone, itunes, Apple TV, iMac) just so that they work seamlessly with each other. While this closed system is great for making profits, it is ultimately bad for consumers. Eventually, I believe consumers will realize this and move towards open solutions. Or we can look forward to a dystopia where everything is owned by an evil corporation.

]]>GMail's Compose window - quite like my bank balance - keeps getting smaller with every iteration. It makes sense. After all, who writes long e-mails these days? It's funny really - sometimes I'll get a mail from someone that spans just over three paragraphs - and they apologize for the]]>http://akshaydewan.me/how-technology-makes-up-shallow-and-stupid/729c34a2-6c7c-4809-8c20-42d19c5f869aThu, 23 Jul 2015 15:31:03 GMTGMail's Compose window - quite like my bank balance - keeps getting smaller with every iteration. It makes sense. After all, who writes long e-mails these days? It's funny really - sometimes I'll get a mail from someone that spans just over three paragraphs - and they apologize for the long mail.

You could, of course, argue that we don't need to send long emails - because we have better communication channels - like Skype/Hangouts/WhatsApp and the like. Yes, you would be correct. But ask yourself when was the last time you had a long, meaningful conversation with a friend over Skype? When did you have a lengthy discussion about the latest Marvel movie, the last cricket match, or depending on your age, about work, politics, religion or your bowel movement over Hangouts?

The problem with always being Online

Back in the old days, you would explicitly go online and sign-in to an instant messenger. It was an elaborate ritual that involved booting up your computer, clicking on the Internet icon, the dial-up modem making beeps (and you mouthing along), and finally clicking on ICQ or AIM. You would see that most of your buddies are offline, and a couple of them online. You would write "Hi" to someone, and they would reply. And you would continue chatting for a few minutes or even a few hours.

These days, everyone is always online. If you say "Hi" to someone, chances are, they will be busy. They will reply after a few hours. And that's when you will be busy. Conversations become short and meaningless.

I find that this is pretty much the same with telephone calls. "Hey, I gotto run. Will talk to you later!"

Your awesome breakfast this morning

Don't you want to share that on Facebook? Check-in to that restaurant? Tell all the people how amazing your life is? About how you're feeling sad or happy or excited today? Oh, but how could I forget about the Send this to 10 people for good luck posts. Or about how Mars is going to be bigger than the moon. (Seriously, to the people who post that: Your mom is bigger than the moon).

Try sharing something that triggers a discussion, and see how quickly the trolls take over.

A solution

While instant messaging and social media do have their advantages, what is missing is the ability to have long, meaningful discussions with your friends. The telephone is a good option, provided you can decide a on a time. For people staying far away in different time zones, this would be difficult.

The solution, I believe, is what people have been doing since a long, long time - writing letters. Of course, you would e-mail them rather than having them go through the alimentary canal that is our postal system.

But then again, perhaps I am one of the few people who sees this as a problem that needs solving. Most people I know are perfectly content with sharing their short, poorly-worded life experiences over Facebook.

However, if you do agree with this post, I encourage you to start writing to people. As for the rest of you, get off my lawn!

]]>

As the planks of Theseus' ship needed repair, it was replaced part by part, up to a point where not a single part from the original ship remained in it anymore. Is it, then, still the same ship?

As the planks of Theseus' ship needed repair, it was replaced part by part, up to a point where not a single part from the original ship remained in it anymore. Is it, then, still the same ship?

If all the discarded parts were used to build another ship, which of the two, if either, is the real Ship of Theseus?

This paradox brings forth the question of how we define objects, their purpose, and the effect of time.

The resolution of this paradox largely depends on how you define the Ship of Theseus. If such a ship really existed, you would probably say that the ship was upgraded, and that the older parts were recycled to create a new ship. The upgraded ship would remain the true Ship of Theseus.

For the sake of argument, if the ship were purely defined as the collection of its planks, it would stop being the Ship of Theseus the moment its first plank was replaced. But that is not how we define objects. Most things (or even people) are defined by:

The material they are made up of

The configuration or arrangement of this material

The process that brought about the creation of the thing

The purpose of the thing

Clearly, it is not enough for an object to "stop becoming" itself unless one or more of these parameters changes beyond a particular threshold. And there is no universal constant that defines this threshold. Another important factor is the passage of time. Even if all the parameters that define an object change significantly, if this change happens over a long period of time, you could still end up with the same object. The lifecycle of a caterpillar or butterfly is an interesting topic to think about in this context, as is the evolution of complex life forms (such as ourselves) from unicellular microbes. We are star-stuff, aren't we?

Theseus 2.0

You have a team of ship-builders, who are given a legacy ship called Theseus. Theseus works quite well, but it hasn't been able to keep up with the times. Now-a-days, ships have better storm-resistance, improved controls for navigation and can carry a lot more cargo. Your job is to upgrade this ship to satisfy these modern requirements.

As you're working on the Navigation Subsystem, the code baffles you and you have no idea how this ship even works in the real ocean. You annotate the source code to see if the commit messages make any sense about why that if-condition was added in the rudder subroutine.

Over a period of months, after you annotate the code of the Navigation Subsystem, you find that all lines of code have been written by your team. None of the legacy authors show up in the list. But you never set out to re-write this code, only to upgrade it part-by-part. Looking at the commit history, you see that every change has been small. And yet, over a period of months, none of the old code remains.

Who, then, is the author of the code? While you have touched all lines of the module, you also managed to capture the intent of the original authors, like that weird if-condition. Of course, you refactored it and came up with a better design. But it was the original author that told you the if-condition was needed. Otherwise, your ship would've sunk.

This is an interesting problem for Wikis and collaborating forums like StackOverflow where ownership of a post can change over time, depending on the edits. Has the intent of the post changed, or only its formatting corrected?

Your code is the Ship of Theseus.

]]>There is nothing quite as satisfying as wasting money on useless gadgets. One of my recent purchases was a dorky watch known as the Martian Notifier.

This is a nifty little watch that shows notifications on a small ticker at the bottom of the watch face. It has good battery

]]>http://akshaydewan.me/getting-endomondo-to-work-with-the-martian-notifier/fb87aae2-661c-480f-8b52-bbd9081b2f61Sat, 20 Jun 2015 09:27:12 GMTThere is nothing quite as satisfying as wasting money on useless gadgets. One of my recent purchases was a dorky watch known as the Martian Notifier.

This is a nifty little watch that shows notifications on a small ticker at the bottom of the watch face. It has good battery life - lasts about a week - and the watch battery is separate, which lasts for a couple of years. The best part about it is that it actually looks like a watch!

The watch is really quite simple - install an app on your phone, select the notifications you want to receive, and the notifications will be pushed to your watch.

Now coming to Endomondo, the popular running app. Wouldn't it be nice if my watch would show me my current pace during my runs? Well, too bad! The Martian is compatible with few other running apps, but not Endomondo. But Endomondo does provide support for other devices like Pebble and a few others.

With a bit of APK decompilation, looking at Pebble's source code and a bunch of common sense, I could figure out how Endomondo talks to Pebble. It just uses an Android broadcast.

Endomondo ---(Broadcast)---> Pebble App ---> Pebble Watch

And well, I could listen to that broadcast!

Endomondo ---(Broadcast)---> My App ---> Notification

And so I wrote a nice little Android app that listens to the broadcasts that Endomondo sends Pebble, and I convert it into a Notification. And it shows up on my watch! Woohoo!

Now time for some field testing.

I never realized that it's so difficult to look at the tiny text on your watch when you're running. I got a few strange readings with some extremely high/low pace values, but on an average, the values seemed to be matching Endomondo's logs.

The watch has a sensor that detects when you tap the watch face. You can tap the glass to dismiss alerts or show the last alert. Unfortunately, the sensor also gets triggered when your hands move while running. This turned out to be a major usability issue, along with the tiny text that's hard to read when you're running out of breath. Well, it's a good testament to the fact that your software never works the way you imagine when you release it into the real world.