Where all of my placeholder images come from

Years back, I happened upon fractalsponge.net, a one-man effort in creating extremely high resolution Star Wars renders of the various spacecraft in that fictional universe.

Checking Akamai cache expiry times on your website’s pages

This involves sending some custom headers along with your HTTP GET request, so utilize either the wget command line tool:

wget -S -O /dev/null --header="Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no" http://www.sportsnet.ca/

Or the curl command line tool:

curl -H "Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no" -IXGET http://www.sportsnet.ca/

The X-Cache-Key setting will contain the amount of time the URL is cached for; in this example, the time is 1 minute (“1m”):

X-Cache-Key: /L/370/77322/1m/www.sportsnet.ca/

Running Windows? No problem – grab a compiled version of wget for Windows.

Source: Stack Overflow – What’s the best way to troubleshoot Akamai headers these days?

Fast 404s for missing images in WordPress

If you’re looking to replace WordPress’s long load time for a 404 error page for at least the missing images on your website, consider adding the following to the .htaccess file that sits in the root of your WordPress installation airblown inflatables canada:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .* /wp-content/themes/your-theme/images/placeholder.png [L]

In practice, this looks something like:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ 
RewriteRule .* /wp-content/themes/your-theme/images/placeholder.png [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Working with Nginx? No problem, here’s the equivalent commands that go into your site configuration file:

location ~* (jpg|jpeg|gif|png) {
	expires 30d;
	access_log off;

	error_page 404 /wp-content/themes/your-theme/images/placeholder.png;
}

Mark Lynas repudiates the anti-genetically modified crops movement

This is a blockbuster speech – in the link, there is a video of Mark Lynas making a speech to the Oxford Farming Conference confessing that he’s been quite wrong on opposing genetically modified crops for reasons of not much more than being obstinately anti-science/progress.

It’s an incredible eye opener, and peaks the hopes that environmentalists who deride others for being anti-science when it comes to climate change indulge in some humility and take a good look at if they themselves are being anti-science in another sphere (anti-GMO).

Mark Lynas – Lecture to Oxford Farming Conference, 3 January 2013

I want to start with some apologies. For the record, here and upfront, I apologise for having spent several years ripping up GM crops. I am also sorry that I helped to start the anti-GM movement back in the mid 1990s, and that I thereby assisted in demonising an important technological option which can be used to benefit the environment.

As an environmentalist, and someone who believes that everyone in this world has a right to a healthy and nutritious diet of their choosing, I could not have chosen a more counter-productive path. I now regret it completely.

So I guess you’ll be wondering – what happened between 1995 and now that made me not only change my mind but come here and admit it? Well, the answer is fairly simple: I discovered science, and in the process I hope I became a better environmentalist.

When I first heard about Monsanto’s GM soya I knew exactly what I thought. Here was a big American corporation with a nasty track record, putting something new and experimental into our food without telling us. Mixing genes between species seemed to be about as unnatural as you can get – here was humankind acquiring too much technological power; something was bound to go horribly wrong. These genes would spread like some kind of living pollution. It was the stuff of nightmares.

These fears spread like wildfire, and within a few years GM was essentially banned in Europe, and our worries were exported by NGOs like Greenpeace and Friends of the Earth to Africa, India and the rest of Asia, where GM is still banned today. This was the most successful campaign I have ever been involved with.

This was also explicitly an anti-science movement. We employed a lot of imagery about scientists in their labs cackling demonically as they tinkered with the very building blocks of life. Hence the Frankenstein food tag – this absolutely was about deep-seated fears of scientific powers being used secretly for unnatural ends. What we didn’t realise at the time was that the real Frankenstein’s monster was not GM technology, but our reaction against it.

Read More

Profiling a MySQL query to optimize performance

The Query Profiler in MySQL isn’t something I’ve spent much time in recently – with more sites making use of popular CMSes like WordPress, query performance isn’t something that’s top of mind anymore (Automatic seems to do a good job in this area). But it’s still a useful tool when you’ve already picked the low hanging fruit off of the optimization tree.

Profiling is enabled on an individual basis for each MySQL session; when the session ends, all profiling information is lost.

To check to see if profiling is currently enabled for your session, do:

mysql> SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
|           0 |
+-------------+
1 row in set (0.00 sec)

Next, enable profiling for all queries:

mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)

