Indistinguishable from magic, and available in your pocket.
Your jetpacks have arrived!
Indistinguishable from magic, and available in your pocket.
Your jetpacks have arrived!
I’ve known about Google’s Javascript minifier, Closure Compiler, for awhile, but after sending a couple snippets through it today I realized it’s a pretty impressive piece of work.
Input:
function howManyMatch(arr, pattern) {
var l = arr.length;
var total = 0;
var i = 0;
for (; i < l; i++) {
if (pattern.test(arr[i])) {
total++;
}
}
return total;
}
Output:
function howManyMatch(b,d){for(var e=b.length,c=0,a=0;a<e;a++)d.test(b[a])&&c++;return c};
Or with whitespace re-added:
function howManyMatch(b, d) {
for (var e = b.length, c = 0, a = 0; a < e; a++)
d.test(b[a]) && c++;
return c
}
Optimizations:
var
statements into one declarationif
statement with &&
operator (to save two bytes)Several of these are often done by JS devs by hand. With closure compiler on tap, we no longer have to. Just concentrate on readability and maintainability and let CC worry about size optimization.
“Nobody’s Home to Go Home To” was a 1969 B-side for Billie Davis that I have a weakness for. The bass playing is incredible and the song cleverly jumps between three keys, but the strings and backing vocals kind of take over the recording. I noticed this morning that they’re both panned hard right and the vocal is centered, so I got to work.
In the result, you get a more interesting intro (IMO) and a tighter rhythm section, and you can actually hear the piano, the backbeat snaps of the electric guitar, what sounds like a low temple block on the snare hits, and Billie’s quiet falsettos at the end of the choruses.
[audio:http://www.mrclay.org/wp-content/uploads/2010/12/Billie-Davis-Nobodys-Home-To-Go-Home-To-mrclay-remaster.mp3|titles=Billie Davis – Nobody’s Home To Go Home To (mrclay remaster)]Ultimately what Haiti most needs isn’t so much aid, but trade. Aid accounts for half of Haiti’s economy, and remittances for another quarter — and that’s a path to nowhere.
The United States has approved trade preferences that have already created 6,000 jobs in the garment sector in Haiti, and several big South Korean companies are now planning to open their own factories, creating perhaps another 130,000 jobs.
“Sweatshops,” Americans may be thinking. “Jobs,” Haitians are thinking, and nothing would be more transformative for the country.
Let’s send in doctors to save people from cholera. Let’s send in aid workers to build sustainable sanitation and water systems to help people help themselves. Let’s help educate Haitian children and improve the port so that it can become an exporter. But, above all, let’s send in business investors to create jobs.
Otherwise, there will always be more needs, more crises, more tragedies, more victims. Back in the cholera treatment center here in Mirebalais, health workers were still disinfecting the bed on which Mr. Merilus had died when, in the tent next door for milder cases, a middle-aged woman suddenly collapsed.
Nurses splashed water on her face but could not revive her. So they rushed her to the main cholera hospital tent to take the newly vacant bed there.
And that is the brutal cycle of poverty in Haiti that only jobs and trade can break.
Leslie Nielson will be sorely missed.
At this point very few would expect that you should be able to carry metal items undetected onto a plane, so I don’t have too big a problem with metal detectors at airports. However, society has a general expectation that the image of one’s naked body is private, so we should certainly consider the new scanners a “search” under the Fourth Amendment, requiring some level of probable cause. Is showing up for a flight probable cause for suspicion that you have explosives on you?
Setting aside the question of constitutionality, there seems to be mounting evidence that TSA agents cannot handle the responsibility that this much power brings:
What happens when a terrorist successfully sneaks in bomb materials embedded under the skin? I’d guess the attack would fail for the same reason the underwear bomber’s did: our system already worked. Until all international airports with flights to the U.S. are outfitted with the new scanners and procedures, we still can’t prevent another underwear bomber (he boarded in Amsterdam).
Zend Navigation has a menu helper class that can output a basic nested UL menu. You can set id/class attributes on the A elements, and it adds an “active” classname to A elements in the active branch, but customizing the markup beyond that gets complicated.
In beta 11, Opera’s going to hide all “http(s)://”, and also all querystrings (until you focus the addressbar). Opera’s devs are right that users consider them mostly “gibberish”, but I think this change could cause a ton of problems and confusion for people, especially support staff, and there are plenty of sites/apps still out there with URLs based on querystrings. I can see this setting as short-lived.
It’s quite frequently that an HTML/CSS designer might want to make changes to a live web page. Maybe she doesn’t have write access, or maybe the fixes needed aren’t worth the start-up cost of copying the page locally and working on it there, or multiple designers want to work up ideas on a given page simultaneously. The “Inspect Element” capabilities of most modern browsers will let you make HTML/CSS changes to a live page, but navigating or refreshing causes those changes to be lost, and they’re hard to keep track of.
Here’s a feature wishlist:
Firefox’s Stylish extension looks to come close to (3), allowing you to add user styles to a page/site, like Greasemonkey does for Javascript. It doesn’t look like the editing experience is great, though.
You can manually do (3) and use the CSS Reload Every bookmarklet, but it reloads all CSS, which is kinda of jarring.
A bookmarklet could implement (3) and (4) and persist its settings in a cookie.
Other ideas?
Update: Here’s a bookmarklet that let’s you swap CSS files and stores its settings in a cookie for the current page. Next step is for it to allow adding files and controlling the cookie path.
When economies are struggling, protectionism seems well-intentioned: By “buying American” we can go back that golden fantasy age when everything was American-made and everyone had a decent-paying job and could afford the latest luxuries. I have some examples that I hope can convince you that freer trade benefits everyone. It’s not completely intuitive; we commonly think that one person is always screwed in a deal; if it’s good for [insert foreign country], it must be bad for America.