Archive | February, 2012

Free Ubuntu Fonts

Ubuntu has released their own custom-designed fonts with all the bells and whistles: bold, italic, condensed, proportional and monospace. Released under the Ubuntu Font License (vice the earlier Red Hat and Oracle Liberation fonts [ed: updated link, note newer version], released under the GPL with a font exception – embedding the font is ‘non-viral’). Check them out at: http://font.ubuntu.com/

Dead links, what to do?

Reviewing my blog’s access logs, I see a miscreant application was denied access thanks to the BadBehavior plugin. Curious, I followed the link as, truth to tell, I don’t recall all my posts, especially one seven years old. When I reviewed the post, I tried to follow the links, and 4 out of 6 are dead. What should I do about old, dead links? The post was pretty much a “look at this” piece, pointing to content mostly gone by now. Should I just kill the post, prune off the dead links with an editorial comment on what used to be there, or ignore it?

I don’t consider this blog to be much of an historical document, so I’m not concerned about defacing it. Google searches are likely finding the keywords on that page and redirecting folks here, which is unfortunately, as the page has really lost its value. Just deleting the page hurts the Google page rank of the domain when the crawlers can’t find it any more. Properly curating the page with editorial notes that summarize what the links were about, that they are dead now, and what the whole point of the post was, would be very nice, but is really more effort than is reasonable to ask, especially when you consider there are likely to be 2,000 other posts needing curation.

The best lesson to take away from this is not to write posts just saying “Check this out” and instead summarize what’s there to be seen, what it means, and why it’s important enough to point out to your readers.

Fixing shorttags in PHP source code

Short tags is a topic of some controversy in coding circles: wrapping your script in less-than, question-mark x 2, greater-than signs is easy to type and flows off the fingers but can be a source of confusion to some parsers. In PHP, it is not recommended, but there is a “shorttag” option available to override it globally or locally.

I recently was asked to edit some older PHP code and found it was littered with short tags, both the <? script goes here ?> variety and the shortcut output <?=”Print this string”?> variety, which need to be replaced by <?php script goes here ?> and <?php echo “Print this string” ?> respectively. A bit beyond my search-and-replace regex or sed skills, I found a fairly elegant solution on StackOverflow, which uses PHP to rewrite PHP:

#! /usr/bin/php
 <?php
 global $argv;
$contents = file_get_contents($argv[1]) or die;
 $tokens = token_get_all($contents);
 $tokens[] = array(0x7E0F7E0F,"",-1);
foreach($tokens as $ix => $token) {
 if(is_array($token)) {
 list($toktype, $src) = $token;
 if ($toktype == T_OPEN_TAG) {
 if (($src == "<?") && ($tokens[$ix+1][0] != T_STRING)) {
 $src = "<?php";
 if ($tokens[$ix+1][0] != T_WHITESPACE) {
 $src .= " ";
 }
 }
 }
 else if($toktype == T_OPEN_TAG_WITH_ECHO) {
 $src = "<?php echo";
 if($tokens[$ix+1][0] != T_WHITESPACE) {
 $src .= " ";
 }
 }
 print $src;
 }
 else {
 print $token;
 }
 }

It just needed a little shell wrapper to take in all the files (which I’d renamed *.php.old and archived and made a backup of) and put them out as *.php.old.new. Again, a quick rename and I was in business. I was astounded to find it ran the first time!

