Don’t Use jquery-latest.js!!!!!!!1

I’m guilty.

So guilty.

For years I have pointed pages to jquery-latest.js. Of course, I don’t think anyone would classify hack.premo.biz as a “production site.” I just want the latest damn version of code. I like to experiment with new features.

But I hate babysitting blogs, downloading point releases, and uploading them to my web server. So I used jquery-latest.js.

But now jQuery has taken this away. Sort of. jquery-latest.js is now frozen in time at version 1.11.1.

Well that’s no good. I can’t putter around on an old version for the rest of my life. But I hate babysitting blogs. And downloading point releases. And uploading them to my web server.

What’s a modern coder to do?

Scrape that s.

I made a two part solution. Part one scans the file structure on includes.premo.biz for files that look like jquery 2.x and returns the newest one it finds. It also sends a custom header so the browser reads it as JavaScript. I’m not going to give the URL here because I don’t want to be the next jquery-latest.js. But here’s the (PHP) code:


header( 'Content-Type: application/javascript' );
$contents = scandir( './' );
foreach ($contents as $file) {
if ($file !== '.' && $file !== '..') {
$ext = '';
$parts = explode('.', $file);
$ext = $parts[count($parts) - 1];
if ($ext == 'js') {
if ($parts[0] == 'jquery-2') {
include $file;
}
}
}
}

The second part is more complicated. It pulls in the jQuery Blog RSS feed, looks for a post about a new release, reads the version number, determines if it is newer than the version my server already has and if so pulls it down, then archives the older version. Here’s the PHP for that:


// run on cron.
// check jquery blog rss for updated version news
// http://blog.jquery.com/feed/
header('Content-Type: text/html; charset=UTF-8');
// what's the latest version we've got? (current?)
$ourVersion = '0';
$contents = scandir( './' );
foreach ($contents as $file) {
//if( strpos( $file,'.' ) !== 0 ) {
if ($file !== '.' && $file !== '..') {
$ext = '';
$parts = explode('.', $file);
$ext = $parts[count($parts) - 1];
if ($ext == 'js') {
if ($parts[0] == 'jquery-2') {
//include $file;
$ver = $file;
$ver = str_ireplace('jquery-', '', $ver);
$ver = str_ireplace('.min.js', '', $ver);
$ver = str_ireplace('.js', '', $ver);
$ourVersion = $ver;
}
}
}
}
echo 'ourVersion : ' . $ourVersion;
$rssString = file_get_contents('http://blog.jquery.com/feed/');
$xmle = simplexml_load_string($rssString);
//print_r($xmle);
$articles = $xmle->channel->item;
foreach ($articles as $article) {
$titleLength = strlen($article->title);
$check = trim(substr($article->title, (strlen($article->title) - 8)));
if (trim(substr($article->title, (strlen($article->title) - 8))) == 'Released') {
if (strstr($article->title, 'RC')) {
continue;
echo 'release candidate. BOO!';
}
if (stristr($article->title, 'beta')) {
continue;
echo 'beta. BOO!';
}
echo 'RELEASE POST';
echo $article->title;
// find '2.'
$words = explode(' ', $article->title);
$ver = '0';
foreach ($words as $word) {
if (substr($word, 0, 2) == '2.') {
$ver = $word;
if (strlen($ver) == 3) {
$ver = $ver . '.0';
}
echo 'version : ' . $ver;
if ($ver > $ourVersion) {
echo $ver . ' is greater than ' . $ourVersion . '!';
$jqFilename = 'jquery-' . $ver . '.min.js';
$jqUrl = 'http://code.jquery.com/' . $jqFilename;
echo $jqUrl;
// http://code.jquery.com/jquery-2.1.1.js
$jqueryContents = file_get_contents($jqUrl);
file_put_contents($jqFilename, $jqueryContents);
// move old version
rename('jquery-' . $ourVersion . '.min.js', './jquery_archive/jquery-' . $ourVersion . '.min.js');
break 2;
} else {
echo $ver . ' is NOT greater than ' . $ourVersion . '!';
}
}
}
echo '----------';
}
}

And that’s that. My very own jquery-latest.js.

iOS 7 and the Death of the Button

If you were to log into the dashboard of this blog and look through the drafts — posts that I haven’t published yet — you’d find one from January 31, 2013 — about nine months ago — titled “Buttons Should Look Like Buttons.” And if you looked at the body of that draft post, you’d see a big blank space.

