K I S S

I’ve been perusing the boards over at PHP Freaks

lately and I’ve noticed a few annoying practices that I want to highlight. In my experience, keeping things as simple as possible helps to keep the code clean and usable. It’s easier to debug, easier to change, and lasts longer. When dealing with something like PHP, you inevitably run into the problem of differentiating languages. PHP, HTML, CSS, Javascript, UGH! Far too many people combine everything in one file and try to make sense of it. It’s rough enough for some people to keep one language straight, let alone 4. So, let’s use some common sense. It’s possible to separate them, so why don’t we?

 

Let’s start with the simple ones. CSS and Javascript are easily put in separate files. Creating a .js and .css file is a good practice and should be a standard step in all web creation. Granted, this should be done with some additional common sense. Creating either file for one or two small additions is not necessary unless those functions/definitions are used frequently through several pages.

 

So, we’ve removed 2 of the 4 languages and separated them out to their own files. How about the PHP and HTML? Well, there’s a fairly easy solution there too. I, personally, use the Smarty Template Engine. I believe there are other template systems out there, but Smarty works for me and I like it. Basically, you put all your php code in one file, make calls to $smarty->assign() and variables from php appear as Smarty variables in the template. From there you can easily “print” them in the template by using something like {$var} … Extremely flexible. Smarty also allows you to do some primitive programming. Enough to make it useful, but not so much that you get confused once more by 2 languages in one file.

 

So now we’ve separated everything into it’s own file. It’s easier to read, easier to understand, and easier to make changes. Imagine being able to simply change the HTML only and not worry about impacting the logic in the PHP program! Ahh.. flexibility!

 

Next on my pet peeve list is programmers who just won’t use functions like sprintf()… Let’s try an example here.. Which looks simpler :

 

$query = ‘SELECT id, name, age, salary FROM users WHERE name LIKE “%’ . $name . ‘%” AND age > ‘ . $age . ‘ AND salary > ‘ . $salary . ‘ ORDER BY name’;

 

or this :

 

$query = sprintf(‘SELECT id, name, age, salary FROM users WHERE name LIKE “%%%s%%” AND age > %d AND salary > %f ORDER BY NAME’, $name, $age, $salary);

 

Now, at first glance, the second one looks a little suspect. That’s because I chose what might be considered an ugly example. But, an experienced programmer can tell at a glance what the intended value of the 3 variables used in the query should be. String, Decimal, and Float. In addition to making it look a little nicer, you also gain some security. If someone snuck a string in for $age, it has no effect. So even if you skip sanitizing your variables, you still have a little bit of security. (Don’t skip sanitization…)

 

Simple additions to your coding toolkit, tons and tons of enhancements to your skillset. Please, code responsibly.

AJAX : It’s not just for cleaning anymore…

There’s a new or, rather, old programming language.. wait.. language? Hrm.. mixture of concepts is more like it. Anyways, there’s this new way of doing things on the web. It’s called AJAX which is an acronym for Asynchronous Javascript and XML. Based on the XMLHttpRequest object, it allows a web programmer to transfer information between the server and the web browser without requiring a complete reload of the web page. Pretty nifty stuff.

 

Dubbed Web 2.0, this “new” technology is revolutionizing the way users interact with the web. More than a mere buzzword, AJAX is sweeping the web and offering up some very powerful web applications. Gmail has been using AJAX for a while now. AJAX, combined with DHTML, allows you to “build” your Google homepage, and allows that same page to be updated on the fly without reloading the entire page. More recently, sites such as Netvibes, Pageflakes, and Eskobo offer “Web Desktops”. Other sites such as Yahoo Maps and Google Local offer web based mapping software without the arrow clicking and page reloading.

I’ve purchased a book on AJAX to enhance my own knowledge of this powerful web development tool. It’s definitely an intruiging concept and it seems simple enough up front, but extremely powerful when you get deep into it. Stay tuned for more!!!

Phew! There’s a backup!

Network management is a field I’ve been in for the past few years. In addition to making sure that packets get from point A to point B in the most efficient manner, I’ve also had to deal with network failures and disaster recovery. Essential to the disaster recovery scenario is the concept of backups. We’ve all heard of backing up the files on your computer, and backing up the servers, and storing them off-site, etc. But sometimes people overlook other backups that need to be handled. Namely, network device configuration backups. It really sucks when you realize that the smoking router in the corner has the only copy of the configuration you need to get the network back up…

 

