The Economist, and, The Kindle: Take 2

January 3rd, 2010

A while ago I had written about how you can get The Economist on your Kindle (and other e-readers) by running a simple PHP script that crawls the economist.com and generates a .mobi file that it emails it to your Kindle weekly. Unfortunately (though understandably), around July 2009 they locked out their This Week’s Print Edition website to only subscribers of their online and print editions.

With a little bit of work, I’ve updated the economist-to-kindle.php PHP script to handle logging into the economist.com’s website with your user-name and password so it can generate a Kindle version again:

https://github.com/nicjansma/economist-to-kindle

With this update, and if you’re a print edition subscriber, you should be able to get this week’s edition on your Kindle again.

Updated 2010/01/25: Several bugfixes, see comments for details.

Updated 2010/07/22: slifox and crosscode have made some great additions to the code and got it working with the Economist.com’s latest site structure. Check out crosscode’s latest version or read the comments for details.

Updated 2011/05/02: Based on crosscode’s latest version, I’ve updated the script on this site (https://github.com/nicjansma/economist-to-kindle) to work with recent Economist.com articles.

Updated 2011/07/26: Small update to work with the economist.com’s latest updates: https://github.com/nicjansma/economist-to-kindle

Updated 2012/01/04: I’ve moded this project to Github: https://github.com/nicjansma/economist-to-kindle. If you have any suggestions, find bugs, or want to contribute, please head there.

Todoist.com (and TodoistBackup.exe)

June 11th, 2009

After reading David Allen’s Getting Things Done: The Art of Stress-Free Productivity a few years back (great book!), I was inspired to change the way I managed my to-do list. For quite a while, I had been maintaining my lists of tasks, projects, and ideas in a discombobulated mess of sticky notes, whiteboards, todo.txt’s, Outlook tasks, and random files on my hard drive. I took some of the ideas from GTD and applied them in a way that worked for me. I settled on two technologies: a wiki (for notes, lists etc), and todoist.com for task management.

There are several good web sites and programs out there that aim to let you apply Allen’s GTD principals, such as Remember The Milk (RTM), Todoist, Toodledo, Outlook, Google Tasks, and even maintaining a todo.txt. One of my favorite blogs is Lifehacker, which is focused on GTD stuff, and has covered todoist.com and RTM as well as similar sites. They’ve published a book called Lifehacker: 88 Tech Tricks to Turbocharge Your Day and a sequel Upgrade Your Life: The Lifehacker Guide to Working Smarter, Faster, Better, that are both fun reads. There’s been a lot of activity around GTD since the book was published, and many websites and apps attempt to provide a seamless way for people to manage their life in a GTD way.

After test-driving a few of the GTD web sites and programs, I settled on one that I’ve been using for 100% of my task management over the last three years: todoist.com. Todoist is a simple, Ajax’y site that allows you to organize your tasks in different projects:

Todoist.com

You can nest tasks and projects, prioritize, tag, colorize, and set absolute and recurring due dates. The interface is dead-simple and very quick. In the three years that I’ve been using the site, there’s only been a few moments of downtime. It manages hundreds of my tasks (all prioritized!) with ease. I honestly think I worry less these days, knowing that all of my tasks and projects are neatly organized. Yes, I am often slightly OCD.

However, I had a big concern that Todoist, which now stores 100% of my tasks, may disappeared without a trace some day. Luckily, Todoist provides a simple JSON API for retrieving all of your projects and tasks. With this API, I was able to build a simple C# app (TodoistBackup.exe) that does daily backups of my Todoist data, just in case Todoist were to ever disappear unexpectedly. (What to do with the data is another question entirely, but I’m sure I could deal with a text file until I found the time to write a replacement… 🙂 ).

The program I created is called TodoistBackup. I am utilizing a C# library from James Newton-King called Json.NET to interface with todoist.com’s API, and save the output into XML. The program is dead simple to use: you simply specify your API “token” (basically a unique ID for each login, so you don’t have to share your username/password), and the output XML file name. For example, this command line saves my tasks to an XML file with today’s date:

TodoistBackup.exe [api token] "tasks-%date:~10,4%%date:~4,2%%date:~7,2%.xml"

The XML looks like this:

<todoist>
    <projects>
        <project Id="1" UserId="2" Name="Fun">
            <items>
                <item Id="1" UserId="2" ProjectId="1" Content="Have fun" />
                ...
            </items>
        </project>
        ...
    </projects>
</todoist>

The conversion from JSON to a XML archival format is incredibly easy in C# using JsonSerializer and XmlSerializer attributes. Check out how nice this is:

    /// <summary>
    /// Todoist project
    /// </summary>
    [JsonObject(MemberSerialization.OptIn)]
    [XmlRootAttribute(ElementName = "project")]
    public class TodoistProject
    {
        /// <summary>
        /// Initializes a new instance of the TodoistProject class.
        /// </summary>
        public TodoistProject()
        {
            Items = new List<TodoistItem>();
        }

        /// <summary>
        /// Gets or sets the project's Id
        /// </summary>
        /// <value>Project's Id</value>
        [JsonProperty("id")]
        [XmlAttribute]
        public int Id
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the user's Id
        /// </summary>
        /// <value>User's Id number</value>
        [JsonProperty("user_id")]
        [XmlAttribute]
        public int UserId
        {
            get;
            set;
        }

Very clean!

The program and source code for TodoistBackup is available on Github. If you have any suggestions, find bugs, or want to contribute, please head there.

Let me know if you use it!

The Economist, and, The Kindle

April 13th, 2009

For the last two years, I’ve been taking the bus to work — there’s a stop a block away from my house, with a direct route to the front door of my workplace.  One of the many things I’ve enjoyed about commuting via the bus is how much free time it gives me a week to read or listen to music.  I’ve always been a reader of books and magazines, but over the past few years the number of books I’ve finished has dwindled due to a lack of free time.

With the extra 5 hours of reading a week during the bus ride (a half-hour ride to and from work), I’ve been able to finish more books than I would otherwise, as well as keep current with some of my favorite magazines.  I started reading The Economist on and off during college, and I recently took the plunge and purchased a print subscription.  Which is no small commitment, as the best prices you can find for a print subscription are over $120 a year.  You can potentially get a subscription for $77 a year if you’re a student, which is an amazing deal: something that, after subscribing to the print edition for a year, I’d heartily recommend to anyone who qualifies.

I recently stumbled upon something amazing: the current week’s full print edition is available, online, for free: this week’s Economist print edition.  Reading past editions requires a paid economist.com subscription, which carries a decent yearly fee.  But this week’s edition is completely free.  I’m not going to gush anymore over how much I enjoy reading The Economist, but to say, that if I only subscribed to one magazine, The Economist would be it. (I also subscribe to Business Week, Wired and others).


After a lot of research, I also decided to purchase a Kindle 2.  I’m in love with it. It’s so tiny, which is wonderful for reducing the amount of weight in books and magazines I was carrying to and from work before.  I’ve been able to expand the range of books I can read on the bus because some of them (text books, Harry Potter, SciFi award compilations, etc) are just too darn thick to lug back and forth!  My Kindle has a dozen of my in-progress books on it right now.

Unfortunately, as of right now, The Economist isn’t available on the Kindle.  After scouring the ‘tubes, I came across a big customer request discussion on Amazon.com.  Looks like hundreds of people want the same thing.  There are also rumors flying around that something’s in the works from The Economist, but nothing substantial yet.

More scouring found KindleFeeder.com (free for most users), which has a feed for The Economist articles, as well as Calibre, which is a really cool e-Book manager.  Calibre will automatically download the Economist print edition, and convert it to a format for your Kindle or similar reading device.

My searches finally brought me to this post on the blog Fat Knowledge, which was exactly what I was looking for: a PHP script that downloads the print edition from economist.com and converts it to Mobi format, which the Kindle can read.  A table of contents is generated, and full text and images from articles are available.  Really cool!

Since the source was available, I also customized it a bit to my needs:

  • emails my kindle (xxx@kindle.com) the resulting .mobi, so I get Thursday morning delivery of the latest Economist (via cron)
  • reformatted the PHP a bit, to better help me understand what the script was doing

Original source code from the Fat Knowledge blog is available, as well as my updates here:

economist-to-kindle.php at Github

After reading The Economist on my Kindle for a few weeks, I do find myself going back and forth between the Kindle format and the dead-tree edition.  There’s something about the magazine format that will probably get me to renew my print subscription for another year or so.  But it’s nice to also have it on the Kindle, especially a day or two before the print edition arrives!

Note: Depending on where you will run the script, you will also need MobiGen for Linux or PC.  The PC version is available from MobiPocket’s /dev/ website.  For some reason, their Developer website no longer links to the Linux version.  I eventually found a random link that has the Linux version on the ‘tubes (though I can’t remember where), so here is mobigen_linux v6.2 build 41 if you need it.

Update 7/9/2009: Amazon announces that The Economist is (officially) available on the Kindle, albeit at the full newsstand price ($10.49/mo) — more expensive than any other magazine available for the Kindle. Do they really expect people to pay full price for a digital edition? The Kindle edition is getting a ton of 1-star reviews because of this — hopefully this sends a message to Amazon/The Economist that they need to lower their price to be more competitive.

Update 1/3/2010: A new version of the script has been posted that uses your economist.com’s login credentials to get this week’s Print Edition. If you are not a subscriber to the online or print editions, you won’t be able to access the website.

b2evolution 0.9 to WordPress 2.7 Migration Script

April 1st, 2009

For the previous 5 years, nicj.net ran on a blogging platform called b2evolution, one of the hundreds of CMS (content-management systems) available.  b2evolution was pretty revolutionary for its time, and worked good as a platform in 2003.  Over the years, the version I had been running (0.9) became rather old and out-dated.  There were probably a few unpatched security holes in the version I was running, but I was getting frustrated at paying the “upgrade cost” to keep my website up-to-date with the latest releases.  Each new release took time to upgrade and invariably caused problems that I would have to spend time debugging.  Lately, there was a big problem with comment spam, which can be annoying to keep on top of.  b2evolution doesn’t have a good solution to reduce comment spam, whereas several newer blogging platforms use Akismet to help fight it.

So over the last year, I’ve been looking for a new blogging platform.  WordPress is the successor I chose.  WordPress is similar to b2volution (both spawned from the same parent), but what impresses me the most about WordPress is how clean the interface feels and how powerful the blogging platform is with all of the community plug-ins available.  Upgrades are seamless as well (as simple as a subversion ‘update’ command).

The problem was what to do with all of the old posts on nicj.net in the b2evolution MySQL database.  Not that anyone cares what I wrote during my junior year of college, but I was hoping to at least be able to archive some of those old posts as ‘private’ so I could have a journal that I could look back to at a later date.  I was sure someone had done b2evolution to WordPress posts/comment/users migration before, and sure-enough, there are several scripts out there:

The problem is, each script has its caveats: migrating from a specific b2evolution version to a specific WordPress version, and each has their own incompatabilities with my situation.

I finally settled on one from tumahler.com, and modified it a bit to suit my own migration needs.  Changes are:

  1. Supports b2evolution 0.9 to WordPress 2.7 migration
  2. Script can read from one b2evolution MySQL DB and write to a different WordPress MySQL DB
  3. Migrates posts marked as b2evolution private to WordPress private
  4. Sets categories for posts
  5. Only posts and comments are migrated (not users, metadata or categories)

So I’m adding my script to the mix of publically available b2evolution -> WordPress migration scripts, in case it will help anyone:

https://github.com/nicjansma/migrate-b2evolution-to-wordpress (b2evo 0.9 to WP 2.7 tested)

Please note: Only use this on a clean WordPress install, as it will delete any WP posts, comments and metadata before the migration of b2evo data.