Tales of an IT Nobody

devbox:~$ iptables -A OUTPUT -j DROP

Upgrading to PHPUnit 3.5 on Zend Studio June 29, 2011

Here’s a quick clip I made to show those who hankering to have an updated PHPUnit plugin for Zend Studio.

I hope this video is obsoleted soon so others don’t have to endure the annoyance.

View in HD!

1 Comment on Upgrading to PHPUnit 3.5 on Zend Studio

Worthy of distribution: PHPUnit’s dbunit testing rundown June 27, 2011

This is by far the most complete and best example of a rundown of database testing using PHPUnit‘s “dbunit” extension. It seems it’s difficult to track down a whole rundown on the more technical aspects of ‘getting into it’.

No Comments on Worthy of distribution: PHPUnit’s dbunit testing rundown
Categories: php programming testing

Interfaces in PHP are worthless. Blasphemy? yes. June 6, 2011

What is the purpose of an interface? One would simply say “they’re a contract, etc.”, and you’d be right.

Long story short, all PHP interfaces do – is enforce:

– What methods are implemented
– What their signatures look like

However there’s one HUGE (in my book) fundamental lack: RETURN TYPES.

Thus, I will call interfaces ‘half a contract’.

The PHP developers and contributors often examine other ‘big brother’ languages to determine some direction for the PHP OO offerings. I think this is where this half-assed implementation came from – an aspiration of the language trying too hard to implement features of strongly typed langauges.

Need examples?


PHP misses a very important component of the ‘contract’, return types. In Java / C#  you can define your methods as such:

public string foo() {}

Now, if you’re willing to shell out for the honor system of implementation or to add some spice to your inductive reasoning – go for it. For what little an interface really does for you, it’s not worth the added complexity and lack of piece of mind interfaces in PHP bring to the table.

I believe that in the current state of PHP, developers will end up implementing additional checks and balances to ensure interface implementors are still behaving correctly.

No Comments on Interfaces in PHP are worthless. Blasphemy? yes.
Categories: php programming

PHPUnit and apache ant junitreport task May 13, 2011

There’s not a whole lot of ‘purdy’ interfaces for parsing junit results. For what little that’s out there – it’s even a bit more difficult when you consider the PHP camp looking for a parser for the output from the likes of PHPUnit

If you’re looking for an easy way out with a reasonable result on the unit test report – take a look at my quick and dirty conversion script.
Basically, the default output from PHPUnit’s –log-junit argument doesn’t jive 100% with ant’s junitreport task. This is due to the nested ‘testsuite’ elements in the results. All the script does is flatten those into several files, something the junitreport task expects.
Take a look, maybe it’ll help someone besides myself. 
Someday I may get around to writing a straight up php parser to deal with either the junit xml or the json output from phpunit… maybe…
No Comments on PHPUnit and apache ant junitreport task
Categories: ant php programming purdy

Add “th” (“nd”, “st”) to a number … painlessly – Part 2 April 26, 2011

So in the previous post I posted my recipe for adding rank suffixes to numbers.

Sometimes – a simple problem can be frustratingly goofy to solve. I took a lazy shortcut by passing the number through mktime – then to date to do it for me.

After analyzing what I came up with – it occurred to me that my final approach could be streamlined even better.

Logically we add ‘st,nd,rd’ to numbers 1-3 in all circumstances except when they’re in what I call an ‘eleventh’ verbal range – meaning ‘111’, ‘213’ – we simply do ‘th’.

Since I’ve already determined the wrap around (mod 10) – I gathered maybe just a straight up switch statement would be faster in the big picture …

So here’s the 2nd rendition of my function:

It’s longer for sure – but when run through a simple benchmark:
10 passes of a 100,000 iteration loop the results are pretty clear on how mktime+date can drag it down, it’s not the most scientific method but the gap is big enough to call the results conclusive:

Version 1 (With mktime+date)
Time: 7.79 seconds

Version 2 (See above – switch)
Time: 4.81 seconds

For some reason – solution #2 doesn’t feel as ‘cool’ as the first solution; I like the hackish appeal of it, but there seems to be more elegance in the simplicity, with more truth in it’s nature.

