8 May 2015

Finding blog posts with broken links

How frequently do you end up with erratic HTML in your blog posts?  Not very frequently.  But if you do find your blog in such a state, how do you fix it?  I was playing around with my Picasa settings and in the process I managed to break all my album URLs.  All my albums now returned a 404.

I wanted to find all my blog posts that link to one of my Picasa Web albums and fix the broken links.  Unfortunately Blogger's search will only search the text of the posts, not the HTML.  What this means is that a post containing HTML like "<a href="http://picasaweb.google.com/mankis.pics/Pilgrimage2010>photos</a>" can be found by searching for "photos", but not by searching for "picasaweb" or "mankis.pics".  Like any self-respecting programmer, I decided I'd whip up a script that would do the searching for me.

To access my posts from a script I have two choices: use Blogger's API or get a dump of my blog by exporting it to a file.  API would be a good choice if I have to edit a great number of posts, but I only have to edit a few posts so I went ahead with the latter option.

If I pass the export XML file and the search string, my script would print URLs to edit posts that contain the string.  This is how I found all posts with links to a Picasa album:
% ./find_blog_posts.py \
     -b /tmp/blog-04-30-2011.xml \
     -s 'mankis.pics'
http://draft.blogger.com/post-edit.g?blogID=28645193&postID=5479412993915553873
http://draft.blogger.com/post-edit.g?blogID=28645193&postID=6291962710796224390
...
The script is available online if you want to use.

2 Jan 2015

A review of the year 2014

I am not much of a believer in “new years”. It’s just an arbitrary point in time which happens to be a round number (01/01). But, I like the fact you can think of this round number as a new beginning. Counting your blessings is a good thing, they say. I’m going to start this year by reminiscing on 2014 a bit.

If 2013 was when we bought a new car for our family, 2014 was the year when a car became my primary means of transportation. When I had to buy a car, the first thing I wanted was a BMW X3. Though I changed my mind later on after finding out the cost, I ended up getting an X3. Turns out, used cars are considerably cheaper. :-)

Getting this X3 was one of the good decisions of 2014
Before getting the X3, and for a while after getting it, I thought the X3 looked really nice. In a few months, I learned that irrespective of what car you have, you’d think of some other car to be nicer/better. I still wish I had gotten a Jeep Cherokee even though I know deep down that the Cherokee won’t be as refined as the X3, and the X3 is a better match for my needs.

By around the same time, I upgraded from Canon PowerShot S5, which had been my camera for about 6 years. I upgraded to Sony Nex-6 and got two prime lenses, thanks to guidance by +Karthik Nagaraj. I am so pleased with the quality of the images I took 3 to 5 times more pictures this year than the past 5 years. After a few years, I took pictures that I myself liked.
When I moved from Sydney, the most important goal I had in mind was to travel more. I started living outside India with the desire to travel, but I hadn’t travelled much when I was in Sydney. I wanted to change that with the move to California. Armed with my new Nex-6 and the X3, I travelled to a lot more places than I had originally planned.

2014 was my “year of broke” after having lived wealthy for several years. Often in 2014, I had much less money than I needed. It was all due to bad planning from my part, which made it easy to fix the issue. I can say I have a good hold on my monthly expenses now. 2015 might actually get better monetarily. Good times are ahead.

This was the year I bought my first non-Nexus Android phone. This was the year my much loved Toshiba Z830 laptop felt inadequate. It’s underpowered for running things like Android Studio. Has a 1366×768 screen, which is not pleasant to look at anymore. Sadly though, I just haven’t found a laptop in the market that’s worth upgrading to. Hopefully System76 will introduce a successor to their Galago Pro with a 4k display.

Here’s to a great 2015!

18 Dec 2014

First week with my Moto X

I have been using my Moto X for about a week now. Thought of recording some initial impressions.

About me
First, some background on me. I used the G1 when it came out. Ever since Nexus One, I have been using a Nexus phone. Except for Nexus 5, I upgraded to every single Nexus phone as it came out. Moto X is the first ever non-Nexus Android phone I have used.

Why Moto X?
I had been using a Nexus 4 since it came out in 2012. I wanted to upgrade to a newer hardware. I didn’t go with the Nexus 6 because it’s too big. Also, Motorola has a good track record when it comes to pushing new versions of Android more quickly than other OEMs. Getting updates quickly is critical to me.

A month or so ago, a coworker brought a 2014 Moto X with him. I held the phone for about a minute in my hand, and immediately wanted to get one myself. From MKBHD’s review, I learned the Moto X’s camera is not all that bad. Overall, Moto X satisfied many of my requirements, so I decided to buy it. (I got a $140 discount on the phone’s price, which was icing on the cake.)

Ordering the phone
Moto Maker is awesome. Designing and ordering the phone was a breeze. I got to pick and choose colours, which was amazing. All Nexus phones have an all-black front, but with the Moto X, I was able to get a white front... something I have always wanted.