And run the query you’d like to see a breakdown for:

mysql> SELECT COUNT(*) FROM wp_posts;
+----------+
| count(*) |
+----------+
|   238121 |
+----------+
1 row in set (18.80 sec)

Get the numeric ID of the profile we want to see:

mysql> SHOW PROFILES;
+----------+----------+---------------------------------------+
| Query_ID | Duration | Query                                 |
+----------+----------+---------------------------------------+
|        1 | 18.80000 | SELECT COUNT(*) FROM wp_posts;        |
+----------+----------+---------------------------------------+
1 row in set (0.00 sec)

Finally, actually see the query profiled:

mysql> SHOW PROFILE FOR QUERY 1;
+--------------------------------+-----------+
| Status                         | Duration  |
+--------------------------------+-----------+
| starting                       |  0.000027 |
| checking query cache for query |  0.000041 |
| checking permissions           |  0.000017 |
| Opening tables                 |  0.000018 |
| System lock                    |  0.000008 |
| Table lock                     |  0.000037 |
| init                           |  0.000014 |
| optimizing                     |  0.000008 |
| statistics                     |  0.000016 |
| preparing                      |  0.000013 |
| executing                      |  0.000008 |
| Sending data                   | 18.802902 |
| end                            |  0.000015 |
| end                            |  0.000008 |
| query end                      |  0.000006 |
| storing result in query cache  |  0.000453 |
| freeing items                  |  0.000009 |
| closing tables                 |  0.000007 |
| logging slow query             |  0.000007 |
| logging slow query             |  0.000031 |
| cleaning up                    |  0.000005 |
+--------------------------------+-----------+
21 rows in set (0.00 sec)

To get even more in depth, check out the optional type values for the SHOW PROFILE command, or use SHOW PROFILE ALL FOR QUERY 1; and view everything MySQL’s got at once.

Why the liberal arts are important: Learning to reflect

I hold a degree in computer science. I’ve been employed for 10+ years as a software developer. When the occasional news story comes out about liberal arts majors having trouble finding employment in today’s economy, there’s a part of me that feels smug. It says, “Yeah. All right. Go us. We made the right choice. We were rational about the job market.” And it is indeed very easy to indulge that part of myself by lapping up news that confirms my life choices.

But I’m also something of a contrarian. (Actually what’s probably more accurate is I hate to be wrong, so I feel compelled to understand the pro-arts side of the argument to prepare for it.) What is the appeal of the liberal arts in 2012? Are they necessary? In the end, I think my final position is that the liberal arts are important, and if a comparison must be done, they’re likely to  be more important than computer science or engineering. My reasoning: Engineering may allow us to live longer and better, but liberal arts let us find understanding in others and ourselves.

As evidence, I offer portions of a piece from 1997 by the late Earl Shorris. It’s about his attempt to teach a group of impoverished Americans about the humanities. It’s really quite profound and, I think, one of the only true ways to permanently solve poverty in the world. Enjoy the read.

Harper’s Magazine – On the Uses of a Liberal Education, Part II: As a weapon in the hands of the restless poor

We had never met before. The conversation around us focused on the abuse of women. [Viniece Walker]’s eyes were perfectly opaque—hostile, prison eyes. Her mouth was set in the beginning of a sneer.

“You got to begin with the children,” she said, speaking rapidly, clipping out the street sounds as they came into her speech.

She paused long enough to let the change of direction take effect, then resumed the rapid, rhythmless speech. “You’ve got to teach the moral life of downtown to the children. And the way you do that, Earl, is by taking them downtown to plays, museums, concerts, lectures, where they can learn the moral life of downtown.”