I’ve written a bunch of code in the past to handle backing up a bunch of different types of equipment, and I’ve decided to make it open source. This new project will be hosted at SourceForge, and there is a link to the project page in the links section of this blog.

 

The initial code release will take a little bit to put together, but I’m hoping to have an alpha release within a month or so. It’s all written in object-oriented perl, a language I find fun to code in. I hope someone out there finds this useful. I know I spent quite a bit of time looking for a solution like this, and was sadly disappointed that I did not find one…

 

Review : SOCOM: U.S. Navy SEALs Fireteam Bravo (PSP)

Anticipation : 7
Expectation : 6
Initial Reaction : 9
Overall : 9
Genre : First/Third-Person Tactical Shooter

 

About a year ago or so I tried out SOCOM for the PS2. The game was simply incredible. But, I never purchased it for PS2. Basically, I just don’t have time to play my consoles.. :( Flash forward to today! PSP.. Best thing ever. I get to play games now! :)

 

Anyways, back to the review. I wasn’t really looking to get this title. It was on my wish list, but only as an interest. Not really a “must have” title. I received it for Christmas and it’s been sitting around since then, waiting for me to open it. (Lots of GTA:LCS play lately) … Well, I took the plunge the other day and I must say, I’m quite impressed. First person shooters on consoles aren’t really my thing. I prefer a mouse and a keyboard. Quick reflexes, ability to spin quickly, etc. But, with a tactical shooter, it’s a little different. It’s definitely a slower pace, so the need to spin around isn’t as prevalent. I wish the reticle in sniper mode moved a little faster, but I can live with it the way it is..

 

Overall I’m pretty happy with the game. The graphics are excellent, the gameplay is smooth, and online play is actually a lot of fun.

 

Speaking of online play. THANK YOU ZIPPER! WPA support. *phew* I didn’t think WPA support was something that was that difficult, and it bothers me greatly that it’s not included in Madden ’06.

Look, I’m a programmer, and as a programmer, I tend to look at things a little differently. I understand the technical challenges that game developers have to overcome, and I understand why some features work the way they do. But, for the life of me, I cannot figure out why Madden does not support WPA. Let’s look at this from an API/framework view. I’m Sony, and I have an API for my PSP. My API has basic features, and an entire network featureset. I include some hooks to make it easier to deal with the network stuff. For instance, I may have a “startnetwork()” routine. I probably have a “senddata()” routine, and so on. In version 1.0, I have support for wireless, and just WEP at the moment. Of course, I’m all about future upgrades, so when 2.0 comes out and I support WPA, I build that into the existing commands, letting all the existing software take advantage of it. Right? Well, maybe. Unfortunately, I don’t have access to the PSP’s API, but it makes sense. So why doesn’t Madden support WPA? Good question.. :(

 

But, SOCOM does. So that’s at least one game I can play at home on my WPA protected network. Madden, no. (Not that it matters, EA has my copy of Madden at the moment. Hopefully they send me a “fixed” version soon)

 

Overall I think SOCOM is pretty decent and I’d definitely recommend it. I’m pretty impressed so far, and I’m definitely willing to continue playing it!

21-10

Ok, so it’s not a tech post. But I have to post. I’m pretty impressed and fairly proud. Pittsburg Steelers. 21-10 over the SeaHawks. Not my team, but still. They looked great all season and were just awesome in the big game. Randel El’s touchdown pass was simply incredible. All in all, an awesome game. And for the most part, it was actually close..

 

Congratulations Pittsburg! Live it up! Next year it’s my turn! :)

phpTodo 0.6 Released!

I released version 0.6 of phpTodo last night. There were some minor bugfixes, nothing major though.

 

Added to this release were a few new fields in the database to track creation date, and last modified dates. Future releases may utilize these fields more, but at the moment they’re only being used for the sort stabilizer.. The task modify code was updated to deal with these 2 new fields. Each time a record is created, the create_date field is populated. Every change updates the last_modified field.

Which brings me to another feature I added. I noticed that if you sort by priority, status, or anything other than subject, the entries shifted when you reloaded the page. My initial thought was to just add a behind the scenes secondary sort on id. I changed my mind and decided to give that choice to the user. So, on the preferences screen, the user can choose what field to sort on. This is set to task ID by default.

 

