Tag Archives: Development

Why Degrade Gracefully?

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.

Tagged , , , ,

IE: Sucking Hard Since Version 5

This code (extracted from a javascript file) works in every major browser except IE (including IE8):

          'frameWidth' : 500,
          'frameHeight' : 465,
          'hideOnContentClick' : false,
          'centerOnScroll' : true,

This is the fix:

          '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.

Tagged , , , , , ,

Firefox is Still King When It Comes to Development

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.

Tagged , ,

OSNews vs. WordPress

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.

Tagged , , , , , ,

The Third Great Platform

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.

Tagged , , , ,

How To REALLY Survive Digg on a Shared Host

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.

Tagged , , , ,

Integers on the Intertubes

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.

Tagged , , , ,

I Switched to Safari 3

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.

Tagged , , , ,

Export Blogsome, Export Slashdot Journal

I was recently issued a challenge: backup a blogsome blog and the content of a Slashdot journal and merge them into a single database. I foolishly accepted this challenge, knowing that Blogsome is based on WordPress. Come to find out that Blogsome doesn’t allow you to backup or export their WordPress content. Also, Slashdot doesn’t provide you a way to export or backup your journal. The prize was sweet: a brand new, fairly expensive, unlocked mobile phone.

If you want to make a mirror of your blogsome blog, you can use a single very powerful command to generate a snapshot of it from any Linux machine or Windows with Cygwin installed:

wget -k -m -r http://url

But this will only create a static HTML mirror of your website. It won’t allow you manipulate content or put it into another database. That leaves only one way to do it – request the entire site page by page, and parse each page individually. RSS is not reliable here, as most people have it set to only 15 or so items and parsing an enormous page make make PHP or your server run out of memory or alloted script execution time.

It’s a multi-step process, to be certain. It was actually painful to go through the process. Requesting over and over, debugging the script line by line. It takes several steps to get things right. But, eventually, I did it. I was able to export a Blogsome blog in its entirety – every entry, all the categories, all the comments with emails and websites …everything.

Slashdot was the same. It took some tinkering, but eventually, I was able to backup a very lengthy Slashdot journal. Again, in its entirety. I got every post, the date, etc. It was not simple, but it worked well. And I not only got them backed up, I merged them into a single database serving up… Small Axe 0.6 (which was a whole adventure of its own, taking current firsttube.com code and “neutralizing” it). Suffice it to say, when I saw all entries working and served in Small Axe, I had a huge smile. Turns out that the person I was doing this for decided against Small Axe (only because it doesn’t yet offer all the bells and whistles WordPress does, even if it is a beast). But it was irrelevant – the hard part was getting the data properly, and that’s done. Migrating to *any* blog database is possible if you have the time, inclination, and skill to write a SQL export/import script.

Here’s how it works:

* Cycle through each page of the blogsome blog. On each page, we get the entries, the URL, the postid, and other relevant info. We set a flag on each item to 0.
* As we retreive the items, we correct the path to images, spacing, smilies, etc.
* Then we cycle through each page individually. We have all the URLs already, so we go through each one and parse comments. It’s important to know that comment owner comments are marked up differently. As we get the comments, we upodate the flag and let the script run on its own. Our 900+ items took about an hour by meta-refreshing the fully rendered page every 3 seconds.
* As we go through the comments, we strip tags we don’t want, we fix emoticons, we fix internal links, spacing, etc. We must expose emails temporarily if we want them to transfer over.
* Finally, we import them all into a central database with an agreed schema.

If you have a Blogsome blog and/or a Slashdot journal you need backed up, I can help you do it. It’s not a simple process, but it is very accurate and preserves whatever data is exposed via HTML. So for the right barter, I would be very motivated to help. If I can simplify the process, I may create an open script to do this. But for now, I’ve got the code.

On a related note, I’ll probably release an updated version of Small Axe sometime in the not too distant future, because the amount of changing I’ve done and all the features I’ve just implemented are killer. Small Axe is FAR from WordPress caliber tested, but it’s SUPER simple and can do all the basics of a normal blog, including templating, smart per-domain caching, blocking by ip, username, email, or keyword, gravatar support, tons of configuration options, RSS and Atom support, threaded commenting, post locking, post expiring, browser identification, slug-based permalinking, and much more.

Tagged , , , , , ,

Featured Link Integration

I integration the “Link Blog” into the RSS feed a few weeks ago, and now I’ve integrated it into the front page. Hope you enjoy.

Tagged ,