Choked Out

Tonight I had my first experiencing with getting choked out - going unconcious from a Jiu Jitsu choke. The black belt was showing me how to do a triangle, and somewhere in the middle of saying “that’s tight” I went to sleep.

I’d always wondered what it felt like. Very surprising - it was a most pleasant experience. One minute I was in class, the next I was having a wonderful dream. I was talking to my brother about something, and out of nowhere Mark was asking if I was asleep. Of course I’m asleep, I thought, and tried to get back to dreaming. Then somebody else said “I think he’s out”, and I opened my eyes to find out I was still in class.

Apparently everybody reacts differently; my experience was quite nice. Scary to think the path from that pleasant dream to dead is not very long.

How To Setup Your Windows CMD Window To Be Usable

I hear complaining about the Windows/DOS command line window and how unusable it is, which is surprising considering how easy it is to make it usable. Here we go:

  • Start a new cmd session. On Vista, click on the round windows icon at the bottom left of the screen and type “cmd” into the “Start Search” box. On XP, click Start->Run and type in cmd.
  • Right click on the top cmd window area and select “Properties”
  • Options: Enable “Quick Edit Mode” and “Insert Mode”
  • Font: Size: 10 , Font: Lucida Console
  • Layout: Window Size: Width: 100, Height: 50
  • Click ok
  • Select “Set properties for future windows”, click Ok.
There you have it. Your cmd window will now be of reasonable size, use a readable font, and allow easy copy/paste. To copy text from the cmd window highlight it with your mouse and hit enter. To paste into the cmd window simply right click.

XML The Evil Adult

Entertaining if long winded rant from Erik Naggum:

When the markup overhead exceeds 200%, when attributes values and element
contents compete for the information, when the distance between 99%
of the “tags” is /zero/, when the character set is Unicode, and when
validation takes more time than processing, not to mention the sorry
fact that information longevity is more /threatened/ by XML than by
any other data representation in the history of computing, then SGML
has gone from good kid, via bad teenager, to malfunctioning, evil
adult as XML.

Python Simple Mock Object

Another one of those that’s mainly for my own notes. I needed to create a mock object that always a returns an empty list no matter what method is called on it. That is, you can instantiate one of these and call any made up method on it and get an empty list back. Here is it:


class Dummy:
	def __getattr__(self, name): return lambda *args: []
d = Dummy()
d.something()   # returns []
d.something_else(”a”,1,”b”)   # returns []

Python SMTP Debugging Server

Note to self: this is how you start a python SMTP debugging server:

python -m smtpd -n -c DebuggingServer localhost:25

On Coaching

Thinking through my performance as coach (of my son’s under-8 soccer team):

We had a tough season, winning only a single game. Clearly not very good.

On the other hand, each and every player showed improvement, some quite significant. One parent even took the time to thank me for helping his son find a passion for the sport.

The season ended on a very high note: we came in first in the tournament (based on points). We won two games, tied one, and lost one (in the final minutes). We played very well, showed a real understanding of the game, and played as a team. I was very proud of every one of the players.

On the other hand, a big part of the reason we did so well was our super-sub. This kid was incredible. We were short on players so he played for our team.

Hmm. So we have a clearly improved set of players, playing as a team, playing their hearts out. Fantastic. I’d like to take some credit for that.

The biggest impact on winning, however, was having an excellent player on our side.

I can’t help but think there’s a management lesson in here somewhere. Something about hiring the best you can…

Easiest Way To Create UML Sequence Diagrams

In need of creating various UML Sequence Diagrams and in no mood to deal with Visio or its other graphical editor ilk, I did some research and ended up at a really nice solution.

What I wanted was to be able to specify my sequence using a simple text description and have a tool turn that into a sequence diagram. What I found was a tool called Sequence by Alex Moffat that does exactly that. The syntax takes a minute to get used to, but once you see what’s going on it’s very easy to use. The generated images are reasonably attractive and easily exportable to png, gif, etc.

Here’s a sample of the syntax:


objectOne.methodOne {
  objectTwo.methodTwo -> value {
    objectThree.methodThree -> anotherValue;
    objectFour.methodFour->finalValue;
  }
}