No Comments on Add “th” (“nd”, “st”) to a number … painlessly – Part 2
Categories: php programming

Add “th” (“nd”, “st”) to a number … painlessly. April 25, 2011

There’s not enough out there about this trick – but you don’t need a convoluted solution to add rank indicators to a number, so to add more noise to google search, here my variant is:

Make sure you visit part 2!

Logical breakdown:

First we get mod of $n against 10 – essentially stripping away base 10 from rolling over.

Then, since we word 1 = 1st, 2 = 2nd, 3 = 3rd – see if we have to do anything special for numbers with modulo in that range – otherwise anything from 4-9,0 is nth.

Additionally, we take characters in the ‘eleventh’ verbal range and simply make them all ‘nth’ – so we skip our special date logic and cut straight to $n.’th’.

We check this by sloppily looking for the 2nd to the last character of our number using substr. If it is NOT 1 (Indicating an ‘eleventh’) – we take the logic block for using date to deal with the markup (st, nd, rd)

The only exception to all of this is the substr will wrap the number ‘1’ and take the logic, so we make sure that if it’s explicit value is 1 – we take the logic as well to indicate ‘1st’….

In hindsight… I will expand on whether or not using date() + mktime() is worth it versus the extra effort for manually figuring the st/nd/rd suffixes.

Follow up: I have made a new rendition with speed comparisons

No Comments on Add “th” (“nd”, “st”) to a number … painlessly.
Categories: php programming

Staying on top of things February 16, 2011

One of the things that’s crucial to my workflow where I work; is to know as soon as possible when changes are made to our mainline repositories. Same with tickets in our Trac ticket system, when it hits the pipes – I need to know.

I could setup a fancy hook for Mercurial to email, our source control system we use. But that doesn’t handle Trac and maybe the other oddball items I want to watch.

Having notifications emailed is nice, but I often find the chatter from unrelated emails annoying. I usually have my email off and check every hourish. This helps me focus.

What I’ve found is this: Trac, Mercurial (via hgweb), etc all have a form of RSS/Atom feed available. These feeds from our tools I have a hunch we often overlook.

Bring in feed notifier:

Pretty configurable – supports https:// with login – and the popup notifications are exactly what I need. Noticeable enough but not annoying like having to look to an email screen. (Sad thing is, I have 3 gorgeous 24″ dell monitors – all too busy to have a silly email client up.)

I think when I get some me time, I may put something together to watch these feeds – and use XMPP to notify a configurable list of users. That’d be a fun project with very cool results. But for now – this developer is happy with his RSS addon.

No Comments on Staying on top of things

JQuery UI tip: floated divs inside JQueryUI tabs December 1, 2010

There’s a somewhat confusing problem that can happen if you want to use a multi column (floated div) chunk of content for a tab in JQuery UI tabs.

Basically, the floats inside the tab container cause the tab container to lose it’s height, making your content appear outside of the tab box.

Let us assume our code looks something like this:

The problem is that the floats inside the tab container cause the tab container height to be incorrect (Shown via Firefox)

The solution to this, was to apparently make the tab container float as well, by adding a float:left; width: 100%; to the ‘myTabs‘ div; making the content all appear correct.

End result css:

12 Comments on JQuery UI tip: floated divs inside JQueryUI tabs
Categories: CSS Design php programming

A real life look at crazy variable names July 23, 2010

Here’s a list of somewhat unique/funny variable names I’ve either created or worked with in the past year or so that have made me either stop and chuckle, or shake my fists in doom.

const ZOMBIE
A toggle switch to determine if a cleanup script I wrote should report but not perform the action. I quickly prototyped the argument by typing:  die(ZOMBIE);

Stands for ‘string Hit’ – a variable used for displaying a hit for a web-based game I worked on long ago

Not my own; it’s on the list because it truly is the longest real variable I’ve encountered in the wild. On the bright side, no explanation needed :)  – the best part is it’s an array – so eventually there would have been usage similar to: $aCredentialsRequiringArticulationAgreements[$nIndex] – adding to it’s loveliness.