Hardware
The phone is very fast. Surprisingly, Moto X boots a lot faster than its more powerful sibling Nexus 6. (Maybe it’s because of the Nexus 6’s encrypted storage, which is known to slow things down.) In my usage, I never had to wait for the phone; it was fast in everything it did.

The screen is gorgeous. Upgrading from Nexus 4’s dull screen, this is a pleasure to look at. I’d put this screen above the Nexus 9’s screen (the other Android I use on a daily basis). The camera is passable (sample pictures).

With the top and bottom looking almost the same, it’s kinda hard to tell if you’re holding the phone upside down. But you’d quickly learn to orient the phone correctly. The edges are metal, which made it uncomfortable to hold the phone while talking. Maybe this is another thing that I’ll get used to over time.

The phone does not have a stereo speaker like the Nexus 6, but it’s pretty loud. Notifications and phone calls are also much louder than the Nexus 4. Finally, I can hear when my phone rings in the next room. In-call sound clarity was also noticeably better than the Nexus 4.

Software
This is the first time I use a non-Nexus phone, so I wasn’t sure how Motorola’s software additions will affect the experience. So far, I have been fairly happy with what Motorola has chosen to add to the phone.

The phone has infrared sensors to detect when you reach for the phone. The moment I am going to grab the phone, screen turns on automatically. I never have to press the power button to turn the screen on. It saves maybe half a second, which may not seem like a lot. But it does matter because I know I am annoyed when my Nexus 9 doesn’t automatically wake up when I want to use it.

Similarly good is “shake to open camera” gesture. With my previous phones, I’d have to press the power button, open camera by sliding the lock screen, and then start shooting. Now I can simply shake without even having to look and the camera is ready. I really like it. The camera is supposed to capture more shots than the ones you take and suggest you to keep the better shot. I haven’t had the phone long enough to actually need that feature yet.

Possibly my most favourite feature is you can customize the “Okay Google” phrase and choose anything you like. I have never liked saying Okay Google, so this is a big plus for me. Speech recognition is good, and voice commands are useful. When I need to do something quick — like a unit conversion or adding a reminder — I turn to my phone and ask it to do it. No need to wake it up; no need to unlock the phone. It just works.

Motorola slowly teaches you how to effectively use the phone by showing notifications about new features every once in a while. It’s way better than dumping everything at you while setting up the phone.

Gripes
Nexus phones come with a dialer app that has two nifty features: you can search for local businesses from within the dialer and it does reverse business lookup when you are making or receiving a call. If I want to call Pizza Hut, I can type Pizza Hut in the search box of the dialer app and it’ll find local Pizza Hut’s phone number. Similarly, if Fedex calls me to alert me about a package, caller ID would show “Fedex” instead of the number they are calling from. Moto X does not come with this dialer, which is a bit of a letdown.

I am mostly used to it now, but I sometimes find the phone a little too large to hold and use. Especially when I have to use it one handedly.

Conclusion
Overall, I have been very happy with the Moto X. If you are on the fence on buying this phone, I’d urge you to just buy it. You may not even want to go back to a Nexus phone in the future. :)

4 Dec 2014

Skipping lines is for jerks

It’s been raining this week, so I have been driving to work since yesterday. Driving to work means I need to take the Shoreline Boulevard exit from 101N freeway. Turning right after the exit takes you to Google offices, while turning left takes you away from Google. Naturally, there’s a very long line on the right turn lanes while left turn lanes are almost empty.

When coming to work this morning, I thought I would turn left from the exit and then take a U turn after so I don’t have to wait on Shoreline exit. I had passed about half of the line on right-hand side lanes when I spotted a gap in the line. I squeezed in and started waiting in there. That’s when I realised I was being a jerk. Everyone in the line has joined at the end and moved forward slowly. Jumping the line and joining in the middle is impolite. We won’t do that where people stand on the line — they’ll give us a dirty look and quite possibly ask us to join the line from the end. But because they cannot do anything when everyone is sitting inside a car, it doesn’t suddenly become okay to not follow etiquette.

I felt bad enough to leave the right turn lane and go with my original plan. I took a left, took a U turn, and got to work. Maybe it took me a bit longer, but I don’t feel like a jerk. That’s a good thing.

21 Oct 2014

I'm a puppet

It's unbelievable how much my spirit depends on external events. Hearing good news makes me happy; hearing bad news makes me unhappy. Not in a shallow way, but in a deep, uncontrollable way.

Back when I was a kid, I remember reading stuff like "a yogi is someone who can be alone in crowd, and can be amidst people when alone". I understood what that meant at an exterior, shallow level. But when I see myself dancing to the tunes of external events, I realise how qualitatively different being a yogi is. I also see clearly how I'm nowhere close to being one.

Back in the days, when I read about the concepts of yoga, enlightenment, etc. I would think that I'm so close to attaining all that. Deep down I would know I don't even know what those words really mean, but I'd suppress that awareness with my desire to attain those ideals. But today, I see I'm way outside the league. I don't have much desire to attain any of it either. Now, I'm just amazed how much of a puppet I really am. Nothing more.