Austin Javascript Meetup!

I almost forgot about this, but I just found out about the Austin Javascript meetup… Thanks to @andyhite for the heads up. I’m pretty excited about meeting some people to discuss this stuff because I’ve been having some pretty bad issues with my applications which are heavily reliant on javascript. The bigger it gets, the slower it gets. Especially with pages that have an incredible amount of DOM elements. I’ll probably update after the meetup to talk about how it went :-)

MySQL Workbench 5.2

For those of you who like to see things visually, the newest release of MySQL workbench enables you to connect to your existing MySQL database and reverse engineer it so that you can see the full ERR (Entity Relationship R_____) Diagram in all its glory. For me this is helpful to see when I’m taking over a project I know nothing about. As long as the foreign keys are set up correctly, the tool should be able to do all the work for you. You can also make changes to the Diagram and then have it synchronize with your development/production database. This feature used to be some sort of premium feature that you had to upgrade and pay for, but I just discovered that it’s all included in the free download. I like free stuff.

MySQL Workbench Screeshot
After reverse-engineering the existing MySQL database, you can get an ERR diagram that looks like this. Now your job is to nicely organize the tables.

PHP Makes You a Lazy Programmer

The fact that you don’t have to initialize your variables in PHP makes me a very lazy programmer.  With a large scale project that I’ve been working on for the past 6 months, I’ve really paid the penalty for dumb mistakes like not initializing and resetting my variables.  So just because PHP doesn’t make you do that stuff, it’s always best practice to do so.

PHP String Concatentation Performance

I’m not sure if this is totally correct and I have no fixed way of measuring this (other than that I don’t get any timeout errors anymore) but I’ve noticed a significant difference when choosing between two different methods of string concatenation:

Slow way:

foreach($oranges as $orange){
$orange_str = $orange_str . $orange;

Better way:

foreach($oranges as $orange){
$orange_str .= $orange;

This is obviously simplified for example’s sake, but I had a situation where I was concatenating several hundred (maybe a thousand) elements to a string and I was receiving a “Fatal error: Maximum execution time of 30 seconds exceeded…”.  My best guess is that with the first method, an actual copy of that string is being made in memory so you’re probably taking up twice the amount of memory than you should be.  That’s just my guess.

Client-side Form Validation w/ jQuery… but with a lot of form inputs…

Probably the best example of form validation comes from Jeremy Keith’s DOM Scripting, which is probably the best book I’ve ever picked up.  Ever since I read it a little over two years ago, it definitely got me into the loop as far as modern-day javascript is concerned…  But anyway, he shows you how to create an unobtrusive way of doing form validation.

Basically all you gotta do is give the field you want to be required a class of “required”.  Then in your javascript, you iterate through all the inputs and search for anything with a class of “required”.  If the contents of that field are empty, then you put up an alert and stop the form from being submitted.  I put my own little twist on it by coloring the border of the field red and alerting the user of how many fields need to be filled in.  Since I’ve been a big fan of jQuery lately, i’ve re-done the function in jQuery…


if($(this).val().length < 1){ $(this).css('borderColor','#ff0000'); counter++; } else { $(this).css('borderColor','#ffffff'); } } ); if(counter > 0){ alert("There are "+counter+" fields that need to be completed."); return false; } } );



Sorry the formatting sucks, but I haven’t figured out how to make things look nicely with this WordPress Code Plugin.  In any case, you can totally copy this exact function and use it for your purposes.

So this is pretty straightforward, but the only reason this function has come to my attention lately is because if you’re working on a webpage with oh…. 200+ input fields (i’ve got a page that looks like a spreadsheet), this function is RIDICULOUSLY slow in Internet Explorer 6 and 7.  In fact, IE tells me “Are you sure you want to keep running this script?”.  The reason it takes so long is that i’m using the class selector $(‘.required’) which actually goes through every single input and checks for the class “required”.  It’s nowhere as fast as using the ID selector (an alias of document.getElementByID).  So i dunno, I haven’t yet figured out a solution to this.  I could definitely narrow down the fields that I’m going through but that seems kind of a hack.  I want to be able to say “required” on any field I want to.

Without saying…  it’s pretty clear how much faster my page with 200+ input fields performs on Firefox or Chrome…  IE sucks.  I should re-title my blog to the IE Sucks blog.

jQuery Internet Explorer bug, cloning a cloned element

I’m currently using jQuery 1.3.1 and Internet Explorer throws an error when I try to clone() an element whom itself is a clone.

So if I were to hit “Duplicate” on row 15 in the diagram above, a copy of that row would show up at the end of the table.  The error occurs when I try to Duplicate that row that was just created. The issue has been reported here  I tried using the latest build last night, but still no luck.

I ended up doing a small work around where I copy the first row, then copy the values of the row that is intended to be duplicated into the new row.  Crappy workaround, but whatever.

Side Projects

I have like 3 or 4 side projects that I want to get rolling on…  but I feel like there’s little time to work on those kinda things.  Kristine and I went to Mozart’s this past Saturday so I could work on something I’d been putting off since September and it actually felt really good.  Now that college football season is over, my Saturdays have to be devoted to something, right?

But in order to get these things done, I have to spend way more time than the weekends to do these things.  When I get home from work (where I do web development), sometimes I don’t feel like doing more web work.  I’ve obviously gotta have some sort of balance in my life.  Things like going to the gym, watching my Netflix movies, keeping up with TV shows, PS3, cooking, and just time with Kristine all supercede the time for side projects.  Most likely, i’ll have to give up the Netflix, fall behind on TV shows, or something…  Or maybe I can organize myself enough to actually get all this stuff done!  Maybe.

By the way, hello Facebook…  I was kinda iffy about importing into Facebook notes, since I think I’ve already got enough exposure on Facebook, but whatever.

I’ve also added a bunch of blogs/websites on my blogroll on If you want me to add your blog or website, let me know.