Multiple expression if statement in BASH
It’s not very well documented, but it’s possible to include multiple conditional expressions in a single if statement in BASH. By multiple conditional expressions, I mean something like:
if foo = 1 or bar = 3 or abc = 4 then
print Hello World
end if
You can do boolean OR in BASH by using the -o operator. The following is the above code written in BASH:
if [ $foo -eq 1 -o $bar -eq 3 -o $abc -eq 4 ]; then
echo Hello World
fi
For boolean AND, use the -a operator. You can also intermix the two.
- none
Posted on November 21st, 2006 in programming - 5 Comments »
Future Toronto Transit Map features
Now that my Toronto transit map contains many of the features I envisioned when creating its predecessor, it’s time to think of new features I would like to add. What follows are whatever features I can think of. Most of these are pretty zany, involving tedious work, but who said a feature request list had to be realistic?
- GO Train stations and addresses.
- Link generation for a search result so that searches can be bookmarked.
- Optional rendering of station names and info on a separate layer.
- Listing of adjoining surface routes for each station, with link to the schedule for that route.
- Surface routes, subway and train lines on their own layer along with the option to select which layers are displayed.
- Clickable bus and street car line markers which bring up the TTC web page for that line.
- Clickable bus and street car stops which link to the corresponding page on the TTC website.
- Rendering of station entrances.
Of these features, the first five seem to me to be a good combination of usefulness and feasibility. The other three require either large amounts of time and/or the usage of a GPS receiver.
Which features would you like to see?
- none
Posted on November 19th, 2006 in transitmap, ttc - 17 Comments »
New tiles for the transit map
Based on a user comment on the new map, I have added another zoom level to the Toronto transit map. I didn’t do this before because Illustrator wouldn’t let me export a large enough image to PNG, in this case 13794 by 8192. Instead I exported the image in two parts and collated the resulting images using ImageMagick. The detail on that zoom level is high enough so that the names of side streets are now visible.
In addition to adding the higher zoom level, I also re-rendered the tiles for levels 3 and 5 as the scale on the line strokes was off. Surprisingly, this resulted in a 50% bandwidth savings for the level 3 tiles so they should download a little faster now.
To further increase download speed, I have spread the tiles over four domains based on the recommendations of a study on optimising page load time. Incidentally, Google’s map tiles are also spread out over four domains and I coincidentally chose the same simple algorithm.
- none
Posted on November 17th, 2006 in transitmap - No Comments »
Too late for an open source Java
After years of promises and speculation, Sun finally made Java open source. All I can say is that it’s much too late. Sun has made some poor design and engineering decisions over the past few years which will continue to bite Java developers in the ass. I can’t begin to tell you how much I cursed Sun’s developers over the years, most notably a few years ago when I was working with their NIO library, first in 1.4.1 then in 1.4.2 and finally in 1.5 trying to make sense of their API and their subsequent changes. I’d go into detail, but then I’d get cranky.
Would an open source Java have made my life easier during those frustrating times? Probably. Twisted Python, upon whose protocol interface I based my Java NIO sockets API, is under an MIT license and kicked Java’s ass with respect to non-blocking sockets at the time. The major advantage was, and still is, its slick design. You didn’t have to write much code in Twisted to get a non-blocking server socket running. I still have nightmares about Java’s implementation.
But all that is in the past. Open sourcing Java won’t make much of a difference to the future. Certainly, I don’t care. Thankfully, I left the Java world almost a year ago and am now working in happy Python land. I don’t miss Java one bit, nor do I miss its tools, without which programming would have been far slower. No, Java can die a slow death for all I care. I’m done with it. Hopefully.
- none
Posted on November 14th, 2006 in java - No Comments »
A lesson in properly closing <script> tags
Here I was thinking that my old TTC map was only helping a few dozen people a day. In goes my updated map and up go my visits by several hundred per day. It turns out that I was closing the Google Analytics script tag in the XML style (ie. <script .../>) and not as <script ...></script>. The culprit? IE, of course, which doesn’t support the former.
- none
Posted on November 13th, 2006 in programming, site - No Comments »