And here’s the resulting diagram:

UML Sequence Diagram

Once you download the jar and run it hit the “Help” option and look at the examples. They’re self explanatory and fairly complete.

Django-Piston: REST Framework for Django

Django-Piston in a promising looking REST frameowork for Django. On first inspection it seems to have all the right attributes and setup. I hope to give it a try soon.

One question I have - while I agree HTTP PUT and DELETE are the right verbs to use for Update and Delete, in practice they’re not well supported and can cause confusion. I’m wondering if there’s a way to change the mapping to the following:

POST /resource  -- Create
POST /resource/id -- Update
POST /resource/id?action=delete -- Delete
GET / resource/id -- Read

Value of The Printed Newspaper: Less Than Zero

We subscribed to the local paper, mainly to support a cause that was raising money by selling subscriptions.

Thursday through Sunday we get the paper physically delivered to our house. And I get to experience the value first-hand.

The value of the printed paper is less than zero. I’d prefer they stop delivering it immediately.

I end up with newspaper all over the house, I feel bad about the wasted paper, and I have to make room in my already overflowing recycling bin.

This is not a comment on the contents of the paper; it could be great stuff for all I know (I’m not really reading the local papers so much anymore). It is a comment on printed newspaper as a medium.

A few years ago I used to argue that paper is so much more convenient that electronic media that I’ll never switch. In those few years, unbeknownst to me, I did switch. Paper is now less convenient for me than carrying my little netbook around.

Preserve JavascriptDB: Yet Another Non-Traditional Data Store

Non-traditional data stores are coming fast and furious these days. Here’s another interesting one: Preserve with JavascriptDB. This one I’d like to check out.

On Magic Powers

As with most profound experiences in my life this took place on a late Southwest flight after a long, exhausting day. The young man seated a few seats away began to scream, threaten, move violently, and curse wildly as the plane took off.

The initial reaction of people close by was fear, disgust, and horror, followed by understanding, compassion, and finally by a genteel unspoken agreement to pretend he doesn’t exist.

The young man suffered from Tourette’s syndrome.

I realized at that moment that taking offense is a choice.

We chose not to be offended by this young man due to his condition.

Knowing this I’ve gained a magic power. I can chose not to take offense. I can choose not to be bothered by things that really should bother me.

And once in a while I actually employ this power - instead of fuming and screaming bloody murder, sometimes I choose simply not to be offended and move on.

Not often enough though.

Proxies For Request Modification?

Interesing post from igvita on Ruby Proxies for Scale and Monitoring discussing the use of Ruby and EventMachine to create simple proxies for monitoring, benchmarking, content examination, and even request modification.

I’ve always wanted to do benchmarking as Ilya suggests. Real production traffic is the best way to test. Good stuff.

I’m tempted by the beanstalkd use case as well - he uses his proxy to detect and route certain requests to an archiving mysql instead of to his beanstalkd instance. I’m leary of maintainability issues however - I’ve generally found indirection, particularly at wire protocol level, can quickly lead to hard to find bugs.

Something to experiment with at some point.

Notes On Distributed Key Stores

Leonard Lin posts his notes on distributed key stores. His requirements are fairly similar to mine so I read with interest. Short version: he likes Tokyo Cabinet / Tokyo Tyrant with his own consistent hashing scheme thrown on top. 

Btw, it’s interesting how much interest there suddenly is in distributed key-value stores - everyone I know is using or evaluating one. How did we live without them for so long? Gasp.

Python Simple Inheritance Example

Another one of those things I tend to forget the syntax of, noting for easy future lookup:

 


class Base():
    def __init__(self, param):
        print "Base:", param
    def method(self, param):
        print "Base.method:", param

class Derived(Base):
    def __init__(self, param):
        Base.__init__(self, param)
        print "Derived:", param
    def method(self, param):
        Base.method(self, param)
        print "Derived.method:", param

>>> d = Derived("me")
Base: me
Derived: me
>>> d.method("you")
Base.method: you
Derived.method: you

Picasa To Flickr/FaceBook Upload