At this point the program is pretty much feature complete. I’m adding in WML support before the 1.0 release, but that’s about it. Besides bugfixes, of course.

 

After the 1.0 release, I have some bigger plans. I read a book by David Allen about todo lists and handling tasks.. Really enlightening stuff. Basically, the idea is to process everything in your inbox (anything you need to do), and determine what the next action is. At that point, you file it away based on when it needs to be done. There’s obviously a lot more to it, and if you’re interested, you can find his book on Amazon.

Based on what I learned, I’m planning on adding a number of features to phpTodo. First, I plan on adding an email module. This will allow the user to email todo items to their list. I’ll be adding some sort of authentication schema to it to ensure the item goes to the correct list. That has yet to be worked out.

I’m also looking at updating the main screen. I’ll break it up a bit to become a dashboard of sorts like the presonalized google homepage. Essentially, there will be an inbox which will consist of un-sorted todo items, an interface to quickly go through those items, the main todo list, and a calendar with appointments.

Since I’m adding a calendar, I want to also add a tickler module that can send reminders via email, sms, IM, etc. The user can choose the method(s) they want to be notified by and the system will alert them when the time comes.

I also want to add group todo lists. In essence, another user that will “share” their list with other users. This will, I believe, add more project management capabilities. Anyone can add a todo list item, and anyone else can take it and work on it. Possibly some sort of notification feature to update all users regarding those items.

 

Overall, I think this project is working out pretty well. I’ve learned a lot about php programming and I’m working on solidifying my coding style. It’s helped me a lot with the coding I’ve been doing for work. I’ve put together a complete database system, dsl tools, and the like. Good stuff that I seem to be getting some decent praise for.. :)

 

You can download the latest version of phpTodo from the phpTodo SourceForge page.

Firefox turns to the dark side?

I noticed an article over on Slashdot about a new attribute, ping, that Firefox handles. That is, the development version of Firefox. This isn’t your standard network ICMP Echo Request, but rather an HTTP Request designed to track a users movements.

 

Ok, ok.. Stop screaming about privacy and security. I’ve thought about this a bit and I think Firefox is doing the right thing. The intention, as far as I’ve been able to tell, is to actually put more control into the users hands.

 

Let me explain how this “feature” works. There’s a small writeup on the Mozilla Blog that you can read as well. Tracking the browsing habits of a user is actually fairly harmless, at least in my opinion. The idea is to get feedback about what a user at that site likes to see. Do more people click on links to cartoons? Or perhaps to political information? It’s all about creating websites that people want to see.

 

So, Joe User goes to a website. There he sees a link for a new type of fusion rocket. He’s interested, so he clicks the link. Nowadays, tracking happens one of two general ways. The easy one is that the “real” destination is wrapped up and appended to a link to a tracking site. These links usually have the real destination URL in plain text, but some sites obfuscate the URL so the user can’t bypass the tracking. The other method is to use javascript to change the URL after the user clicks on the link. The user never sees this happen, so, in a way, it’s even worse from a privacy perspective.

 

Either method then directs the user to the tracking site, which tracks the request (and could, by the way, take advantage of any exploits that may exist), and then redirects you to the real site. This takes time, and the user is generally left sitting there with a blank screen.

 

The ping attribute, on the other hand, is much nicer. The owner of the website uses the ping attribute to specify tracking urls. When the user clicks on a link, the browser goes directly to the intended site, and then “pings” the tracking sites in the background. This means that there are no redirects, and no “trickery” to get the user tracking info. It all happens in the background, and that’s where all the privacy concerns come from. But, according to the spec, the browser is intended to have controls to allow a user to decide how the pings are handled. A user can choose to disable them completely, or enable them for some sites, etc.

 

Currently, the development version of Firefox has the bare minimum. That is, it sees and obeys the ping attribute, but there are no fancy GUI interfaces to change settings. Of course, this is the DEVELOPMENT version! They have to start somewhere. It’s not like these new features get a complete GUI, implementation, etc the moment they’re added. This stuff takes time! And it’s enabled by default! Light the torches! Stone the oppressors!

 