#! /bin/bash
FILES=./*.php.old
 for f in $FILES
 do
 echo "phpize $f >$f.new"
 ./phpize.php $f>$f.new
 done

Staples: “that was easy” FAIL

I’m a regular customer of Staples, web-based and brick-and-mortar. I’m attempting to reset my online password. This function failed the “that was easy” motto. Forgive my crankiness, but I design and develop web pages for a living and I expect better from a world-class organization like Staples. In accordance with good security practices, I’m using a password consisting of upper- and lower-case alphabetic, numeric and punctuation characters. I am not trying anything tricky like Alt+numeric-keypad characters. I’m using a en-us keyboard layout. Here are the problems with the message I’m getting:

1. “Sorry, but an error has been made.” is atrociously passive grammar. And who has made an error? The operator, the web site?

2. “The information you entered contains invalid characters.” Which ones? The email address or the password fields? The “5” the “@” the hyphen or the “e” ?

3. “Please try again” How many times should I try again, and what is it that I should try differently?

4. If you have a password policy (like “no punctuation”), you need to tell the person typing it in.

5. If an operator can type it in from the keyboard, it _is_ a valid character. You need to be liberal in what you accept.

Staples, you lost a sale today, and you’ve lost my trust that you know how to run a secure website.

[OT] Hitler, Apple, Gates and Godwin’s Law

Perhaps there is a corollary (if not, let’s coin Roche’s Rule) to Godwin’s Law — briefly, that any discussion is practically over when it degenerates to metaphors of Naziism — that those who call off Godwin are in turn berated as thread police, censors, infringers on some divine human right to drag threads off topic and, yes, with all the irony involved, Nazis. In this response, I make the foolish mistake of not ignoring the troll bait. I am as guilty of overreacting as the hyperbole used by the original poster to compare Apple with Hitler.

Hitler burned, gassed, tortured, shot seven million Jews in concentration camps. Millions more, of all faiths, died defeating him.

The late Steve Jobs charged premium dollars (and sometimes outrageous fees!) to keep his company out there and competing in the tough markets of computers and software. Apple makes beautiful industrial design, often as impractical as Lamborghinis. They sell DRM-crippled music. They have pushed the envelope of consumer computing, much as Microsoft “innovated” back in the days when they had competition. Apple has sold a billion songs. I admire and respect Jobs, as an empire builder, like Gates and Olsen and Carnegie before him, but I don’t spend the money to buy many of his products, as I’m cheap. I have philosophical differences with Apple, too, but I’d probably buy an iPhone if I hit the lottery. They’re shiny. But, unlike some, I’m not betting my business on them.

Microsoft’s behavior has often been as outrageous as Apples, having been pulled into court a few times, regularly making their large corporate customers buy computers with Windows pre-installed and then pay again and again for licenses to run their OS, access their machines remotely, or run software on them, switching their license fees and terms and dropping products that are near and dear to all of our hearts. I’m not ABM as much as preferring what works best. Windows DirectX is supposed to be a good gaming platform. I hear XBoxes are great for Netflix. I use a Microsoft keyboard and mouse. I happen to think that Microsoft Windows on the desktop is here to stay, even with the incredible drag it puts on businesses with malware problems, poor performance and high cost. I do not, however, think that “the desktop” is here to stay, as a metaphor for people to do their business, and I look forward to Microsoft’s stranglehold on their clients breaking with some Next Big Thing. Off the desktop, I really don’t see Microsoft having contributed that much to the state of computing through their many (many, many) acquisitions. I prefer other brands for networking, server OSes, database servers, programming languages and technologies, not through some blind hatred as much as hard-earned experience. But that’s off-topic…

[The poster who tripped Godwin’s Law…] ‘s post doesn’t have much to do with the topic of the thread, Linux, and is a really offensive comparison to some of us. Hitler and Naziism was one of the most horrific incidents of modern history and to minimize it by comparing it to shiny overpriced phones dehumanizes us all. Gates is not Idi Amin. The cellphone landscape does not resemble Dafur. Let’s get some perspective here, people.

There’s a difference between policing a thread, trying to manage to stay on topic, and censorship. I invoked Godwin’s Law to point out that the thread has likely run its course. You’re free to say what you want. I’m free to point out you’re off-topic.

So, if you want to keep on-topic on the “Linux Desktop Thread” I have some insight and informed opinions on the matter, having run Linux as my desktop for six years now, supporting a half-dozen clients with LAMP boxes in their offices, and developed some dozen or more LAMP applications. If you want to go off-kilter onto iPhones and Google as “liars and thieves,” why don’t you go start your own thread?

(Full disclosure: as I’ve mentioned before [blog.tedroche.com/disclaimers], I purchased a tiny bit of Apple stock a long time ago. It’s now worth a lot more than I paid for it, through no fault nor skill of mine. I also own tiny bits of Red Hat, HP and Microsoft. They’re still tiny. I don’t think this influences my opinion all that much, but I let my possible biases be known.)

Powered by WordPress. Designed by Woo Themes

This work by Ted Roche is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.