Well, buttons should look like buttons.

Firefox Buttons
Firefox Buttons

A great example of buttons failing to look like buttons — right next to buttons succeeding at looking like buttons — is Firefox. Let’s just focus on the reload button and the home button. When I am moving the mouse pointer on the screen, it’s very easy for me to tell where I have to click in order to trigger the home button. It looks like a button. It has clearly defined edges.

When I want to click the reload button, it’s very hard for me to tell where I have to click. I know the white area inside the black arrow/line/loop would almost certainly register. But what about the white space outside the arrow/line/loop? Can I click all the way out to the edge of the white area? Where is the border between the reload button and the button to the left of it (the menu dropdown)? Is there dead space between the reload button and the menu button? Do they butt up against each other?

It’s impossible to tell by looking.

Firefox is particularly infuriating because there are buttons with precisely defined edges immediately next to buttons with no button edges at all.

With iOS 7, Apple has done away with some clearly defined buttons. I believe that button borders are only gone in places where the button contained only text. In this respect, the button has been replaced — at least visually — by the equivalent of a hyperlink. And we’re all used to text hyperlinks.

I believe there’s one othe reason Apple can get away with that. Fingers are imprecise. And because we know that when we tap on a screen we don’t have single pixel precision, we know that there is compensation for imprecision. We are not anal about our precision, or lack thereof.

Looking ahead, I have seen screenshots of OS X Mavericks. It looks a lot like iOS 7. I am hoping Apple does not do away with button borders in the desktop OS, because when I use a mouse, I want clearly defined buttons.

Star Trek Into Darkness and Physical Media

I really liked Star Trek Into Darkness.

For some reason I had middling expectations going in. It didn’t do quite as well as its predecessor, 2009’s Star Trek, in North America. This informed my opinion. I really liked the 2009 film, and had expected a Pirates of the Caribbean style “box office take of each movie reflects audience appreciation of previous film in franchise” explosion. It didn’t happen. I concluded that Into Darkness must have had something wrong with it.

I saw the previews. It looked like the USS Enterprise got destroyed. My brain replayed a remembered or imagined fanboy’s voice: “How many times can you destroy the Enterprise?” Another question, too dark even for my inner dialogue to whisper: “Is this the film that ends the new Star Trek franchise?”

No, it’s not. Into Darkness is really good. I don’t know why more people didn’t go to see it. I need to watch it a couple more times, but currently I believe I like it better than the previous film. And I really liked the previous film!

Okay, time for side note/personal trivia/minutia that no one except me cares about. The previous film — 2009’s Star Trek — was the first movie I bought on Blu-ray. For years I had held out. I had decided that it wasn’t a big enough jump from DVD, and the next format I was going to adopt was digital download. I had already gone digital with music; I hadn’t bought a CD in years.

Then I bought a PS3. In 2009, when Sony released the Slim model. Suddenly I had a Blu-ray player. Then I saw Star Trek for sale at Walmart … and the Blu-ray was less expensive than the DVD.

My theory is that the some industry was trying to push consumers toward the bright Blu-ray future. Maybe it was the Blu-ray consortium. Maybe it was retailers. Maybe it was both. I went for it hook, line, and sinker.

Somehow I had never redeemed a digital copy of a movie. Today, I can’t remember what my reasoning for this was. After Christmas of 2012, sitting in my basement, I decided to redeem all of the digital copies I had previously ignored. Some had expired. Some I was able to redeem despite their expiration date having passed.

Several weeks later, my wife and I were going to watch The Bourne Legacy. I took the Blu-ray disc out of its case and pushed it into our Blu-ray player. No dice. It wouldn’t play. I took the disc out and looked at it, then put it away. I took the HDMI cable out of our Blu-ray player and put it into our Apple TV. We then watched the film with no issue. That was the moment I decided I don’t need media anymore.

Steam. Digital PC games. It’s great. There are no boxes to take up space. There are no discs to take up space. I rearranged the media center in our basement about a month ago, and now I have all these DVDs and Blu-rays with no place to put them. I already sold the majority of my Xbox 360, PS3, and Wii games — but I still own the games I purchased digitally. I’ll probably hold onto my 360 and PS3 because I have digital libraries. I can store those systems with very little footprint, and bring them out if I feel nostalgic. (This is a hypothetical future. I own several 360 and PS3 games that I haven’t finished yet.)