Not my own; merely a non-descriptive name for an index number.

Not a variable, but a network name – symbolic for a googol: http://www.pcmech.com/article/the-mysterious-1e100-net/

Gosh I thought I had more off the top of my head – guess I’ll just keep adding to this post as time goes by.

No Comments on A real life look at crazy variable names
Categories: programming

Hashing out those regex April 30, 2010

Priceless utility I found not to long ago and thought I’d drop a note about it.

There’s an online version – as well as an Adobe AIR app that is simple and lightweight to install.

Check it out: http://gskinner.com/RegExr/

A must-have for people who have to hammer out some levels of regular expressions

No Comments on Hashing out those regex
Categories: programming tools

PHPCodesniffer and Zend Studio/Eclipse – Part 3 April 29, 2010

( Double-click the video to view more clearly )

No Comments on PHPCodesniffer and Zend Studio/Eclipse – Part 3
Categories: php programming

PHPCodesniffer and Zend Studio/Eclipse – Part 2

( Double-click the video to view more clearly )

No Comments on PHPCodesniffer and Zend Studio/Eclipse – Part 2
Categories: php programming

A priceless gem March 31, 2010

A co-worker linked this to me today as a ‘MUST HAVE JQUERY PLUGIN’. I totally agree.


No Comments on A priceless gem
Categories: programming

Take it to the next step March 14, 2010

Very cool (albeit somehow hectic page) on pythian on a recent Rasmus session.

There’s a HUGE amount of information in this for people wanting to ‘step to the next level’ with web application development. You’ll have to turn over some stones of your own and reapply some of this to you independent scenario, but still a wealth of info!


No Comments on Take it to the next step
Categories: linkspam php programming

Duct tape programmer October 1, 2009

Good article on slashdot about my type of programmer, the ones I try to describe in my ‘good programmer’ posts/rants.


No Comments on Duct tape programmer
Categories: programming

OOP August 20, 2009

Since I can remember, I always thought there was an irrational gravitation towards OOP from people. “If you don’t do OO, you’re not a programmer” is an underlying sentiment in all circles of programmers.

Now, I firmly believe that OO design is definitely a great way to organize, process and a conceptualization tool for programmers to use for managing their code.

However, I’ll add that too many people jump into OOP because they want admission into an ‘elitist’ realm. (Admittedly, programmers like to covet their engineering)

Here’s an interesting sentiment from the almighty MIT that you might find interesting:

Especially a quotation from Paul Graham:

  • Paul Graham, a successful web entrepreneur and programming author, has suggested that the purpose of OOP is to act as a herding mechanism which keeps mediocre programmers in mediocre organizations from “doing too much damage”. This is at the expense of slowing down productive programmers who know how to use more powerful and more compact techniques. [1]

I think all to often the confines of an OO design slow down programmers attempting to encapsulate everything around an abundantly engineered solution for simple processes.

But the biggest issue with OO, is how easy it is to paint yourself into a corner and slow everything down.

No Comments on OOP
Categories: programming rant

Overengineeringalisminity August 5, 2009

More often than not, developers thrive for the opportunity for self-developmental moments by designing something super abstract – and in the end become disappointed and unhappy with it because designing things that are too abstract can be just as limiting, if not more limiting and difficult to work with than something simple.

“KISS – Keep It Simple Stupid.” ~ Micheal Scott

Simplicity can be as profound as complicated abstract programming. Not everything has to have a special class or super abstract format – get over it cause it’s moreso an elitist coffee club for programmers to try and put a notch between them and others.

Do you want to be a real uber programmer, a savant, a pro, the ‘go-to’ guy that everyone trusts?


Don’t put everything on a high horse, know the balance between what should be a quick development and what should be programmed at a framework/abstract level.

Your superiors will love you because they can trust your judgement – it’s a true level of experience and knowledge, NOT your uber xyz class you wrote. Anyone can spend a year writing a ClassOfAwesome, but not everyone knows and understands the balance involved with being a truly productive programmer with a reputation and understanding of what can and should be done right.