I smiled at her, misunderstanding, thinking I was indulging her. “And then they won’t be poor anymore?”

She read every nuance of my response, and answered angrily, “And they won’t be poor no more.”

“What you mean is—”

“What I mean is what I said—a moral alternative to the street.”

She didn’t speak of jobs or money. In that, she was like the others I had listened to. No one had spoken of jobs or money. But how could the “moral life of downtown” lead anyone out from the surround of force? How could a museum push poverty away? Who can dress in statues or eat the past? And what of the political life? Had Niecie skipped a step or failed to take a step? The way out of poverty was politics, not the “moral life of downtown.”

But to enter the public world, to practice the political life, the poor had first to learn to reflect. That was what Niecie meant by the “moral life of downtown.” She did not make the error of divorcing ethics from politics. Niecie had simply said, in a kind of shorthand, that no one could step out of the panicking circumstance of poverty directly into the public world.

Although she did not say so, I was sure that when she spoke of the “moral life of downtown” she meant something that had happened to her. With no job and no money, a prisoner, she had undergone a radical transformation. She had followed the same path that led to the invention of politics in ancient Greece. She had learned to reflect.

In further conversation it became clear that when she spoke of “the moral life of downtown” she meant the humanities, the study of human constructs and concerns, which has been the source of reflection for the secular world since the Greeks first stepped back from nature to experience wonder at what they beheld.

If the political life was the way out of poverty, the humanities provided an entrance to reflection and the political life. The poor did not need anyone to release them; an escape route existed. But to open this avenue to reflection and politics a major distinction between the preparation for the life of the rich and the life of the poor had to be eliminated.

Read More

All hail the generalist

I’ll have to buy Mr. Mansharamani a drink or two if I ever meet him at a bar. I’ve considered myself a generalist for nearly a decade, but I’ve at times had difficulty explaining how useful it is to have a broader viewpoint when looking at specific problems.

All Hail the Generalist

Approximately 2,700 years ago, the Greek poet Archilochus wrote that “The fox knows many things, but the hedgehog knows one big thing.” Isaiah Berlin’s 1953 essay “The Fox and the Hedgehog” contrasts hedgehogs that “relate everything to a single, central vision” with foxes who “pursue many ends connected…if at all, only in some de facto way.” It’s really a story of specialists vs. generalists.

In the six decades since Berlin’s essay was published, hedgehogs have come to dominate academia, medicine, finance, law, and many other professional domains. Specialists with deep expertise have ruled the roost, climbing to higher and higher positions. To advance in one’s career, it was most efficient to specialize.

For various reasons, though, the specialist era is waning. The future may belong to the generalist. Why’s that? To begin, our highly interconnected and global economy means that seemingly unrelated developments can affect each other. Consider the Miami condo market, which has rebounded quite nicely since 2008 on the back of strong demand from Latin American buyers. But perhaps a slowdown in China, which can take away the “bid” for certain industrial commodities, might adversely affect many of the Latin American extraction-based companies, countries, and economies. How many real estate professionals in Miami are closely watching Chinese economic developments?

Secondly, specialists toil within a singular tradition and apply formulaic solutions to situations that are rarely well-defined. This often results in intellectual acrobatics to justify one’s perspective in the face of conflicting data. Think about Alan Greenspan’s public admission of “finding a flaw” in his worldview. Academics and serious economists were dogmatically dedicated to the efficient market hypothesis — contributing to the inflation of an unprecedented credit bubble between 2001 and 2007.

Finally, there appears to be reasonable and robust data suggesting that generalists are better at navigating uncertainty. Professor Phillip Tetlock conducted a 20+ year study of 284 professional forecasters. He asked them to predict the probability of various occurrences both within and outside of their areas of expertise. Analysis of the 80,000+ forecasts found that experts are less accurate predictors than non-experts in their area of expertise.