So I had made the decision to go digital only. Then Star Trek Into Darkness came out on iTunes before DVD and Blu-ray. And I missed this film — the first film I was really looking forward to that I missed because my wife was very pregnant and didn’t want to do much of anything (I still love you Julie). So I bought it. On iTunes.

So 2009’s Star Trek was the first film I purchased on Blu-ray, and 2013’s Star Trek Into Darkness was the first film I purchased digitally, on iTunes. They’re sci-fi movies set in the future.

Now I plan on buying or receiving as gifts two more Apple TVs — one for each remaining TV in our home. I wouldn’t mind if Apple announces a new model next month. I’ve got to sell off these DVDs, Blu-rays … and CDs? Digital — I’m in!

Windows 8 First Impressions

Last night at midnight (all time zones), Windows 8 became available. I downloaded the $39.99 Windows 8 Pro version.

I installed it on my Dell laptop. I’ve been running Windows 7 on this laptop since I got it. It does not have a touchscreen.

Every time I install Windows — and I do it every six months or so — I format the hard drive first. When I started up the Windows 8 installer (running from a USB stick), I backed out twice because I didn’t think I was going to be given the option to format first. Turns out the option is there. I think there’s a trend in all software to make crucial processes — like OS installation — less intimidating to novice users. Unfortunately this also gives advanced users the impression that high-level options are missing even when they’re not. This is a very small gripe, but one that’s really an improvement for the group of users I like to generically refer to “people like my dad.” I’ll get back to Dad.

Windows 8 is the first version of Windows to tightly integrate a user’s online Microsoft/Live.com account. I appreciate this. Also, Apple’s been doing it for a while. One thing I don’t like about it is that in order to log into my computer, I need to use my Live.com password. For most people this probably wouldn’t be an issue, but I use a password manager (1Password) and therefore a long, cryptic, hard-to-remember, hell-even-hard-to-type-in password. That’s annoying, and I was not given the option to use a different (simpler) password to log into my machine. I’m still acclimating to the new OS, so I’m certain there’s a place to change my password. I hope that I will be able to have one password to log into my machine while maintaining my long and cryptic password for Live.com. I will update this post when I find out.

[UPDATE] If your PC’s account is tied to your online Microsoft account, the two accounts will necessarily share the same password. Making your PC’s account a separate account allows for a different password, but stops synching. However, there’s a pretty good third option. You can create a PIN number for logging into your PC. I kind of wonder if this isn’t designed for people like me. I’d rather have an alphanumeric password, but a PIN is tolerable.

I like the look and feel of Windows 8. It leans heavily on the Metro visual style (I refuse to refer to it by its proper name, “Windows 8 Style.”), and that’s a good thing. I would describe Metro as ultra modern. Again, good.

A quirk of Windows 8 is that it’s kind of running two operating systems simultaneously. On one hand, it runs more or less Windows 7, with a desktop, a task bar, Windows Explorer (called something else now), etc. On the other hand, it’s got the Metro UI, which will run all Windows RT applications. I consider this analagous to a hypothetical future version of Mac OS X that also runs all iOS apps.

The first installer I ran after booting into Windows 8 was Google Chrome. I didn’t even launch IE to download the installer — I have a copy on another USB stick. It installed with no issue, and as Chrome does the first time it runs, it asked me to type in my credentials so that it would sync all my bookmarks and extensions. This proceeded as it has every time I’ve installed Chrome on any machine. The 1Password browser extension is quirky and doesn’t sync like other exensions, so I installed it as I always do. It didn’t work the first time I tried it, so I decided to reboot the machine.

When I got to the Metro Start Screen, I clicked on the Google Chrome tile. Chrome launched and … prompted me to type in my credentials so it could sync all my bookmarks and extensions — as if I had never run it before. But I had run it only moments earlier! I looked around the screen, and noticed that there was no taskbar. Also, there was no button to change the size of the Window.

This was the Metro version of the Chrome browser.

I summoned the Start Screen and clicked on the Desktop tile. From there I launched Chrome, which had the 1Password extension installed (working normally now). I switched between the two versions of Chrome, nearly identical, running simultaneously. It appears that Desktop mode uses one user profile, and Metro mode uses another.

