Author: nigelb

  • Fun in Delhi

    I’ve spent the last month in Delhi, mostly having fun and spending time with friends. Remote working does have the advantage that I can work from anywhere as long as there’s power and an Internet connection. I’m not a very touristy person, but here’s a few places I visited out of peer pressure and curiosity.

    CR Park

    I found Diagon Alley!

    If you have a Bengali friend in Delhi, the chances are quite high that you have been dragged there (er, convinced to visit). In total, I went there 3 times during my stay and each time, I found the food spectacular. More amusing is the feeling that I’m not in Delhi anymore. I hear Bengali everywhere. My friend feels right at home and talks to the shopkeepers in Bengali. The shopkeepers even talk to me in Bengali (I just end up keep a blank face)!

    Daryaganj

    Books. More Books. And even more Books.

    The streets are filled with books. It felt like Blossoms, but on the street with no air conditioning. Overall, I found less fiction and a lot more study guides and the like. There are strategically placed ATMs all around the street, so in case you over-purchase, you can always withdraw more money. The only enemy is the heat. By the time we finished shopping, I was thoroughly exhausted and thirsty. We ate at the restaurant that claims to have invented butter chicken (Not all that much spectacular).

    Old Delhi

    I couldn’t go back home without meeting Prateek and Souvik of Miranj. We decided to go to Old Delhi on a food walk, and luckily we were all non-vegetarians. So, one Friday evening, we took the (very crowded) Yellow line to Chawri Bazar. I took a while to process the streets after getting out of the metro. Crowded streets, cycle rickshaws, and very narrow roads were the norm. To add to the “fun”, there were a bunch of bikes, honking loudly.

    There were 6 of us and the plan was to visit 4 or 5 places, ordering food for one person at each place. We started with a place with pretty great buffalo meat. It was spicy and very juicy. We were headed to a place with Kheer next, but they’d run out! At the next stop, we ordered a full fried chicken. Then, it was a mutton curry. The last stop had beef fried rice (…heaven!).

    After the main course, we had to have dessert. Souvik and Prateek knew a Kulfi place with a wide variety of flavors. I don’t remember all of them, but to give an idea: Jamun, Paan, and Anaar. I can’t remember the other flavors, but we were fighting for a few of them 🙂

    Something I noticed while we were there was the gender ratio. There were very few women walking around in the streets. Probably less than 25 during the entire trip. And the streets were extremely crowded.

    Rongali Bihu

    Rongali Bihu celebrations

    I learned recently that the Assamese New Year’s is around the same time as the Malayalam New Year and Bengali New Year. On the Sunday after the New Year, we went to an event organized by the Assam Association. I had a bit of a flashback of growing up in the middle east. There was no sitting room once the program started and everyone was enjoying being with people who spoke their language.

    Before the event started, we had “lunch” (at 5 pm :P). It wasn’t Assamese food, but more of a generic North Eastern meal. There was pork involved (need I say more?). After we were sufficiently fed, we walked around to discover a Nirbhaya Multiple Expressions exhibition next door. We got back just in time for the cultural programs to start. As usual, it started off a bit boring and then got better. The most fun was a dance by the little kids. They looked very adorable dancing in saris.

    Overall, I seem to have gotten a wide range of experiences in this trip. There’s more to do and see, but then I’m incredibly lazy to step out 🙂

  • meta-q-override is now warn-before-quit

    I wrote an add-on a while back that would catch Cmd+Q and show a screen asking for confirmation before actually quitting. I got tired of quitting Firefox one too many times.

    It used to be called meta-q-override, I’ve now renamed it to warn-before-quit. As always, please file bugs for issues/feature requests.

  • Git Tips You Probably Didn’t Know

    I’ve been using git for quite a while now and some of it’s features continue to amaze me. Here’s a few things I learned recently.

    Finding only your changes to master.

    When you’ve made a change against a master that’s moving often, you find that simply doing git diff master doesn’t give the right diff. It shows you the difference between your branch and current master. That’s not what you want in most cases. The master branch would have changed and now the command also shows those changes. GitHub does the right thing and the right command in this case is the following:

    git diff master... 

    Copying your changes in one branch into another

    Recently, our designer Sam Smith started working on making CKAN more responsive. His Branch was based off master and I wanted to make a new branch based off release-v2.2 with his changes on top of it. My instinct was to make a patch.

    git diff master...responsive > ../responsive.patch 

    Then, apply the patch onto a different branch. This would surely work, but I’m using a version control system! It should be smart about this. The good folks in #git pointed me in the right direction.

    First find the last commit from the responsive branch that you don’t want to copy.

    git checkout responsive git log master..responsive 

    The last commit in that log is what you want to copy. In this case, it’s 7587c6e8fe49c809ef7357b6f88496bd06ac93b9, so now you want to do git log 7587c6e8fe49c809ef7357b6f88496bd06ac93b9^. The first commit is the one you don’t want to keep.

    git checkout responsive git checkout -b reponsive-2.2 git rebase 7587c6e8fe49c809ef7357b6f88496bd06ac93b9 --onto release-2.2 

    Thus, responsive-2.2 is a new branch with responsive changes based on top of release-v2.2!

    The more you know
  • Dharamshala Getaway

    We ran with our luggage. None of the buses at ISBT were to Dharamshala. Just as we were about to give up hope, a guy said, “It’s just started from the platform and is near the gate. Run and you can catch it.” More running and I got there just as the driver was about the close the luggage doors, just in time to get our luggage in and get in. I still can’t believe we actually caught the bus. This vacation definitely started on an exciting note.

    I woke up to scary, but beautiful mountains all around us. The fear was definitely ecause of how our driver drove the bus like a bike, squeezing into tight spots (you have a dirty mind…) band (seemingly) barely using the brakes. After we got to Dharamshala, the bus driver seemed extremely careful, because our taxi ride to Naddi, where we booked a cottage, was scarier. We did that trip several times during our stay and every single time I was convinced, we’d meet with an accident on a hairpin turn. The drivers in these mountains seem to have missed that lesson about honking on a blind curve, or at least slowing down a bit.

    View from Naddi

    Staying in Naddi had its downsides and upsides. We had a spectacular view and the only noise we could hear were the sparrows at the doors and the kids playing cricket in the small ground behind us. It was also a bit far from everything and we would be charged Rs. 200 to McLeodganj or Rs. 300 to Dharamshala. After we caught up with sleep on the first day, we walked around and saw the sights in Naddi. We thought about going to a waterfall nearby, but we were told it probably wasn’t worth it. We walked down to the Dal Lake instead. Now, it’s only 2 km away, but in retrospect, I’m not sure it was a good idea. We learned that we’re both not in good shape and walking downhill is actually harder. Dal lake is beautiful and quiet. We sat there for some time resting our feet and catching our breath enjoying the view.

    The climb up and walk back to our rooms thoroughly exhausted us. The next morning, we went down to Dharamshala. After lunch, our plans were to visit the Infinity Hackerspace. It was quite the bus ride and then a “20 minute walk” which took us 40 minutes. The view from there is just spectacular. It looks as though the mountains are just another walk away (of course, it’s not). I spent the afternoon chatting to sva and planemad about their life there, internet woes, and renewable energy. We started heading back after an hour or two long stay there. This vacation definitely included more exercise than I get with my daily life (I think life is trying to tell me something :P).

    The next day was our last day in Dharamshala and it was reserved for McLeodganj. We had the most physical strain on this day because we took the wrong turn to the temple and ended up going down quite a bit and climbing up an even stepper slope. But hey, we finally got there! The Tibetan museum in the complex was eye-opening to the problems of the Tibetan people and their conflicts with China. We seem to never get a clear picture of this conflict. On the way back, we did some shopping and got something to eat.

    Another view from Naddi

    While we were eating lunch, the sky outside was clear and it was a slightly chilly day. Right after we finished lunch, visibility outside dropped to less than 50m and suddenly the whole placed had a magical feel. Just as suddenly as it came, the clouds vanished and it was back to normal. I’ll remember that moment though, when the restaurant and the square seemed empty for 5 minutes. I couldn’t even see across the road.

    Overall, this was a thoroughly enjoyable vacation. It taught me that I’m completely out of shape physically and I’ll need to do something about it 🙂

  • Better Problem Definition

    I’m a core developer on CKAN at Open Knowledge, the most widely used data catalog software. Early this year, we released version 2.2 of CKAN with a complete overhaul of the filestore. Amusingly, right after that, we started getting more and more complaints about data loss from the old filestore from on the ckan-dev list. One of the many folks, helped narrow it down to a particular file called persisted_state.json.

    This file is created by a library called ofs. Every time a new file is added to the filestore, OFS does the following:

    • Read the persisted_state.json file.
    • Convert the JSON to a Python dict.
    • Add an element to this dict with the metadata of the new file.
    • Convert the dict back to JSON.
    • Write this new JSON to persisted_state.json file.

    This causes concurrency problems when things were added to the filestore at high frequency and eventually lead to data loss. Oh joy.

    Technically, this wasn’t a bug in CKAN’s codebase. We already solved the core problem at this point by switching to a new filestore which did not use ofs. We couldn’t abandon our users though and I volunteered to find a fix. I read through ofs code and I thought of solving the problem there. After an hour or two of reading up on concurrency and documentation on the python, I still didn’t have a working solution. Eventually, I asked myself what I was looking to solve.

    My original problem: “OFS is not thread-safe, causing data loss”. I then realized, that’s not what I wanted to solve. A better problem to solve was: “OFS is not thread-safe, causing data loss. Our users need their data.”. So, I wrote a script that would re-generate the persisted_state.json file with just enough metadata to start working. It isn’t a complete fix, but it was a productive fix. The script was “dramatically” called ofs-hero.

    Lesson Learnt: Defining the problem properly helps you solve it better.