Tetlock’s conclusion: when seeking accuracy of predictions, it is better to turn to those like “Berlin’s prototypical fox, those who know many little things, draw from an eclectic array of traditions, and accept ambiguity and contradictions.” Ideological reliance on a single perspective appears detrimental to one’s ability to successfully navigate vague or poorly-defined situations (which are more prevalent today than ever before).

Read More

The skills gap myth: Survey reveals why companies can’t find “good people”

As a software developer I’m always bemused by the leaders of industry who lament the lack of skilled workers to fill open positions in my field. It seems that too many forget one of the most basic rules of capitalism: If demand is low, you’re not offering enough value. As it fits this scenario: If developers aren’t applying for your position, you’re not offering enough compensation.

This is rather cynical, but I imagine that these pronouncements aren’t for my ears anyways: They’re made to justify keeping “information technology professionals” on the overtime exempt list, or to raise immigration caps for technology workers. (Which is often well justified, but I wonder at the distortion it introduces to the domestic labour pool.)

TIME.com – The Skills Gap Myth: Why Companies Can’t Find Good People

The first thing that makes me wonder about the supposed “skill gap” is that, when pressed for more evidence, roughly 10% of employers admit that the problem is really that the candidates they want won’t accept the positions at the wage level being offered. That’s not a skill shortage, it’s simply being unwilling to pay the going price.

But the heart of the real story about employer difficulties in hiring can be seen in the Manpower data showing that only 15% of employers who say they see a skill shortage say that the issue is a lack of candidate knowledge, which is what we’d normally think of as skill. Instead, by far the most important shortfall they see in candidates is a lack of experience doing similar jobs.

Employers are not looking to hire entry-level applicants right out of school. They want experienced candidates who can contribute immediately with no training or start-up time. That’s certainly understandable, but the only people who can do that are those who have done virtually the same job before, and that often requires a skill set that, in a rapidly changing world, may die out soon after it is perfected.

Read More

We are not now that strength which in old days; Moved earth and heaven

Despite being originally taken in 1962, the above remains a well-recognized photograph: That’s James Meredith, the first black student admitted to the University of Mississippi, walking to class accompanied by U.S. Marshal James McShane on his left and John Doar of the Justice Department to his right.

John Doar was bestowed with the Presidential Medal of Freedom yesterday. Sometimes it seems like the world is running out of men like Mr. Doar; men and women willing to put their lives on the line to take an unpopular stand and do what they think is right.

Heroku’s Adam Wiggins on how to scale a development team

Not much to say here; I think this is an excellent template for growing a software company and this is my way or preserving copy for when I need it.

Adam Wiggins – How To Scale a Development Team

As hackers, we’re familiar with the need to scale web servers, databases, and other software systems. An equally important challenge in a growing business is scaling your development team.

Most technology companies hit a wall with dev team scalability somewhere around ten developers. Having navigated this process fairly successfully over the last few years at Heroku, this post will present what I see as the stages of life in a development team, and the problems and potential solutions at each stage.

Stage 1: Homebrewing

In the beginning, your company is 2 – 4 guys/gals working in someone’s living room, a cafe, or a coworking space. Communication and coordination is easy: with just a few people sitting right next to each other, everyone knows what everyone else is working on. Founders and early employees tend to be very self-directed so the need for management is nearly non-existent. Everyone is a generalist and works on a little bit of everything. You have a single group chat channel and a single [email protected] mailing list. There’s no real need to track any tasks or even bugs. A full copy of the state of the entire company and your product is easily contained within everyone’s brain.

At this stage, you’re trying to create and vet your minimum viable product, which is a fancy way of saying that you’re trying to figure out what you’re even doing here. Any kind of structure or process at this point will be extremely detrimental. Everyone has to be a generalist and able to work on any kind of problem – specialists will be (at best) somewhat bored and (at worst) highly distracting because they want to steer product development into whatever realm they specialize in.

Read More