logo

ShrimpWorks

// why am I so n00b?

(Wanted to reply to this NewsForge article, since some other seemingly know-it-all n00bs were ranting in the comments about Smarty being a waste of time, however their comments system won’t let me post [most likely a problem on SAIX’s side])


After having used Smarty for around 2 years now, I don’t think I could ever go back to writing PHP applications without it.

It’s brilliant to be able to spend some time working out your code, logic, etc all nicely in a PHP script, assigning the variables and values you want to present on the final page, then go and throw together a plain HTML page with some smarty tags to display that information.

Bug in your HTML? No need to dig through PHP scripts bloated with loads of HTML searching for problems, just whip out the template and correct it easily. Same goes for debugging the PHP code, it’s not all mixed in with the HTML so it’s millions of time easier to debug.

Overall, there’s no faster, cleaner way of writing PHP applications.

w00t

Finally, got my internet connection back. Turns most of the houses in the townhouse complex we moved into don’t actually have phone lines installed. It’s taken more than 2 weeks of begging and whining at the complex managers to get something done. They finally arrived yesterday (Thursday) with a Telkom tech guy and installed it in around 10 minutes.

Today a not-too-bright Telkom dude pitched up and installed the ADSL. Apparently we should be glad it works at all, since we’re far from the exchange. I guess all that matters is that it actually works in the end :).

The drive up was pretty uneventful, even though it did take 12 hours, around 3-4 more than it should have. I blame retarded truck drivers for that. I must say the scenery around the Eastern Cape is a lot nicer than the barren wastelands between there and Johannesburg. I’ll miss it. The weather here is so dry and hot :(, I’ll miss the humidity too.

Aside from the lack of a phone line (although fixed now), the new place is pretty nice, secure and stuff, 2Kms from work, nice views (guess I’ll post some nice pics I took the other day soon). You’re not allowed to hammer anything into the walls or anything here, or drill any holes, etc, etc, so I’m looking into getting as many PCs on 108mbps wireless LAN. Dodging masses of network cables around the passages between rooms isn’t too hot :).

Work’s just work, but it’s nice not having to fix people’s emails and printers every five minutes, I’m just left alone to write code and stuff. I’m strangely looking forward to work every day much more than I used to in East London, although I’m basically doing the same job (except the lame fixing stuff). Maybe it’s the free and easy access to the coffee machine. Unfortunately the interweb has been owned by a rather nasty proxy/firewall setup that seems to block completely random stuff, even development resources like parts of SourceForge (like most search results) and large parts of the online PHP manual. UnrealZA also works fine, until you try to view a thread… Pretty strange :/.

Guess I should stop babbling and go catch up on some Battlefield 2 :D.

I just came across a post on Voodoo Extreme about the fact that IGN are offering fansite hosting. The commentary along with the post really made me think about the state of fansites in recent years.

They really *have* pretty much completely died off. The closest you’ll get to a fan site these days is something like the SGS or Prophecy forums. I see the Prophecy homepage is even a store-front now, with the forum coming across as an afterthought. Perhaps a little closer to the original fansite idea, you get places like BeyondUnreal and GameSpy’s various Planet* sites. However, these sites have taken themselves from traditional fansites, to giant networks, many of which focusing on some business model or another, rather than the game that got them going in the first place.

On the other hand, a site like UnrealZA is perhaps one of the few remaining dedicated fan sites around. Although, most members on the forums hardly play the game any more :), the idea behind the site and it’s operation has remained pretty much the same since Buccaneer founded it way back in 1998 (granted, a lot of sections and things have been ‘streamlined’ or removed completely due to lack of interest from maintainers and readers alike).

Sadly though, I have also noticed fewer and fewer visitors, and new community members, on the site. Perhaps this is why the bigger sites have reformed themselves from mere fansites like UZA, to the giant networks they are today. I’d really like to try some new stuff with UZA, which I believe could be rather successful (thinking the ’network’ approach of some sites), however on the other hand, I’m worried about losing UZA’s ‘identity’ and ’legacy’ which has been one of the cooler things about being involved with UZA. It really is a pretty unique place on the local gaming scene, I think.

But we’ll see what develops over the coming months.

Yay, on Friday, I decided to take the plunge, and install Debian on my laptop. I’ve always wanted to try working in a Linux desktop environment, considering I do practically no Delphi development any more, everything’s either PHP or Python. Since Debian has plenty of support for both of these, it seemed quite ideal.