Seriously though, I feel confident, based on their past record, that the creators of Firefox will get this right. Sure, it’s enabled by default. But so is Javascript. The “correct” path is not always clear cut. If a feature is disabled by default, the chances of it ever getting enabled are slim. Most users just don’t know how! So, enabling it by default, and then popping up a message stating that the feature is active, here’s how to disable it, etc. is the right thing to do. I’m actually interested in this feature because it will allow the web, at large, to remove some of the trickery currently used to track users. It will allow this information to be up front and not hidden, and I think it will allow the end user greater control over their own security and privacy.

Review – Grand Theft Auto : Liberty City Stories (PSP)

Anticipation : 10
Expectation : 8
Initial Reaction : 9
Overall : 9
Genre : Third-Person Action/Adventure

 

Grand Theft Auto. One of my favorite PS2 games… I’ve been looking forward to this game since it was announced! I initally harbored some reservations about the controls for the game, but it seems that Rockstar did their homework. The controls are excellent and you can *almost* forget that there’s no second analog stick.

 

My first impression of this game was extremely positive. The game loaded just like the PS2 versions do. Cut scenes are excellent. The voices are a little tinny, but not too bad. The graphics are amazing and easily match Grand Theft Auto III. From what I’ve played thus far, it looks like the entire city is virtually identical to Liberty City from GTA3. Rockstar did an incredible job on this game.

 

So, gameplay. So far I’m pretty impressed. There are a few glitches with the camera, but that’s almost to be expected with a “free” camera that follows the character. Camera issues aside, the game is smooth and fun. The first few missions are pretty simple, but engaging. Jacking cars, crashing them all over the place, etc. is as fun as ever. The game seems to flow naturally and keeps the player engaged.

 

Overall, I’m incredibly impressed with this game. And Rockstar has since announced another GTA title headed for the PSP. They claim it’s a new property, so perhaps we’re looking at a completely new city and storyline?

 

I highly recommend this game to all fans of the series.

Review – Ghost in the Shell : Stand Alone Complex (PSP)

Anticipation : 7
Expectation : 6
Initial Reaction : 7
Overall : 6
Genre : First-Person Shooter

 

I’m a big fan of the first Ghost in the Shell movie. If you haven’t seen it, I highly recommend it. So, it stands to reason that I would be interested in a game related to the movie.

 

I received GS:SAC as a Christmas present and eagerly started the game. My first impression of the game was pretty positive. It starts out with some story elements and then moves on to the mission map and character selection screens. Character selection is interesting. You can choose from 4 major characters in the movie. Motoko, Batou, Togusa, or Saito. In addition, you can choose one of 4 different Tachikoma to assist you. Think of the Tachikoma as a big robotic spider with 4 legs. You can customize the characters with 3 weapons, and the Tachikoma with up to 5.

 

This is the first FPS I’ve played on the PSP and the controls are quite good once you get used to them. The analog stick is used for moving forward and back, and sliding left and right. The square and circle buttons are used to turn left and right. The right trigger button is used to fire. The D-Pad is used to change weapons, reload, and some other stuff. Overall, I think these controls work out very well despite bad reviews from other sources. I think those bad reviews come from being used to using 2 analog sticks to control the action on the PS2…

 

I’ve played through a few missions thus far and I’m still pretty impressed. The missions, so far, have been pretty short and to the point, but fun nonetheless. I wouldn’t put this in the same category as something like Half-Life or Doom 3, but still pretty fun.

Game Reviews

I’ve often disagreed with game reviews posted on sites such as GameSpot, IGN, etc. So, since I have my own blog now, I figured I’d write some reviews myself. My intention is to rate the games on a few “at a glance” categories, rather than the entire game in one shot. Later on, I’ll add another entry to update my initial review. I think this will allow me to provide a different perspective on the game and maybe give some idea of how a person may enjoy each game over time.

 

The initial reaction categories will be scored on a scale of 1-10, 1 being the lowest, 10 being the highest. The cartegories are :

 

Anticipation – How much was I looking forward to this game?

Expectation – How “good” did I expect the game to be?

Initial Reaction – My initial reaction to the game (and any gameplay) after the first 15 minutes

Overall – My overall rating of the game *after* I played it the first time. Initial playtime is usually 1-2 hours.

 

I’ll also include the game genre. I’m not going in-depth with details, but more of my feelings about the game, some basic details, and my reactions. Hopefully this will give you a good idea of what to expect. :)

 

I haven’t decided how to do the follow-up reviews yet. Nor have I thought about the final categories I want to rate. When I’m ready to post a final review, I’ll first post how they’ll work.

 

And now, on to reviewing!