This is where I come back to users like my dad. I can’t imagine explaining this scenario to my dad, let alone telling him how to resolve it. Some quick Googling indicates that you can force Chrome to always run in the desktop mode, but it requires a registry hack. Facepalm.

Maybe Google will update Chrome with a checkbox in the settings screen to force Desktop mode at all times. Maybe Microsoft will patch Windows 8 so that each application to be forced to run in Desktop mode. In fairness, maybe there are updates available to Windows 8 that I simply haven’t installed yet.

But this is a problem. In an hour of use I encountered an annoyance clearly directed at making the experience better for novice users, then encountered what could be a serious problem — and I don’t know how I would explain it to users like my dad.

I’m curious about how IE handles the Metro/Desktop issue, but I doubt that I will suggest my dad run IE full time.

I anticipate that Google will work out a resolution to this problem — and I feel comfortable using the word “problem” rather than “issue” — but Windows 8 has been available in its final form for several months and as a full-functional beta for over a year. Why hasn’t this been sorted out already? I will monitor updates to the OS and to Chrome, and update this post as appropriate.

HTML5 and jQuery

The last time I was unemployed, I put together Fav.Premo.biz.  Unemployed again, I’ve dipped into code all over the various projects I’ve got up and running.

With the exception of the main site (i.e., the page you’re reading), I’ve decided to change all of my sites from HTML4 or XHTML to HTML5.  In addition, I’ve decided that now is a good time to stop using Prototype and script.aculo.us and start using jQuery.

I’ve decided to move to HTML5 for two main reasons.  First, HTML5 is more elegant than HTML 4.x or XHTML 1.x.  I love elegance when it comes to programming.  I find that the criteria which determines what is and is not valid HTML5 code is less draconian than for HTML4.x and XHTML1.x.  Also, HTML5 introduces new features that allow developers to add greater functionality with hand-written markup.  Greater flexibility and greater functionality sound pretty elegant to me.  Second, due to these new features, HTML5 provides for greater use of open source technologies.  The long and short of my feelings in this area is that HTML5 gets us one step close to a world without Adobe Flash.  The <audio> and <video> tags allow developers to add rich content to sites without relying on a closed source, proprietary plugin that is a resource hog and a security risk.  Who couldn’t love code that’s more elegant combined with a better user experience?

I’ve decided to move to jQuery because jQuery is updated far more frequently than the JavaScript frameworks I’ve been using up until now — Prototype and script.aculo.us.  For example, jQuery 1.4 was released in January 2010 and jQuery 1.3 was released in January 2009.  When it comes to Prototype’s progression over that time, I can only estimate that it’s seen two bug releases (0.0.0.x) and one maintenance release (0.0.x).  Although putting out regular updates to a code base may be virtuous, it’s not the whole story.  Every time jQuery is updated, its release notes contain graphs showing speed improvements for all major browsers.  Speed improvements on an annual basis.  This just isn’t happening in Prototype or script.aculo.us.

I have a few public-facing sites that use JavaScript here and there, but only one makes heavy use of it: Fav.Premo.biz.  Since modifying code to use both HTML5 and jQuery would be painful at best, I’m going to rewrite Fav.Premo.biz using these new technologies.  It’ll be an undertaking, and it might not be finished soon, but it should be interesting.

Windows Money Savers

Today I checked out Ars Technica’s latest Week in Microsoft, and came across two articles that might save Windows users some money.

The first is about Microsoft’s freshly-out-of-beta antivirus suite.  First look: Microsoft Security Essentials impresses.  In 2006, Microsoft released a retail antivirus program called Windows Live OneCare.  By the end of 2008, Microsoft had announced that it would discontinue this product in favor of a free replacement called Microsoft Security Essentials.

For years I’ve been using AVG Free, but today I uninstalled it (you don’t want two antivirus programs running at the same time) and installed MSE.  It looks like it’s a bit easier to use than AVG and I must say, it’s got some beautiful system tray icons.  I might write a post in the future with some expanded impressions of the product, especially with Windows 7 coming out this month.

Microsoft Security Essentials can be downloaded here.

The second article is about something I’ve known about for years but to which I’ve never committed.  Newegg reveals Windows 7 OEM prices.  I’ve known about OEM versions of Microsoft Windows since before Windows Vista was released.  From what I understand, an OEM copy of Windows is only supposed to be used on a newly built machine.  However, I believe that is more of a suggestion in line with the “Student and Teacher” edition of Microsoft Office (which has since been renamed to the “Home and Student” Edition.)  On Newegg’s listing page, the text appears to be cut off, but here’s the part that caught my eye:

software requires the assembler to provide end user support

That made me think:  Hell, I’m capable of that.  I’d prefer it that way, in fact.  If I were married with kids, I’d probably put an OEM copy of Windows on each of their machines, too.  I wouldn’t suggest it for my parents or my sisters, or even my best (nontechnical) friends, though.  But for me, why not?  Oh, and why is this a money saver?  Depending on the edition of Windows purchased, the OEM version is about 50% cheaper.  The greatest savings percentage-wise appears to be on the Professional Edition, which is the one I’ve got my eye on.

Newegg lists every version of Windows 7 it’s selling here.

So if you’re a technical person, take a look at both of these articles.  If you’re not, consider using Microsoft Security Essentials.  Because it’s free antivirus software.

Mac OS X 10.6 Snow Leopard

I picked up Mac OS X 10.6 Snow Leopard on Friday, as I’m sure many people did.

Somehow, the improvements I notice the most are visual.  Apple has adjusted the default gamma from 1.8 to 2.2.  I don’t know what that means.  However, I can tell very easily that all the colors I’m seeing are more saturated.  It was slightly off-putting at first but I’ve quickly come to appreciate it.  The second thing I’ve noticed — and I might just be imagining this — is that the glass dock’s magnify effect seems to be smoother than it was on 10.5 Leopard.  This doesn’t make sense to me, because I’m under the impression that such things should only be improved on machines with discrete video cards.  My late 2006 MacBook has an integrated Intel video card.

Someone at Apple decided to put the Applications folder in the dock by default.  This is appreciated, since it’s one of the first things I would do after installing Leopard.  There are other changes to the dock.  Menus are charcoal and transparent.  Exposé is available on a per-application basis by clicking and holding on each application’s dock icon.  Also, Exposé is available as an icon, which can be dragged to the dock.  I recommend doing this.

I have no complaints about the software.  It was inexpensive at $29.  The previous update — 10.5 Leopard — cost more than $100 if I remember correctly.  Installation was very similar to that of Leopard.  I performed a clean install.  When I purchased the software at the Apple store, the clerk asked if I had an Intel Mac with Leopard.  I did, and Snow Leopard requires an Intel Mac.  And I read on the Internet some questions about whether a clean install was even possible with Snow Leopard.  Like I said, I was able to do it.  But I do wonder if the process will be any different when performing a clean install of Snow Leopard on top of an existing install of Snow Leopard.  Will the installer ask me to insert my Leopard install disc?  We’ll see.

Overall, Snow Leopard is an inexpensive update which provides some worthwhile new features and clears up some disc space.

Firefox 3.5

Just downloaded Firefox 3.5 from Mozilla’s FTP site (yeah, you’re not really supposed to do that). It’s clear that JavaScript runs faster (which is a big deal to me), but I’ll give the latest browser a thumbs up just because of the New Tab button. For years the first thing I do when I install Firefox on a machine is add the New Tab button to the toolbar. Now it’s there in almost the exact same spot.

Safari 4 Beta

Wow, Safari 4 includes built-in functionality extremely similar to a Firefox extension I use almost daily — Firebug.  It’s accessible through Safari’s Developer menu, which is hidden by default.  I wonder if technology like this being built into browsers will become the norm.  I seem to recall that Mozilla had decided to strip the console or DOM inspector out of future versions of Firefox, but a couple minutes on Google and Wikipedia leave me with no evidence of this.

The conclusion here is that competition is good for the consumer, and developers aren’t often thought of as consumers.  It’s also interesting that Safari, which lacks Firefox’s robust extension architecture, now has built-in functionality similar to my favorite Firefox extension.  This reminds me of the progression of Mac OS (and perhaps Windows) — imitate popular third party applications, and include them with the OS.  Think of iTunes: MP3 player, CD ripper, podcast manager.  Many popular (free) third party applications have faded into obscurity because people don’t need them anymore.

AnswerTips: No Longer Just for NYT.com

Over a year ago, I wrote about a feature on the New York Times website.  The feature works as follows: the reader double-clicks on a word, and a new window opens with a dictionary lookup of that word.  I called it a killer feature.

Today I find that the same feature, powered by the same company (Answers.com) is present on CBSNews.com.  Not bad.