Uploading pictures from Picasa to Flickr (or Facebook, or pretty much anything other than Picasa Web Album) is still too difficult. There’s a nice project called picasa2flickr but it has some issues - it takes focus and blocks while uploading the images, which can take quite a while. I used to drag and drop from Picasa into flickr uploadr but that doesn’t seem to workanymore with Picasa 3. Thanks Googs.

The solution, seems to me, should be something like this: Select a number of pictures, right click on them, and have an “Upload to Flickr”, “Upload to FaceBook”, etc, button. Clicking the button should simply send the list of files to a background uploader and return immediately. The background uploader can take its merry time uploading the pictures.

I’m really tempted to go write this if only to stop being my wife’s “I need to upload photos to FaceBook” tech support guy. Looks like there’s a Picasa Button API (via picasa2flickr) so this should generally be doable. Now to find the time.

Distributed Database Talk

Very informative PyCon talk on various fancy distributed data stores, including BigTable, Dynamo, Cassandra, and several others.

 

Is There Any Legitimate Reason To Follow > 1000 People On Twitter?

You can only pay attention to so many people. Unless I’m unaware of some magical tool or technology, 1000 people is way past the point where you can pay attention.

When I see people who are following 3000 or more people follow me, I have to wonder, do they have any legitimate reason? Or is their sole motivation to get me to follow them?

On Twitter Replacing RSS/Blogging

Simon Willison asks whether people are using Twitter as a replacement for RSS aggregators, and finds anecdotally that a sizable number are.

I can buy that. I still prefer RSS for a number of reasons, not the least of which is the velocity of Twitter is too high - I don’t have time to keep up with a lot of the conversations, and by the time I get around to reading (if I do), it’s often too late to participate. It’s also annoying to see partial nonsensical conversations between people you’re otherwise interested in. A lot of the old timers are using Twitter as the new IRC, and I’m not quite used to that yet.

Anyway, as a still-interested-in-RSS fellow I’m concerned not about people using Twitter as an RSS aggregator replacement, but about authors tweeting instead of blogging. I enjoy reading longer, more thoughtful pieces, and I feel like people are decreasing their blogging output in favor of increased tweeting. Looking at my RSS feeds it feels like a good number of the non-commercial authors are publishing less than they used to. I suppose if I wasn’t lazy I could actually calculate this instead of guessing, but, alas, I’m lazy.

So, Simon, perhaps you could ask the complement of the authors as well: are they using Twitter in place of writing blog posts?

Tokyo Cabinet Observations

I’m using Tokyo Cabinet with Python tc for a decent sized amount of data (~19G in a single hash table) on OS X. A few observations and oddities:

  • Writes slow down significantly as the database size grows. I’m writing 97 roughly equal sized batches to the tch table. The first batch takes ~40 seconds, and processing time seems to increase fairly linearly, with the last taking ~14 minutes. Not sure why this would be the case, but it’s discouraging. I’ll probably write a simple partitioning scheme to split the data into multiple databases and keep the size of each small, but it seems like this should be handled out of the box for me.
  • [Update] I implemented a simple partitioning scheme, and sure enough it makes a big difference. Apparently keeping the file size small (where small is < 500G) is important. Surprising - why doens’t TC implement partitioning if it’s susceptible to performance issues with larger file sizes? Is this a python tc issue or a Tokyo Cabinet issue?
  • [Also] Seems I can only open 53-54 tc.HDB()’s before I get an ‘mmap error’, limiting how much I can partition.
  • Reading records that have already been read from the tch seems to go much faster on the second access (like an order of magnitude faster). I suspect this is the disk cache at work, but if anyone has extra info on this please enlighten me.
Another somewhat surprising aspect: using the tc library you’re essentially embedding Tokyo Cabinet in your app; I had assumed it was going to be network based access, but it’s not. You can do network access either using the memcached protocol or using pytyrant.

If you have enough traffic, the cost of servers outweighs the cost of programmers

Quote from Bill Venners (via):

If you have enough traffic, at some point the cost of servers outweighs the cost of programmers

Absolutely true, which is why places like Yahoo and Google are among the last bastions of very skilled C/C++ programmers.

Of course I should mention: you are not at that point. You really aren’t. So for now ignore this quote.

Next Page »