Kicking it, the Muay Thai way

sit rama soon logo

I have been training Traditional Muay Thai (Thai kick boxing) for 3 years now. It’s a brutal sport, and I have the scars to prove it. It’s also a very rewarding activity for me.

I train at “Sit Rama Soon” (English Translation: Students of Rama Soon), under the direction of Kru Jay and Kru Joey. Both are former champion Muay Thai fighters from Thailand. Recently my coaches started posting videos of training sessions that they have filmed over the years, including this video of me teaching a new student how to throw a proper muay thai kick. I was unaware of my coaches filming this.

coachs_josh

What I am trying to show here is that the kick is more like a baseball swing, and your knee and hip placement are more important then your lower leg. You can almost think of your lower leg and foot as the end of a whip.

[youtube]http://www.youtube.com/watch?v=JIzvHYWGvY4[/youtube]

How to throw a Muay Thai kick:

  1. Step in with your lead leg, turning your foot to a 45 degree angle
  2. Lift your rear leg, elevating your knee to the desired height
  3. As your leg raises, drop the same arm (right leg up – right arm down)
  4. Point your toes down (stand on your toes of the planted foot, point toes of the kicking foot)
  5. Turn your hips hard into the direction of the target, your hips should be verticle in impact
  6. Point your knee to the opposite side of the target (imagine the target isnt even there)
  7. Your shin should land on the target, NOT YOUR FOOT.
  8. Once the kick lands, push hard into the target
  9. Return to your fighting stance

It’s a lot of steps, but once you can make it all one solid flowing motion its a very powerful weapon. A good thai kick often has more striking power then a baseball bat.

sparing

Removing trailing comas with PHP

php_logo_mediumDealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression.

$string = eregi_replace(',$', '', $string);

Before: string = “2, 6, 9,”
After:
string = “2, 6, 9”

Only the trailing coma will be stripped. If no coma is found, the string simply passes through. It’s a simple and effective solution.

Create WordPress Thumbnails Automatically

create wordpress thumbnails automaticallyWordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things.

The theme I am currently using allows for a custom field named “thumb”. If you create the “thumb” custom field in a post and pass in the path to an image, for example “wp-content/uploads/2008/12/wordpress_logo.png”, a thumb nail version of the image will appear next the posts title on the home page of my blog. Awesome stuff.

When I discovered this theme and the “thumb” custom field, I already had 225 posts in my blog. I didn’t want to go back and manually create all the custom fields for the existing posts, so I wrote a PHP script to do it for me.

The PHP script cycles through your existing posts and looks for the first image in the post, and creates the thumb field based on it’s location. The script is configurable, your theme may want a different custom field name, like “thumbnail” or “image”.

This code is provided as is. If you aren’t a developer, you should be messing with stuff like this. Be sure to back up your wordpress database before running this.

Instruction:

  • download this code
  • configure the database connection info and custom field name
  • upload this code onto your server
  • point your browser to the file
  • watch the script do it’s magic
  • remove the file from your server
  • donate $2 to my paypal account ([email protected])

Note: This is a one time deal, when you create new posts you will need to add the “thumb” field and image path manually


			

UIPickerView – spinning multiple components

xcode

I found an interesting issues with the iPhone SDK and the UIPickerView

The didSelectRow method gets called after a users selects a new value on a picker wheel. The method knows what wheel (component) was spun and the index of the newly selected value. This works great for a picker with a single wheel. My picker had 5 wheels in it.

If I spun two components of the picker at the same time. I would only get one call to the didSelectRow method. More specifically, if I spin one component and move another component no call was received until the first component stops spinning, and so the second component move is never registered.

Long story short, I didn’t catch this problem when I submitted my app, “Ka-Ching”, to the iTunes store. As a result of not catching this, Apple rejected my app. I could argue that the iPhone SDK should have so programmatic hooks that would only allow one component to be spun at a time, or even a method to return the state of all of components in the picker.

uipickerview

Trying to figure out a solution to the problem I expanded on my idea of recording the state of all the components in the picker when the didSelectRow method was called. Realistically, by the time that didSelectRow gets processed it is possible that all 5 of the components had changed.

Looking through the SDK documentation for the UIPickerView I came across this:

- (NSInteger)selectedRowInComponent:(NSInteger)component

With this method you can determine the selected row index for any of the components in your picker. you don’t have to rely on the values passed into the didSelectRow method.

The wrong way to do it

- (void)pickerView:(UIPickerView *)thePickerView
 didSelectRow:(NSInteger)row
 inComponent:(NSInteger)component
{
	//get the value of the component that was changed
	if(component == 0)
	{
        	currency_value = [currency objectAtIndex:row];
	}
	else if(component == 1)
	{
        	hundereds_value = [hundereds objectAtIndex:row];

	}
	else if(component == 2)
	{
        	tens_value = [tens objectAtIndex:row];
	}

	else if(component == 3)
	{
        	ones_value = [ones objectAtIndex:row];
	}

	else if(component == 4)
	{
        	change_value = [cents objectAtIndex:row];
	}

	//some code here to save the values

}

The right way to do it

- (void)pickerView:(UIPickerView *)thePickerView
 didSelectRow:(NSInteger)row
 inComponent:(NSInteger)component
{

	//get the values
	NSInteger currency_NewRow = [thePickerView selectedRowInComponent:0];
	NSInteger hundereds_NewRow = [thePickerView selectedRowInComponent:1];
	NSInteger tens_NewRow = [thePickerView selectedRowInComponent:2];
	NSInteger ones_NewRow = [thePickerView selectedRowInComponent:3];
	NSInteger cents_NewRow = [thePickerView selectedRowInComponent:4];

	//some code to save the values 

}

I upgraded my mac!

MacMiniRamUpgrade-22-500x375

A few months ago I bought a Mac mini so I could start to develop iPhone applications. I must say that I am growing to be more of a Mac user then I thought i would be. I purposly bought a cheap Mac to get started with, but I’m starting to regret it. One of the downsides of buying a low end computer is the lack of RAM. RAM is the area of the computer where th.e work gets done. Think of RAM as a work bench. The larger the work bench you have, the more things you can be working on at the same time. It boils down to this, more ram, more speed due to less reading and writing to the hard drive. My Mac had 1 Gig of RAM, no where near enough RAM for a power user/programmer.

Coming from a PC and Linux world, I have build all of my own computers since 1996. I’m comfortable working with computer hardware and the Mac mini is just another computer, except its wrapped up in a tiny package. I did some research and realized that it wouldn’t be hard to upgrade the RAM in my Mac. I found that MacSales.com had some great prices on RAM so I went for it and got 4 gigs worth.

I documented the whole upgrade process, and launched a new website, MacMiniRamUpgrade.com. It’s a Do-It-Yourself site to help inspire and walk people through the upgrade process.

Adding the RAM to my Mac mini is one of the best upgrades I have ever done. So much bang for buck. You should do it also! http://macminiramupgrade.com