login
v2
v1

jmoiron.net

Welcome to my blog. You may view older entries via list navigation, view posts sorted by topic, or see them arranged by date.

Cheesy color console output

posted January 20th, 2010 @ 00:09:34

- tags: python

- comments: 0

Since Audacious crashes in Ubuntu 9.10 when playing NSF files, I was compelled to compile a newer version for personal use, and I noticed that their build system is tricked out with very little extraneous geek-cred output and some colored output. I have been writing lots of little one-off bulk job scripts lately, and when I realized the answer to the question "Why don't I do this?" was "I don't know how", I decided to do some google jump roping and figure it out.

I've been playing around with my PS1 recently and had some idea of what I was looking for. Of course, the answer can always be found on PyPi and the termcolor seems like it'd do quite nicely. However, for the simple uses I required, 3 little lines of python were enough:

white, black, red, green, yellow, blue, purple = range(89, 96)
def color(string, color=green, bold=True):
    return '\033[%s%sm' % ('01;' if bold else '', color) + str(string) + '\033[0m'

For quick one off jobs, this is probably all you need. The termcolor module is a good bet if you are going to be writing lots of these, as import termcolor is obviously shorter still, and it is less likely to break dramatically and illegibly on stranger software configurations.

On-Suspend scripts in Ubuntu 9.10

posted January 7th, 2010 @ 19:25:47

- tags: general tech

- comments: 0

My thinkpad works pretty well in Ubuntu 9.10, but one thing thing that is not fixed is that my wireless ceases to function when I resume. If you remove and reinsert the kernel module for it, it will work again. Back in the day, you'd put this in /etc/apm/resume.d/, or more recent, in /etc/acpi/resume.d/, but as with other seemingly fine technologies Ubuntu has recently deprecated ACPI. The new location for the script is /etc/pm/sleep.d/.

As before, when your computer suspends, the script is called with "suspend" as the first argument, and when you resume, the script is called with "resume" as the first argument. Here's a quick script that did what I want, easily adaptable to your need:

#!/bin/sh

case "$1" in
    resume)
    modprobe -r ath_pci
    modprobe ath_pci
    ;;
esac

Third World

posted December 15th, 2009 @ 09:14:53

- tags: life

- comments: 0

Every time I go to Asia, it gets harder and harder to come back. Landing at Newark "Liberty" International Airport via Hong Kong's airport feels like travelling to a third world backwater.

The ride to the Hong Kong Airport takes you across multiple attractive suspension bridges. Or you could have checked in your baggage at the Tsim Sha Tsui or Central train stations and taken a train directly to the terminal. The departures terminal (all flights are international) is large, spacious, and clean, with gratis luggage trucks. You take off surrounded by new (by US standards) high rise buildings and the beautiful nature enveloped mountains of Lantau Island.

