Pulling cheap tricks with JQuery

Let’s say you got some tabular data with input button/anchor tags that ideally will cause previously hidden data to appear.

Attempt 1 went like:

//Simulated row
  <a href="#" onclick="$('#my_SubData<?= $currentRecordId ?>').slideToggle(); return false">Click me to show stuff!</a><br>
  <div id="my_SubData<?= $currentRecordId; ?>" style="display: none "> Blah blah blah....</div>

I hate messy code, but unfortunately this is PHP so there’s only so much one borderline pyschotic developer can accomplish. Or is there?

//prior to my table
                return false;
  <a href="#my_SubData<?= $currentRecordId ?>')" class="actionable">Click me to show stuff!</a><br>
  <div id="my_SubData<?= $currentRecordId; ?>" style="display: none "> Blah blah blah....</div>

It’s almost elegant if you ignore the PHP inject. JQuery’s .live handler automatically routes all unhandled click events to the closest “.actionable” classed element, then inside the live event handler, you grab the anchor’s href value to get the element Id of what you want to edit.

Stupid PHP tricks: The Array builder

class ArrayBuilder {
    public function __set($name, $value){
        return $this->$name = $value;
    public function __call($name, $value){
        if(count($value) == 1){
            $this->$name = $value[0];
            $this->$name = $value;
        return $this;
    public function toArray(){
        return get_object_vars($this);
    public static function FACTORY(){
        return new ArrayBuilder();


  $x = ArrayBuilder::FACTORY()->hello("World")->digits(1,2,3,4,5)->foo("BaR?")->toArray();
   array(3) {
  string(5) "World"
  array(5) {
  string(4) "BaR?"

Works great for factory scenarios and confusing the $*&! out of the unwary.

Hosting local, the ghetto fabulous way

One of the first big draws of Ruby on Rails in late 2006 was the ability to host my development environment locally. Not only did this cut down on the chore work of developing in an environment, but it probably also boosted productivity for me substantially. A year later when I started teaching myself Python, another nail was hammered into the coffin that is my opinion of PHP. That said, I’ve toyed with a lot of different idea’s of hosting a PHP environment locally but to a degree stymied in the effort.
Continue reading

Bridging the gap: GIT & SVN, B.F.F.


I’ve been using SVN for several years now, since late 2005 or early 2006, and its done me well since then. But a new darling has entered my life and its name is Git. I like git for some very specific reasons: It’s stupid easy to work with and as good or better then SVN for reliability. Also it helps that my preferred IDE, Komodo, recognizes and works with Git as well.
That said, I use google code for hosting my public projects and it only supports SVN and HG. So one night I read up on git and noticed that it had a plugin/support for bridging to a SVN managed repo. So began my journey.
Continue reading

Canvas tag: Collision detection & pixel decay

UPDATED: March 14, 2011 here

Continuing my tests/experiments with the Canvas tag has led to the Ping prototype. I had 3 minimal things I wanted to accomplish: Detecting the intersection of a 360 degree arc of ray/line segments to previously defined in map shapes; a visual decay/fade out of intersection points on the canvas, and lastly a test of performance. In addition I decided to experiment with another approach to Javascript object construction in the hopes of getting a performance gain.
Continue reading

Thoughts on my corner of the Web industry

I’ve been busy with professional contractination work, which is a word I just made up to describe the chaos that goes on while being vetted for a new client. “Do you know PHP5?”, “What is class inheritence?”, “What’s the difference between include and require?”, etc. I wish I could make a indexed video of me answering these questions but I don’t think that would work for some reason. Still its just par for the course and I really don’t blame the client or the client’s gatekeeper asking because I’ve been on the other side of the fence, vetting out people and its a miserable task.

My resume shows 5 years of contract work and I’ve got half a dozen references ranging from developer peer’s to team managers and c-letter people…but from what I’ve seen none of that matters. Out of respect for all involved, I won’t be mentioning names, employer, or anything specific. Last thing I want is to kill someone’s career or tarnish a client’s reputation. That said, I’ve seen some pretty terrible “Senior” developers. What I mean by terrible has little to do with how they solve problems, but the fact that they don’t solve problems.

One recent case, I worked with a “Sr.” developer that proclaimed themselves “Team lead”, “Chief Architect”, and “Dev. manager” which was surprising because I finished three different projects on time and tested for production use in the time that this individual struggled with one project. Speaking to the CTO of the company I got to look at the person’s resume and it all made sense. They had been in the industry for 4-5 years as well, but 3 and a half of those years was as a “junior” developer in a fairly large team. Then they jumped or got booted and fell into my client’s company and became the defacto “Senior” developer because there was no one else. I think two things fed this person’s loose grip on their reality. In very large company’s, I’ve noticed that junior developers are not to be seen or heard and instead are programmers. They aren’t given opportunities to grow through mistakes and failures because that’s not what they are there for. Then the other side is that without peer review from competent peers… its easy to imagine your poop smells like roses.

Another case was a peer that got signed to the same company as me, both as contract to hire. One unique thing about this situation was that I knew NOTHING about the language or technology being used. The only saving grace is that the team leads had re-implemented a better/saner version of a framework pattern I had designed a few years ago. So of course I struggled in the first week and somewhat into the second week, but fortunately the language in use was imperative object oriented so everything eventually clicked for me. I won’t lie and say I was a super star, but I did my best to pull the line and help the team meet its goals. Meanwhile the other contract made a lot of mistakes: it’s generally a bad thing to hit on the female staff at work, if the product lead takes the time out to give you advice… its probably cause your fucking up, and lastly do not alienate your peers. Healthy dev. teams are like Survivor… if you become the weakest link and cause others to work harder to cover your ass, you will find yourself out of a job.

What I am getting at is that, in both cases it would be tough to figure out if someone can actually do the work needed for an employer. Their resume might look amazing or their credentials impeccable, but neither really mean much. The subject of vetting out good candidates has been covered over and over across the web and print…so I will keep my advice simple. If you have a small team or no team, go with established recruiting firms that will incur penalties to themselves if they recommend a dud ( generally 5-10 business days covered ) or if you do have a team, get them involved in the last stage interviews and see if this person fits in. I am sorry, I know this would seem to eliminate anyone who has text anxiety or social disorders… but time after time Geeks & Nerds recognize their own.