New Metra schedule for Simplenote

As I mentioned last November, I have plain text versions of the Metra commuter rail schedule between Chicago and Naperville (where I live) saved in Simplenote. Metra made some changes to the schedule this week, so I updated and decided to make the files available in a GitHub repository.

On the iPhone, the schedules look like this:

Because Simplenote uses Helvetica, a proportional font, and doesn’t have adjustable tab stops (even if it did, there’s no tab key on the iPhone for entering them), the columns don’t line up perfectly, but they look OK. Until the iPhone gets a decent monospaced font, this will have to do.

There are six schedule files in the repository:

  1. Eastbound Monday through Friday
  2. Eastbound Saturday
  3. Eastbound Sunday
  4. Westbound Monday through Friday
  5. Westbound Saturday
  6. Westbound Sunday

Also in the repository is a Python script, metra.py, that I wrote to reformat the schedule times from the way they’re presented on the Metra web page.

I copy the schedule times from the box and paste them into a text editor. Generally, I get something that looks like this,

  08:40  10:40  12:40  02:40  04:40  06:40  08:40  10:40  12:40
Naperville  09:37  11:37  01:37  03:37  05:37  07:37  09:37  11:37  01:37

which some extra stuff at the beginning of each line that needs to be deleted to make it look like this:

08:40  10:40  12:40  02:40  04:40  06:40  08:40  10:40  12:40
09:37  11:37  01:37  03:37  05:37  07:37  09:37  11:37  01:37

Then I copy those lines and execute

pbpaste | python metra.py | pbcopy

which puts the reformatted schedule,

  8:40a            9:37a
10:40a          11:37a
12:40p            1:37p
  2:40p            3:37p
  4:40p            5:37p
  6:40p            7:37p
  8:40p            9:37p
10:40p          11:37p
12:40a            1:37a

onto the clipboard. It looks weird here, but that’s because you’re seeing it in a monospaced font, not Helvetica. Finally, I paste the times into the Simplenote webapp and do some minor editing. This usually consists of

Here’s metra.py:

 1:  #!/usr/bin/python
 2:  
 3:  import re
 4:  import sys
 5:  
 6:  # Collect the two rows of data.
 7:  start = sys.stdin.readline().split()
 8:  stop = sys.stdin.readline().split()
 9:  
10:  # Change leading zeros to two spaces.
11:  start = [re.sub(r'^0', '  ', s) for s in start]
12:  stop = [re.sub(r'^0', '  ', s) for s in stop]
13:  
14:  # Print the data as two columns, using a simple heuristic for am/pm.
15:  ap = 'a'
16:  for i in range(0, len(start)):
17:    if start[i][0:2] == '12':
18:      if ap == 'a':
19:        ap = 'p'
20:      else:
21:        ap = 'a'
22:    
23:    print ' %s%s          %s%s' % (start[i], ap, stop[i], ap)

The AM/PM test is in Lines 17-21. This works pretty well for the Naperville-Chicago schedule and would probably be OK for other schedules, too. I thought about writing a routine that would work in every case, but it just wasn’t worth the effort. With this simple test, I only had to change a few as and ps.

If you’re a Simplenote user who lives in Naperville, the schedule files are pretty handy as is. If you’re a Simplenote user who lives in another town on the Chicago-Aurora line, or on another Metra line entirely, you can use metra.py to create your own Simplenote files.

If you’re not a Simplenote user, you should give it a try. It may be that Jesse Grosjean’s Dropbox-syncing suite of programs will end up working more smoothly, but until that happens, Simplenote is leading the pack.


5 Responses to “New Metra schedule for Simplenote”

  1. jiyq says:

    Do we know if Jesse Grosjean’s new app will have a monospaced font support?

    Also I wish we could host Dropbox on our own severs

  2. jiyq says:

    What would also be brilliant is if you swapped your site to use MathJax as soon a possible.

    It is not possible to install tex fonts on every computer I view this site on and without them, its horrible.

  3. Dr. Drang says:

    I’ve been looking into MathJax for a while, but I’m not ready to jump just yet. Because it doesn’t use <span> and <div> tags to enclose the equations, I’ll have to change the customizations I made to PHP Markdown Extra to fit MathJax without screwing up my older posts.

    I occasionally look at the site with the TeX fonts disabled. It’s somewhat slow loading, but I wouldn’t characterize it as horrible. Can you email me some horrible screenshots and tell me the browser you’re using?

    Update I just looked again and saw that minus signs weren’t appearing when using image fonts with the default scale of 110%. I bumped the default scale up to 120%, and the minus signs reappeared. If you don’t like 120% when using TeX fonts (I don’t), you can change the scale to whatever you like by clicking the jsMath button in the bottom right corner and changing the scale option in the control panel.

    Also, this comment thread would be better placed in an article that uses jsMath, but since you started it here that’s where I replied.

  4. jiyq says:

    I’m sorry the whole proportional font thing reminded me, that is why I posted here, in hindsight not the best idea.

    Its a pity that it requires a rewrite of your customizations to your system to get it to work. ( The bit here on convertion from jsmath here is no help?)

    The main frustration is I get this obtrusive message every time. It it messes up scrolling once it appears (Page does a tiny scroll when it appears)

    “No jsMath TeX fonts found — using image fonts instead. These may be slow and might not print well. Use the jsMath control panel to get additional information.”

    Also sometimes, on a computer with TEX fonts installed, I get minor errors with the rendering, (I’ll try to get screen shot next time)

    I’m being very fussy here and I just like to stress how much I enjoy your site.

  5. Dr. Drang says:

    I have read the conversion page you linked to and at first blush it seemed like the switchover would be fairly simple. There are, however some problems with IE (what a surprise) and how it handle spaces around the <script> insertions that MathJax uses. I want to make very sure I know what I’m doing before making the change.

    I’ve been following MathJax development for a while, and I will make the switch. But I’m taking it slow.

    Nothing wrong with being fussy. I’m limited in how many OS/browser/font combinations I can test, and I want the site to look decent on as many as possible. When it looks bad, I want to know where and how.