I’m not dumping the existing Windows install though, so I had to partition my drive. Now, partitioning drives is about the most nerve-racking thing I’ve ever done, no matter what software I’m using, no matter how little data I stand to lose, I’m always scared as hell something will go wrong. Doubly so on this laptop since I use it constantly for work, and it’s the default installation HP put on, which I’m not really eager to bugger up. Luckily, that all went smoothly though :D.

When it came to installing Debian though, I had a problem with the netinst installer I was using, in that a package or two would not install due to missing some authentication files or something. So, since that installer didn’t work, it was suggested that I try an older Sarge installer and upgrade to the Unstable branch from there.

As expected, that installation went without issue. Unfortunately I just had to try my best to keep the machine cool while waiting for the installation to complete and the ACPI applications to kick in so the fans would do their thing. Thanks Korpse for warning me about that in advance ;).

So anyway, after the base installation was done, it was trivial (as I have come to expect from Debian,) to get Gnome, X.org and GDM installed and running. Apache, PHP and the rest were even easier. I was very pleased to see that the Firebird SQL server (open source’d Interbase fork thingey) was available in Debian right away, so I plonked that in as well. All that was left was to install Subversion, and check out my work stuff. Once done, I was 100% ready for work :D.

There are a few things not working yet - I haven’t had much luck with the wireless LAN. Gnome’s wireless LAN configuration applet thing is missing WPA-PSK authentication options (which I’ve configured my wireless AP to use), it only supports WEP. I also can’t seem to get the WPA tools (wap_supplicant) to work correctly. Based on the output I’m getting though, it *looks* like it’s connecting to the access point - it manages to find the AP’s MAC address and everything just fine, and it reports the authentication was successful, but beyond that, I can’t actually ping anything, and all traffic still seems to be trying to go through eth0 (wired LAN) rather than eth1 (wireless). Guess I need to learn a bit more about Linux networking… heh.

Another thing that’s not quite working is Bluetooth. Again, it *seems* to be working, the hardware is detected, and is working fine. My phone can pair with the laptop fine, using the PIN I’ve defined, but I can’t seem to transfer files or anything in either direction. I’ll admit that I haven’t played with this much yet, but I’m not really sure where to go next. I haven’t even tried looking into infra-red yet :).

And yes, I do use all these things, that’s why I spent so much on this laptop :P.

I also haven’t installed the ATI drivers yet, it looks like it’s going to be a bit of a mission on it’s own though.

Along the way I’ve also discovered some interesting new applications I haven’t seen or heard of before. gDesklets seem like a nice way to waste some CPU time and memory if you like to keep your desktop busy. Beep Media Player seems like a very nice alternative to XMMS, seems a lot more stable, and the general feel integrates better with Gnome. RapidSVN looks like it’s trying to be a nice enough SVN front-end, however I find the good old command-line a lot more friendly and efficient (and it crashes less). Sylpheed is a rather nice little mail client, and works well as an alternative to Thunderbird - assuming you’re unhappy with Thunderbird though. ibWebAdmin is a neat web-based tool for managing your Interbase databases, not as feature-packed or good looking as phpMyAdmin, but it does what it needs to do pretty well.

All that’s left now is to give it a shot at work tomorrow, and see how it all goes :).

I’ve had a couple of questions regarding my Battlefield 2 Stats in Python post, and how it may be possible to do the same in PHP, so I thought I’d add an update for that.

Simple PHP code for Battlefield 2 Stats retrieval:

    ini_set("user_agent","GameSpyHTTP/1.0");

    $info = "per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-";

    $pid = '43595724';
    $data = file("http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=".$info);

    $stats = array_combine(explode("\t", $data[3]), explode("\t", $data[4]));

    printf("%s has %s kills and %s deaths and a score of %s", $stats['nick'], $stats['kill'], $stats['deth'], $stats['scor']);

Note that if you’re not using PHP5, you’ll need to add the following drop-in replacement for the “array_combine” function:

    function array_combine($keys, $vals) {
        $i = 0;
        foreach ($keys as $key) {
            $newarray[trim($key)] = trim($vals[$i++]);
        }
        return $newarray;
    }

It’s also important to note that while at the time of writing this, this method of retrieving stats works, EA, DICE and GameSpy are supposedly working on a new XML-based stats system for BF2.

Updated: Since this was written, some things changed with the stats system, and the GameSpy application requires you to pass a bunch of columns you want info for. This can help customise the data you get back, so you only request what you need. I’ve included all the columns in the $info variable, which you can customise. Make sure it contains only valid columns, or you won’t get any data back at all.