It’s the name of the game – you don’t have all the time in the universe, PR/Marketing wants the goods delivered by xyz, every programmer is grumpy and unhappy because they can’t write ‘the perfect code’ – GET OVER IT and start understanding, this is the way it’s been, and will be FOREVER.

If the consumers/PR/Marketing/”The bosses” had their way, you’d have the best, most perfect product done yesterday, right? So, either you’ve already failed, or there’s an unachievable construct of constraints keeping you from doing what DOES need to be done in time.

What you need to do, is get as close as possible to your goals by making a trade off of “perfect” for “got it done”.

Do you -honestly- think the folks at Microsoft are too dumb to write perfect software?
It’s a game of balance – deliver xyz featrues if possible – keep it as secure as possible, your deadline is xyz – Corners have to be cut and it’s up to -you-, the programmer to pick the right ones that don’t end in catastrophe.

No Comments on Overengineeringalisminity
Categories: programming rant

Good programmers

Truths about good programmers:

0. They know the difference between writing it ‘quickly’ and writing it ‘right’
1. They know that the ability to do both is necessary.
2. They know that when writing it quickly, if you have to stop and think about something, think about the data storage schema, not the code.
3. They know that other programmers go through the same stuff, so stop complaining.
4. “Proof of concept” code tends to turn into production code, so don’t show it to marketing unless you’re ready.

No Comments on Good programmers
Categories: programming rant

Programming through inductive reasoning

I’ll never forget my Geometry class in high school, not just because it was fun, but the teacher was kind of an oddball (in a good kind of way). I learned so much from this class it was unbelievable, it was a life changing experience because it taught the true powers of using inductive reasoning (in geometry, things like the sums of the angles of a triangle are always 180 degrees, etc)

Kevin Mitnick demonstrated this power in the 90’s – Organization and inductive reasoning work hand in hand. If you know that something is completely organized around a concept you can safely assume a lot about it without truly knowing.

With that said, my previous post about table organization should already (hopefully) make more sense.

You can safely assume that because a table starts with ‘category’, it contains a p_id, id and title, etc. All of this is nice and consistent, other programmers will know what’s going on as well.

Admittedly I have plenty of stuff that doesn’t revolve around this concept – maybe someday I’ll re-organize.

No Comments on Programming through inductive reasoning
Categories: databases programming

Canonically speaking

A co-worker and I recently got into a discussion regarding table naming – specifically prefixes and how to group them.

A common approach you see, is to group the tables around a system using a prefix for it’s name:


The hardest thing about keeping everything ‘integrated’ is to get other developer’s off of the concept that they need to build their own access control system, or specialized category organization – a category system is a category system, it’s more so a metadata heirarchy to organize data.

I’ve always adopted a canonical approach, similar to how dns server operate, start with what would be your end:


in table terms:


The reason I do this is to keep myself in check with how consistent my designing is –
the schema for ‘newsevents_categories’ and ‘file_categories’ in a conventionally grouped table set may vary widely – the idea is to wean off of these drastic changes and group them by their TRUE function, not just the ‘sub-system’ they compliment – and have their schemas as similar as possible. This ensures better object design and abstraction possibilities as well as truly faster development. You can trust yourself with this naming convention just as much as you can trust yourself with the conventional naming, it just takes a different perspective to have it make sense.

The real issue here is how we name our datastore tables for our various formats – if you have news posts, or faq items you’re likely to see tables like:


Ideally, these generic datastore tables would follow a naming convention revolving around what they truely are, the ‘data’ that drives the system (not to be confused with various metadata tables like category), e.g.:


The idea here is to keep the schemas the same – everything has metadata and other supplemental information that makes it ‘different’, that’s what code is for, bringing those tables together to make them into specific objects.

There’s always the unknown – a good example of a wrench thrown into the mix is if you have file information stored in a table – possibly containing image dimensions, file mime types or category relationships – The thing that makes table designs so inconsistent is typically the metadata that revolves around the specifics of what it’s relevant to. This inconsistent, or ‘unique’ information should be stored boldly in a metadata table.

This post is a little long so I’m going to post the “bring it together” stuff in another post

No Comments on Canonically speaking
Categories: databases programming