Posts tagged Development
Why Degrade Gracefully?
Jul 27th
I got thinking today, as I near roll out of an internal helpdesk app heavily using jQuery, why we bother to degrade our scripts so they work without javascript. I get it: some people have javascript disabled in their browser… but my question is this: so what?
Javascript is a core part of web experience today. In fact, I’d say that, on the desktop in the full browser front, if your browser doesn’t support at least HTML 4, javascript, and CSS 2, you’re not playing with the right tools. After all, we expect that people can parse HTML, why not expect that javascript is a pre-requisite for web usage?
Some of us go to great pains to make sure our sites work should a user have javascript disabled. But I’m actually considering the opposite: hiding certain critical elements if you don’t have javascript enabled to ensure that each visitor is on an even playing field. Wrapping submit buttons in jQuery’s append() method, submitting data on click(), and plentifully exchanging JSON data via AJAX throughout ought to properly cripple participation of those who opt out of script execution on my site.
It all comes down to this: if you want your site to reach the widest audience possible, you need to anticipate that the client may not allow you scripting capability. Conversely, on our intranet, and maybe one day on my websites, I’m doing the opposite: if you want to use the site, you’ve got to enable javascript: if you don’t, well… your loss.
IE: Sucking Hard Since Version 5
Jul 9th
This code (extracted from a javascript file) works in every major browser except IE (including IE8):
$('a[rel*=fancybox]').fancybox({ 'frameWidth' : 500, 'frameHeight' : 465, 'hideOnContentClick' : false, 'centerOnScroll' : true, });
This is the fix:
$('a[rel*=fancybox]').fancybox({ 'frameWidth' : 500, 'frameHeight' : 465, 'hideOnContentClick' : false, 'centerOnScroll' : true });
See the difference? Yeah, neither did I. The difference is the last comma in the argument list.
That’s 3 consecutive major versions of IE that have been absolutely crap. Why anyone continues to use IE is beyond me. IE: sucking hard since version 5.
Firefox is Still King When It Comes to Development
Oct 17th
At home, I prefer Camino. At work, I use Google Chrome. I find both to be very pleasurable experiences. But no browser out there comes even close to challenging Firefox when it comes to development.
First of all, extensions such as Stylish and Firebug are invaluable. In fact, scratch Firebug, the default Firefox error console alone is aces to me.
Is there anyone who can tell me why no browser besides Firefox has a “View Background Image” link even as an option? How come no other browser has developer friendly stuff? I know that the Web Inspector in Webkit browsers is really cool – I love Webkit – but ultimately, it’s Firefox I often resort to when I’m doing real work.
OSNews vs. WordPress
Aug 13th
I’ve spent quite a bit of time, over the last 5 or 6 days, diving into WordPress and learning what makes it tick. Parts of WordPress are really impressive – just flat out cool. The way some of it works is fairly complex and deciphering it sometimes means reading page after page after page to understand an entire routine. But sometimes, when you finally see, end to end, how something in WordPress works – I mean really see individual bits of the engine – you have to admit it teaches you a little about PHP. WordPress, underneath it all, is a pretty big beast and its strength and ubiquitous presence comes largely, I think, from the fact that it can do virtually anything. The really sweet plugin system, the ways hooks work, “The Loop,” the dynamic options panel – it’s all very educational.
The interesting thing here is that I’ve browsed the source of Slash, Scoop, phpNuke, and now WordPress, and all of them are definitively more complex and much heavier than the entire OSNews codebase. Now, before you jump all over me – firstly, Slash and Scoop are Perl, and I don’t really read Perl, so I can’t speak as an expert there. Secondly, WordPress and Nuke both are very portable and dynamic, whereas OSNews has a narrow focus and, location-wise, is very static. But that aside, OSNews has withstood simultaneous link bombs from Slashdot and Digg. As amazing as WordPress is, it’s mostly amazing that it functions at all and loads in less than 2 minutes per page with as much going on as I can see behind the scenes. That’s not a cut on WordPress, by the way.
In fact, if anything , what is really impressed upon me is how smooth and simple OSNews code is, if I may be so bold. OSNews runs superfast due, in part, to lots of creative caching, some on-demand, some via cron. But it also does so because of highly efficient queries that are measured for speed on their JOINs, meaning in some cases, it’s faster to do 20 simple queries than one complex one, or build a long and scary chain of “OR x=a OR x=b OR x=c OR x=d…” Watching WordPress code in action is really fun for me, but watching OSNews work knowing what I now know about how much work PHP can cram into its threads is even more fun.
The Third Great Platform
Mar 6th
First, there was the PC.
Then, there was the web.
Now, there is the iPhone.
At long last, the iPhone will become what it was destined to be. In June, when the iPhone 2.0 update is released, the iPhone’s true potential will be unlocked. VoIP? Sure, why not!? Games? You betcha. Exchange, ActiveSync, Remote Wipe, 802.1X? Check. How about access to the entire SDK via XCode, a compact framework (Cocoa Touch), a native emulator, and access to the SQLite databases present in the iPhone file system? Yup. Lastly, how about the most innovative platform in the last 20 years that has single handedly made the mobile web viable? Present and accounted for.
In fact, the iPhone is a new generation, and it’s been grunting along the sidelines as a gloried browser. But come iPhone 2.0, it will validate itself as one of the most amazing devices out there.
How To REALLY Survive Digg on a Shared Host
Jan 2nd
After reading a ridiculous post on “surviving the Digg effect on a shared host,” (and then laughing ridiculously at it), I decided to write a real tutorial on real-live ways not only to survive the Digg effect, but also a simple but powerful way to improve your site’s performance. Read more within.
Integers on the Intertubes
Dec 12th
Some time ago, I wrote an application for my company. Like most weblets I’ve written, this used PHP and either MySQL or MSSQL for the backend. This particular application logged all phone calls. As part of the record, it would record the caller’s account number, which is a 5 or 6 digit integer.
So, I got a phone call from the director of our customer contact department this week. He was concerned about the reports. He made a decision last week that when a call came in that was a lead – in other words, a non-customer, that his people would fill the phone number from the caller ID into the account number field. But when he ran his export reports, he found that hisn techs had entered this phone number for ALL of the calls: 429-496-7295. That’s weird, he said. So he called me and asked why that was. I checked all the calls and most were from one woman, so my first instinct was “Check if her browser has autocomplete turned on”. But he swore that he tried it too and gotten the same result.
I checked the database and sure enough, it was right there: 429-496-7295, in all of the fields. So I went back to the code. In short, I took the input from the form, and declared it like this:
$accountnum = (int) $_POST['accountnum'];
Pretty straightforward: explicitly declare the type. So, I started my debugging by attempting to manually enter the data into the database. Sure enough: the account key field showed this: 4294967295.
So, I went back to the PHP and started by dumping out the raw SQL query:
INSERT INTO calls ('','x','x','x','4294967295','x','x');
What? So the database automatically converts it to this weird phone number and PHP does too? Suddenly it occured to me. One of the benefits of 64-bit computing is the ability to address more memory. There are limits to what can be done in 32-bit computing, and one is that integers have a limit! In this case, a database field called “integer” is limited to numbers between -2,147,483,648 and +2,147,483,647. It just so happens that the number is the same length as a US phone number – 10 digits. Changing the db field to “BIGINT” allowed me to manually run the SQL query and it worked. But the app still didn’t.
PHP’s int() and (int) $var syntaxes both conform to the integer limit. So I devised a work around:
$ac = $_POST['accountnum']; if(!is_numeric($ac) { $ac = (int) $ac; }
It’s not gorgeous, but it will more than suffice for an internal app. We web programmers don’t usually have to deal with big integers, so it’s totally possible that web developers would never have had occasion to handle a situation like this. Here’s looking forward to native 64-bit for our next server, though.
I Switched to Safari 3
Aug 26th
I really did not expect to ever post something like this, but it’s true: I switched to Safari 3.
I love Camino, really I do. But recently, its limitations have been bothering me. I prefer my tabs in a very specific order and often I have several tabs open. If ever I close a tab by mistake, I cannot get that same order without doing tons of work or re-launching. Safari 3 draggable tabs.
One of the things that used to bother me about Safari was that there was no “New Tab” button available for the toolbar. There is now. It’s also got great keychain integration, private browing, the original embedded RSS, true Aqua widgets, resizable text boxes, easy PDF integration, and it’s super-fast.
Camino doesn’t support Ad-Block, but rather, stylesheet-based filtering. Safari does that too, by default, and it’s even easier to use than it is in Camino. Safari doesn’t have any Flash problems and once you add “Safari Stand” and enable the debug menu, you have a perfect drop in replacement.
My biggest complaint about Camino was the lack of development tools. It doesn’t have a Javascript debugger (ChimericalConsole never worked me for), doesn’t have a decent source viewer, doesn’t have many third party hacks to add functionality – it’s a browser for users, not developers. Without XUL, it’s tough to add features easily. And that made it tough to use for me. When I did any serious work, I’d always switch to Opera or, more recently, Safari 3. Safari 3’s Inspector is just awesome.
So… for now, I am Opera on Windows and Safari on Mac. My browser requirements are more demanding than most. I have felt for some time that Opera and Firefox on Mac just “feel” wrong, they don’t fit. So we’ll see how the Safari experiment goes.

