Flying with Django
Sunday, May 24th, 2009This is from xkcd. Shows off everything great about Python.
This is from xkcd. Shows off everything great about Python.
I wanted to use Poker Tracker to keep track of my stats when playing at the play money tables of Poker Stars. Poker Tracker doesn’t support the play money tables.
I wrote some Perl to convert the the lots from the play money format into the real money format.
#!/usr/bin/perl use strict; use Cwd; use File::Find; my $some_dir = "Z:\\HandHistory"; my $startDir = &Cwd::cwd(); find(\&processFile, $some_dir); exit; sub processFile { shift; return if not /\.txt$/; my $inFileName = $_; my $infile = "$startDir/$File::Find::name"; my $outfile = "$startDir/outHands/$inFileName.$$.converted.txt"; open (inFILE, "<$infile") or die "can't open in file!: #$infile# ($!)"; open (outFILE, ">$outfile") or die "can't open out file!:#$outfile# ($!)"; my @players; while(<inFILE>) { chomp; @players = () if (s/^(PokerStars Game .*\()(\d+)\/(\d*)(\).*)$/\1\$\2.00\/\$\3.00\4/); push(@players, $1) if (/^Seat [\d+]: (.*) \(\d+ in chips\)/); foreach my $key (@players) { my $value = $key; $value =~ s/\s+/_/; ($value = $1) =~ s/($1)/_\1/ if ($key =~ /^(\d+)$/); s/$key/$value/; } s/([\( ])(\d+)([\) \.])/\1\$\2.00\3/g; s/\(Play Money\) //g; s/^\s+//; s/\s+$//; print outFILE "$_\n"; } close(inFILE); close(outFILE); }
I remember a theme for mac os 9 that I’m pretty sure came with the bondi blue style iMacs. There was one theme with matching colors for each of the iMacs. I’m pretty sure I’m not making this up. I’ve googles around but can’t come up with anything. Does anyone remember this?
I finally upgraded to [REDACTED] beta 5 on one of my iPhones. Everything seemed to go just fine. I upgraded Xcode and installed the new SDK. Yay. Things were looking pretty good until I tried to build some of my existing applications.
‘Error from Debugger: Unknown packet reply: “timeout” to environment packet.’
I don’t even know where to start with that error. I’m only getting it on the iPhone 1st gen that was upgraded to beta 5. The same project builds and runs just fine on my 2.2.1 3G.
I just tried another project and it builds and runs just fine on both my beta 5 1st gen and on my 2.2.1 3G.
Anyone else getting this? How did you fix it?
I’ve been big into using git for all of my Python Version Control. I’ve been mucking around with GitX to use it with my Xcode projects and that works out pretty well. I wanted to have something that was actually integrated into Xcode, that limits me to Subversion, Perforce and CVS.
I’m not a fan of CVS so its out. Never used Perforce and Subversion seems to be the easiest to get started with.
I ran svnadmin create SVNrep and the set it up in Xcode and found it gave me Error: 180001. That’s no good. After some googling I found a post by James Murty which describes the problem. It seems Xcode 3.1 isn’t compatible with versions after 1.4. I’m I’m running 1.6.1. svnadmin has a flag –pre-1.5-compatible that will create repositories that are compatible with versions less than 1.5.
After removing the previous SVNrep and running svnadmin –pre-1.5-compatible create SVNrep I now have a SVN repository that Xcode 3.1 can use.
The other day Digg went live with the DiggBar. It is like a combination of TinyURL and Stumbleupon. There are a lot of people not too happy with Digg and the DiggBar right now. I must say that I am one of them.
I think the DiggBar is a throwback the internet of yesteryear. Don’t get me wrong, I see what they are trying to accomplish with it. They want to give the average Digg user a better experience. That is great. The DiggBar is not the way to do it. A better way to have the same results would be a toolbar for Firefox or Internet Explorer. Everyone wins in that case.
Back before Leopard and the tabbed Terminal.app I was using iTerm. I iTerm, I did everything I wanted. Leopard came along and with it the new Terminal.app. Hello tabs. With this new tabbed Terminal.app I no longer needed iTerm. As time went on I had pretty much forgotten all about iTerm. Just the other day a friend tweeted about iTerm which made me download it and give it another try.
Things I love about iTerm.
Things I missed.
The option + delete may not seem like such a huge deal but I used it all the time. After a bit of googling I’ve found a simple way to make it work like it should.
Open the Manage Profiles window (Bookmarks -> Manage Profiles). Select the keyboard layout you use, and make sure +Esc is selected.
Apple approved #WHOIS, a whois client I wrote for the iPhone / iPod Touch. I’m glad they approved it. I had a blast getting familiar with Objective C and Cococa. Coming from a strong Python background it wasn’t that big of a leap. I’m not sure why I had been so intimidated by C before, It really isn’t a difficult language to use.
I’ve been hard at work coming up with ideas for the next few projects I want to do and should have the next thing submitted to Apple early next week.
All in all, the turn around time from submission to live was right around 7 days. Oh, I almost forgot, I have some promo codes to give out. If anyone is interested leave a comment, get in touch with me on Twittter (@trcjr) or AIM (stupidfoot)
I’ve been coding python for over two years now. I’ve mostly used it for console back end applications. Talking to Postgresql or Sqlite. I love Python. Before Python I was doing pretty much the same tasks with Perl. I’m not going to go into the Python vs Perl thing now but I will say that Python is a much, much more friendly language to use.
I got into Django with the 1.0 release. Developing with Django is fast. Crazy Fast. The Django ORM makes dealing with the database an extremely pleasant experience. Looking for a post with the slug ‘hey-i-am-the-post-you-are-looking-for’? Its as simple as Model.objects.get(’hey-i-am-the-post-you-are-looking-for’).
Django follows the DRY principle. Don’t Repeat Yourself. The thing that I miss the most when dealing with other web frameworks, like CakePHP is the lack of get_absolute_url(). I love that there is just one place where you define the url structure to a type of object. Want to change all of the links to your posts from /posts/<slug> to /not-posts/<slug>? Easy, change the value of get_absolute_url() in the Posts model.
With Django you can go from an idea for a webapp to a fully functional site in an afternoon. Django’s ORM is great to use even if you are not going to be using Django to build a web site. If you have not, spend an afternoon with Django. Get cozy. Learn to love it.
Last year I was turned on to Puzzle Pirates by Three Rings. If you don’t know anything about Puzzle Pirates, it is a MMORPG where you are a pirate and you join a crew and sail around attacking other people. You control the sailing and attacking and pretty much everything else through the act of playing puzzle games.
I played the game for a few days before I thought that there must be some way to autopilot the puzzles which would allow me to make in game money for doing little work. After a small amount of research I fount SCAR Divi.
SCAR Divi seems to be mostly centered around building bots for RuneScape. I have written several bots for Macroquest 2 back in the day so I figured writing a puzzle solver for Puzzle Pirates wouldn’t be too difficult.
In the span of a few hours I threw together a simple proof of concept bot that would play the Bilging game pretty well. I tinkered with it here and there for a few days and ended up with a pretty capable bot that would sit and play Bilging for hours on end making me a tidy sum of pieces of eight.
I’m betting that Three Rings didn’t like the fact that I had several accounts running my little bot for days on end which is probably why my computer was tainted.