You land in the US at the massive concrete sprawl of Kennedy Airport, or in the shipping container fields and chemical waste swamps of Elizabeth, NJ. You walk out into a room where you wait on line (even if you are a US citizen; there's never a line for Hong Kong residents in HK), and you undergo a biometric check (eye scan and finger print). You fill out a card detailing what you've brought, which is then stamped (after one line wait) and then ignored and placed in a pile in customs. The documentation creates lines that wrap around the baggage carousels, which are in a low-ceilinged dingy room where cell phone usage is prohibited. Last time I bothered to check, the baggage trucks carried a fee.

If you're lucky enough to leave the airport in a car, you're taken to your destination either via the perpetually congested Van Wyck, the congested route 1&9, or the toll road GSP. If you're unlucky enough to be taking the trains, JFK will charge you $5 to leave the airport, and then you're stuck out in the boonies waiting for a subway. At Newark, you ride a (free, if I recall) airport rail out to an NJ transit station, then make a (non-free) transfer somewhere on the line to a path train, then (probably) another non-free transfer onto the NYC subway.

The differences aren't really for lack of cash; certainly if there's a metropolitan area in the US that can compare with the economic output of Hong Kong it'd be the New York one. This kind of difference in the quality of service is pretty pervasive; it's not just in public transportation. The evidence seems to suggest that in the US, competing private interests with ulterior motives are given sway over these public services, whereas in Hong Kong they operate under one consistent vision.

Why don't we have one convenient method of rfid debit payment in the NYC metro region that I can use in busses, trains, kiosks, etc? Why isn't there one (cheap) rail line that seamlessly connects the subway and the airports? How can the MTA still be leaking money while providing increasingly poor service at dirty, run down stations? Provided there was a clear vision and a decision to solve these problems, I can't imagine that we would lack the resources to do so. The collective reluctance to do so, say, because of the impact it'd have on private enterprise operating in those spaces, or because of power plays between unions and corporations, is the reason why I am not very optimistic about it getting fixed any time soon.

iPhone wifi timeouts

posted November 21st, 2009 @ 14:33:05

- tags: general tech

- comments: 0

I finally got sick and tired of my iPhone disconnecting from wifi when locking, not actively in use, or feeling unloved, and did some research this weekend. There seems to be two issues that are not easily overcome:

read the rest of "iPhone wifi timeouts"

The joys of racing

posted November 3rd, 2009 @ 02:02:05

- tags: life , games

- comments: 0

I'm not quite sure how to initiate this discussion. I know that it was initiated for me by the recent release of the [Forza 3] racing sim, but it's something that has been on my mind for years. As someone who used to prefer the cheap thrills and pure raw adrenaline of arcade racers, I know what it's like to bemoan a game filled with cars that "won't turn."

read the rest of "The joys of racing"

Things I wish Google Chrome had

posted October 23rd, 2009 @ 22:42:02

- tags: general tech

- comments: 0

I've used Mozilla's flagship browser since before Phoenix, the first version of Firefox, existed. Been using Chrome on Linux for a few months now, and I've mostly moved my day to day habitual browsing to it. Although there are some "Linux just seems to suck at doing this still" issues, like having audio always just work, they aren't unique to Chrome. Still, I've found a few things that I miss from Firefox, or I wish chrome would do given its additional features.

read the rest of "Things I wish Google Chrome had"

Wikis and the False Promise of Documentation

posted August 20th, 2009 @ 23:57:18

- tags: general tech

- comments: 0

In order to offset the increased monthly costs of my new phone, I recently decided to migrate one of my two dedicated servers to a VPS. After mulling over bargain basement offerings and some major ones, I decided on linode. I figured that most of the services I run on my weaker dedicated server (mail & webmail, DNS, etc) would live as happily on a $20/month VPS as they would on a $65/month dedicated server, and although I've had a long time to start the switch, I commenced last night (with 10 days remaining) by moving my wiki and my dev site.

read the rest of "Wikis and the False Promise of Documentation"

Good Presentations in Linux

posted August 5th, 2009 @ 00:21:37

- tags: general tech

- comments: 0

Been looking at ways to write attractive presentations half-way semantically in Linux. The "semantically" there is important; I want things to just generally look alright without having to agonize over bullet style. Two things sort of led me to S5: the sorry, sorry state of affairs of creating presentations in Linux, and Ian Bicking using S5. These are somewhat related.

read the rest of "Good Presentations in Linux"

Brave Old World of Proprietary Software

posted July 21st, 2009 @ 01:01:55

- tags: general tech

- comments: 0

I finally buckled down and got an iPhone recently. I had a lot of reasons for getting a phone I can't readily write applications for (without jailbreaking); among them: I need my phone outside of apps, so I can't have something that I am breaking constantly; I want a GSM carrier w/ 3g coverage; the iPhone is the only touch-screen next gen smart phone that has had a few hardware revisions under its belt.

read the rest of "Brave Old World of Proprietary Software"

About SQLAlchemy and Django's ORM

posted June 21st, 2009 @ 17:08:13

- tags: development

- comments: 0

For some background, I've been working with Django for a few years now and for the past year have been a developer on a rather large django application at work. I did a few projects with SQLAlchemy about 2 years ago when I was put on a project whose requirements seemed to imply the need for a database but had no web component. I know of and have used other python ORMs (notably SQLObject), but this post is about SQLA and Django's ORMs, and how I consider the differences between them to be important but also neutral.

read the rest of "About SQLAlchemy and Django's ORM"