For info on what to do with the stats, and what all the columns etc. mean, check out the BF2 Technical Wiki.

So Korpse pointed out a rather interesting website the other night - Pandora.

Basically, it’s a rather nice little service which allows you to discover new music, artists, etc, by telling it which music you like already. Based on a song, or artist name you provide, it goes off and finds music matching an assortment of criteria matching the provided song/artist. It then proceeds to play a endless playlist. It’s all streaming, but it’s extremely good quality for streamed content, and practically never stutters, even when downloading or uploading other stuff (0n 512k ADSL anyway).

During your listening, if it plays something you don’t particularly like, you can tell it so, and it’ll further fine tune the playlist, the same applies to something you do like.

I do have a few things I’d like to see added or changed though. The ability to play your well refined playlist in the player of your choice

  • could play pretty much like a normal streaming playlist. Show a timer/track progress bar thing, it’s just nice to know :). Ability to go back and play previously listened to tracks. Perhaps two additional rating categories - it’d be nice to rate vocals and music separately.

Anyway, my 10 free trial hours are up, and I can’t seem to cheat by deleting cookies or something. My MasterCard should be arriving this week some time, and I’m seriously considering that $36 for an annual subscription…

Someone posted an image of somewhere they’re staying in “Qatar Doha” (no, I don’t know exactly where that is ;)) on the SGS Forums, mentioning how similar it looks to the Battlefield 2 map, Strike at Karkand.

I thought it might be cool to try to make the image look a bit more like the map, adjusting the colour balance, adding the orangey dusty air effect, etc. Further on, someone posted an image with some player characters and a jet overlayed, I though it was a pretty cool idea, so I whipped out Photoshop, my previously modified image, the official BF2 site (for screenshots of vehicles and characters), and got to work.

The end result is pretty cool I think :D. Click for full versions (original on the left, mine on the right):

Lost in time

Update; toned down the colours a bit, didn’t realise the monitor I did this on originally was so off :P.

A few weeks ago, the Serious Sam 2 demo was release, and my clan, the Avatars, and I were dying to try out the co-op, since we had played the previous game though together (although some shocking networking code made it near impossible), and were rather looking forward to SS2.

Unfortunately however, the demo’s internet play functionality was rather broken. After some digging on various forums looking for a solution, someone found a rather useful little utility - Hamachi.

Hamachi is basically a very simple VPN system, which behaves pretty much like an instant messaging client. When you install it, you’re run through a very informative little tutorial to get you started. During the process, you’re assigned an IP in the 5.5.x.x range - though I’m not entirely sure where the range starts or ends, we all got IPs like that - and a new Hamachi network connection is created under Windows. You may then join or create as many private or public networks as you like.

Members on the network can ping each other on their “Hamachi IPs”, they can browse shares, and copy files backwards and forwards (shares even end up showing up in your “My Network Places” eventually), send messages back and forth, etc. And of course in our case, it registers in games as a LAN connection, so you can easily play any multiplayer game with LAN support, without the need for the person hosting the game to mess with their firewalls, routers, port forwarding, etc.

There is a Linux binary available, however I couldn’t get this to work on my Debian Sid server, there were various tunneling problems, which are a bit beyond my networking skills to resolve.

In general though, the possibilities are pretty endless. Anything you can do an a LAN, you can securely and easily do with Hamachi, on a network spanning the world if you really wanted.

“Oops, I just printed my bank statement to Joe in Australia’s printer!”

Ever since installing BattleField 2, I’ve had a problem with taking screenshots. Basically, the game completely freezes up when I press whatever key is assigned to screen captures, and I need to reset my computer completely. Also, I seemed unable to use Fraps to make screen captures since the game seemed to be blocking all requests to whichever keys I assigned to Fraps’ capturing options.

I decided to rather just create my own utility. A simple application that hooks into the “Print Screen” key’s press, so when you press Print Screen, this app takes the image out of the clipboard, and will write it to a folder as a JPEG image. You can customise both the output location and the JPEG compression quality. The images are named after the current date and time.

It doesn’t work only for games, ANY time you press Print Screen, a screenshot will be saved. I think that could actually be pretty useful.

Yes, there are a million screen grabbers for Windows out there, but writing something yourself is both educational, and you know exactly what it’s doing. Also, I now have a single screenshot button for games, and everything else as well :D.

Note this may not work for all games, as some games tend to dump quite a mess to the clipboard when attempting a Print Screen.

This post also serves as a test for the attachment plugin for WordPress I recently installed ;).