Friday, December 25, 2009

Jeff Martone

Since I've only mentioned Pavel thus far, I thought I should write about Jeff Martone as well. He has some great video clips available for free on the Crossfit site, and he also has some advanced kettlebell DVDs on his own site. I've learned things just from the free videos.

Pavel gives you all the basics, and it could be reasonably argued that you don't need anything else. However, I think Martone's work is important for several reasons.

First of all, despite the fact that Pavel's name is almost synonymous with kettlebells in the US, he's marketing various fitness products, many of which have nothing to do with kettlebells. However, Martone seems to specialize in kettlebells.

Secondly, while Pavel's instruction is very high-energy and motivational, Jeff's teaching style is more casual and informational. He provides nuances that Pavel doesn't even mention.

Also, Jeff Martone mixes it up, giving little variations to keep things interesting. With Pavel, you can design a perfect workout for life. With Martone, you can easily make every workout a little different, which keeps it interesting. Don't let me give you the impression that Jeff gives you a bunch of new moves and complicates things. Rather, he explains minor variations in the same exercises, and I think that makes them more fun and less repetitive.

I haven't yet seen any of his DVDs, but the video clips I watched were great, and his teaching style was excellent. It could be that the videos were of him teaching other personal trainers and not end-users, but I really felt like I was getting all the in-depth info.

Wednesday, December 23, 2009

Kettlebell Posture

Okay, so I'm getting the hang of this kettlebell thing. (I refuse to make the easy joke and say I'm 'getting into the swing' of it.) One thing I wanted to report, as I continue to get comfortable with the basic moves and work on perfecting my form is that a kettlebell will improve your posture.

I'm a sloucher. I'm slouching in my chair right now. But you won't catch me slouching after a kettlebell workout. That's because keeping a straight back during the exercises is essential, and afterwards (and the next day), it feels better to keep your back straight.

Interestingly, that changes the way I walk, and improves my balance. As Pavel likes to say, Americans tend to walk by falling forward and catching themselves on their feet, and Russians lead with their stomachs, whether they have them or not.

He also said that his instructors frequently receive the comment from students that "you guys all stand the same way." His response is "so will you." I believe it.

So, just one more plus for kettlebells. In addition to having workouts that actually directly translate to movements you might be called upon to do in an average day of playing with your kids or grocery shopping, it also improves your posture. Time to sell my dumbbells.

Thursday, December 17, 2009

First Swings

Well, I finally got a kettlebell this Monday. I don't have too much to report because I'm taking it slow. Pavel advises a new kettlebell user to "practice," rather than "work out" for at least a couple of weeks. It is vital to hone proper form as a beginner, because when you move onto the more complicated moves or higher repetitions, the chance for injury increases if the foundation isn't in place.

I have taken a number of swings and shot video to study my form. At first it was pretty ugly, but I think I'm getting the feel of it now. I'll be on vacation from work next week, and I intend to put in some quality time with the kettlebell and expand my exercises. Thus far I've only done the basic swing and the one-handed swings. I want to start working on the cleans and presses.

I'm still doing research into various diets. And by 'diet' I mean permanent eating habits, not "lose 10 pounds in 10 days" kind of stuff. I'll report on that stuff another time.

Sunday, December 13, 2009

Kettlebells and Kung Fu

Well, I've been reading all about kettlebells and I've watched some video online. I'm getting more excited every day about getting started. However, I still don't have a kettlebell. That should all change tomorrow!

For now, though, I wanted to point out how much overlap there is between the rules of working with kettlebells and the rules of kung fu. By kung fu, I mean my limited experience with Wing Chun and Yang-style taiji.

* A solid foundation is vital. Without it, no progress can be made, and injury is possible.

* The core of the body is used for all basic motions. The arms may have their place, but everything is about the hips and waist. There is no body strength without a stable center.

* The centerline is key.

* Everything is based on making connections with the floor.

* It's all about the physics of the human body. Proper positioning of the joints creates strength and power. Incorrect body mechanics results in strain and injury.

* The kettlebell is gripped using the heel of the hand and forearm when held up, and by hooked fingers the rest of the time. Never in a death-grip. In kung fu, a tight fist means slow, stiff movement.

* A kettlebell, like an oppenent's fist, can cause damage very easily when in motion. A kettlebell swing packs more punch than any fist, and the same basic techniques apply to neutralizing that force in both disciplines.

* If you get hurt, you were doing it wrong.

* Both are practical. Most workouts and exercise equipment train muscle groups, but very few things teach the entire body to work together, and almost none directly duplicate physical actions people are likely to need to perform on a daily basis.

* Properly-executed movements keep everything close to the body. This is for balance and to keep all force under control with body structure, not individual muscles or joints. Over-extending is trouble.

That's all for now, although I could probably come up with more parallels. I'll be posting more once the workouts start.

Thursday, December 10, 2009

Enter the Kettlebell!

My new book arrived today: Enter the Kettlebell. I'm pretty excited about the kettlebell training, although I don't have a kettlebell yet. However, it should be arriving early next week. That's fine; it'll give me time to watch the kettlebell videos on Crossfit and read the book.

Thursday, November 12, 2009

psycopg2 on Snow Leopard

I use PostgreSQL with Django, and recently upgraded my MacBook Pro to Snow Leopard (OS X 10.6). Everything went smoothly, except trying to actually run Django. As it turns out, the problem was with using psycopg2 with Python 2.6 on Snow Leopard, because Python is 64-bit by default, and is unable to load the 32-bit psycopg2 module. The error thrown is:

Symbol not found: _PQbackendPID

The solution I found was to re-install Python 2.6, after configuring it to compile in 32-bit.

While doing the standard steps (./configure, make, make install), replace ./configure with:

time ./configure --with-universal-archs=32-bit --enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk

Note: This put the newly-compiled Python in a location not on the PATH:

However, I was able to use that Python version to create my new virtualenv, and everything worked smoothly from there on. I hope this helps somebody, because in my Google searching I found a lot of people with the same problem, but none of the solutions given in any detail worked for me.

Monday, November 2, 2009

Enforcing Session Timeout in Django with JavaScript

This article could also be called "How mixing AJAX and Django sessions broke my app."

Here's the rundown: Sessions are set to expire for security reasons. Normally, clicking a link or submitting a form would cause the browser to be redirected to the login page. Obviously this is bad because sensitive information might be visible on the screen. Not quite so obvious is the fact that, when your form submission requires AJAX validation of an address, that validation breaks behind the scenes. The poor user just gets an error message about an invalid address, and can't attempt the form submission which would send them to the login page.

The solution we used relies on having the session expiration added to the context in a context processor, then using JavaScript in our base template to redirect to the logout page if the user is inactive for too long.

Here's the JavaScript, which should be placed in a template block. Inheriting templates should have {{ block.super }} inside the block tags.

            <script type="text/javascript">

//for the session timeout
session_timeout = {{session_timeout}};
page_load_time = new Date().getTime();

function check_session_timeout(){

// check timeout
active_seconds = (new Date().getTime() - page_load_time) / 1000;
if (active_seconds >= session_timeout){
window.location = '/logout/';
setTimeout('check_session_timeout()', 5000)


//Start checking for session timeout


Sunday, November 1, 2009

Address Validation with Google Maps

We've recently begun validating user-submitted addresses via Google Maps. As it turns out, this is very easy to do. All that's necessary is an HTTP call to this URL:

We are using Django and Python. Below is a simple function to handle the geocoding. We have additional code to call this via AJAX via jQuery, as well as internal code to enforce our validation requirements.

The code not seen in this function comes from the Django settings file, and it only contains the arguments required by Google. Documentation for that is on Google's page describing use.

Here are the arguments we send (aside from, obviously, the address itself, which is urlencoded and sent as argument 'q'):

key: our Google Maps key
sensor: false
output: json
oe: utf8


Google Geocoding responds with a lot of useful information. The address object is 'Placemark.' For ambiguous addresses, it may return multiple placemarks. For our purposes, this counts as an invalid address. It also returns an accuracy number, from zero through nine. This is helpful in determining whether your user entered an address specific enough for your purposes. In our case, we can accept four, a fairly low score, since we are just estimating driving distance. But if you're planning to send something by mail, a higher score (at least eight) is required.

If there's interest, I may provide some JavaScript code, or maybe even a fully-functional example page in a later post. Our primary application requires a login to use, and is not available to the public.

def get_address_info(**kwargs):

#expects to receive address fields, bumps
#them up against Google, and returns the
#validation status

geocode_options = settings.GEOCODE_OPTIONS

address_string = ' '.join([

geocode_options['q'] = address_string

output = urlopen("%s?%s" % (settings.GEOCODE_URL, urlencode(geocode_options)))
except Exception, ex:
return False

geocode = simplejson.loads(

result = {
'latitude': '',
'longitude': '',
'accuracy': 0,
'address': '',
'multiple': False,

#if Google returned something juicy
if 'Placemark' in geocode:
if len(geocode['Placemark']) > 1:
result['multiple'] = True

result['accuracy'] = geocode['Placemark'][0]['AddressDetails']['Accuracy']

result['address'] = geocode['Placemark'][0]['address']
except Exception, ex:
log.debug("Exception adding address to result dict: %s" % (ex,))

if (len(geocode['Placemark']) == 1 and result['accuracy'] >= 8):
result['latitude'] = geocode['Placemark'][0]['Point']['coordinates'][0]
result['longitude'] = geocode['Placemark'][0]['Point']['coordinates'][1]

return result

Thursday, August 20, 2009

New Waste of Time

I bought a new book yesterday. So, I'm going to work on yet another huge waste of time -- learning to write add-ons for World of Warcraft. I say it's a waste of time because I barely play the game anyway. In fact, I rarely enjoy it when I do. But I have friends and family there, and sometimes it's a good way to escape for an hour or two.

My dream add-on, and my initial impetus for wanting to learn to write add-ons in the first place, is Moron Filter. If I could just avoid seeing the chat from people who type in all-caps, type "lol" and its evil family members, and other pet peeves (numbers instead of words), I'd enjoy the experience a lot more.

This blog post is the first in a series which will eventually include my code as it takes shape. For now, I'll leave you with the interesting fact that Lua, the language used to script the game's UI, has been ported to the Lego Mindstorms NXT platform.

jQuery UI and Internet Explorer 6 Bug

It will come as no shock to any Web developer that IE6 chokes on its own vomit given the slightest provocation, even with a well-tested, cross-browser library such as jQuery UI.

I post this here hoping that someone else who has this problem will find it; I was able to find nothing useful about this by searching Google and the jQuery UI mailing list. The solution was discovered by my friend Dave, by arbitrarily removing bits of HTML and JavaScript until IE stopped doing its best weeping angel impression.

In this case, it was setting the 'modal' property of the jQuery UI dialog to 'true.' Commenting out that line made everything all better. That's all for now. Watch for other random bits of tech and other gibberish from me in the near future.