Site down

Last night, having tipped a small carafe of Grade 7 Burgundy into my greedy maw, I blithely reformatted my server and upgraded it to Meerkat, smug in the knowledge that I’d copied over /var/www and all the important config files first. However, suffering a lapse of judgement that would shame the greenest of noobs, I forgot to back up any of my databases, which meant I lost WordPress, my bookmarks page, my shopping cart, my site stats and quite a bit more. A doubleplusungood situation that I’ve been trying to rectify today. Still, at least it didn’t happen at work.

Turns out most of my extremely dull, derivative WordPress posts were available in my work rig’s Firefox disc cache (about:cache), though they were gzipped and unreadable, at least until I stumbled upon the excellent script below. I copied and pasted the relevant files’ contents, saved the lot as cache.log and then invited Chrome to fire it up. Having scrolled nervously through the resulting binary sea, I reached the output at the bottom and found the posts, perfectly intact. Many thanks to Frozax, who wrote it.

// cache.log is a copy of chrome or firefox cache page with
only the file content section

$cacheString = file_get_contents("cache.log");
print_r($cacheString);
$matches = array();
preg_match_all('/\s[0-9a-f]{2}\s/', $cacheString, $matches);
$f = fopen("t.bin","wb");
foreach ($matches[0] as $match)
{
  fwrite($f,chr(hexdec($match)));
}
fclose($f);

ob_start();
readgzfile("t.bin");
$decoded_data=ob_get_clean();
echo $decoded_data;

The Wayback Machine helped me grab another couple of posts and trusty old Google had a cached copy of my bookmarks page, so at least I could restore them all manually. The cart schema sadly eluded me, but at least I had an Access sketch of the table relationships that roughly resembled the finished arrangement, so that’s now back in action.

Tomorrow’s task is to restore the posts and get Postfix working. Judging by the log message below, it should already be working, but my inbox remains void of contact forms. Time to consult a Unix expert.

19 18:40:08 MiffyServer postfix/qmgr[10735]: E188AAE0085: from=,
size=569, nrcpt=1 (queue active)
Jan 19 18:40:09 MiffyServer postfix/smtp[10810]: E188AAE0085:
to=, relay=smtp.o2.co.uk[82.132.141.69]:25, delay=0.57,
delays=0.09/0.01/0.31/0.16, dsn=2.0.0, status=sent
(250 <4EEB66400530A52F> Mail accepted)
Jan 19 18:40:09 MiffyServer postfix/qmgr[10735]: E188AAE0085: removed

Yes, my server’s called Miffy. I’m so sorry.

Post to Twitter

Welcome back

Well, the site’s back online, though in a pitiful state of WordPress vanilla. Why am I bothering? Now that I have a web-based job at a half-decent University, I need to emerge from my dilettante cocoon and become a proper developer, concentrating especially on:

  • Valid HTML5 and CSS3
  • Secure, efficient and well-commented object-oriented PHP
  • Complex MySQL queries
  • Linux bash scripting, shortcuts, command switches etc.
  • jQuery
  • Designing applications from scratch
  • WordPress (child themes, custom functions, widgets etc.)
  • I’d add Photoshop as well, but I can’t design for shit

This means that the odious mass of spaghetti that comprised my first attempts to code has to be binned, updated or (especially where attached to a crayon scrawl that would shame an infant) kept for posterity, so people can laugh and point. Then, using this default theme as a starting point, I need to build a cutting-edge child theme that takes full advantage of HTML5 and CSS3 techniques. My first six months at work have taken me into the depths of WordPress, so at least I have some experience of doing this. So with luck I’ll be hacking this one apart within weeks.

I’m sure I can do it. After all, I can boast a history of programming the BBC Master 128k in assembly language at school, often in order to coerce it and twelve of its friends to play an indescribably irritating rendition of Cavatina with a 50ms delay between each; or to build elaborate trojan horses to capture the occasional password (for ethical use only, of course!). Neither activity brought joy to my poor computer master, but at least I discovered a peculiar love for coding.

In fact I’ve already done the bookmarks page, probably the easiest one to update, whereas putting new wheels on the shopping cart fills me with dread.

Post to Twitter

Talent

Does one need to be a natural born artist to be an adequate web designer? Well, it probably helps, but for those like me not gifted in an artistic sense there is still much worth striving for.

Consider the drafts of Montaigne: they bristle with the prolonged torture of corrections, additions and alterations; endless careful detailed polishing that makes one realise the cliched schoolmaster’s advice of 10% inspiration 90% perspiration holds true even in the rarefied air of innate talent. Or look at Raphael’s drawings after he has studied the masters and learnt to do perspective. They may look like the effortless strokes born of raw talent alone, but with the context of his earlier drawings I think one could attribute the improvement mainly to years of diligent mimicry, a painstaking transfer of skills by proxy if you like. How prosaic and disappointing to imagine these elite creatures having to stoop to practice in order to make their work seem effortless! (Meanwhile the world is probably awash with lazy geniuses who have come to nothing because they expected their talent to somehow allow circumvention of the work required to bring it to fruition).

Sure, not every web designer will be a Van Damme but you’d be surprised how far graft can take one. To deny an aspirant the chance of success because he’s not “built correctly” from birth is to deny the immense and constantly surprising power of humans to learn and adapt, indeed perhaps to create versions of internal circuitry with which luckier ones may have come pre-installed. What is our brain but a malleable electrochemical soup after all? No hardwired semiconductors in place that a priori necessarily deny change. The obvious can become signficant with practice, though yes to the innately talented it will of probably come more easily and to a larger degree. Even if it doesn’t, there is hope for all for are prepared to devote time to getting the details right, honing practical skills on the field of experience and slowly piecing things together, just as there is room for a skilled joiner to work alongside a cabinet maker. Indeed the lazy cabinet maker may have to watch out that he is not replaced.

Post to Twitter

Origin of religion

If I had been raised in a sufficient degree of isolation I suspect the concept of god would never have crossed my mind, much as the concept of (“invent vacuous word here: damn ‘postmodernism’ is taken”) has not. Atheism is surely our natural state, until our brains become tarnished (when young, they are extremely malleable and trusting of authority, especially parents: it’s an evolutionary necessity) by received ideas. In other words, atheism does not require one to take a negative position of any sort until its opposite is invented then passed on by word of mouth or scratch of quill. It’s essentially a non-existence of belief, not a rebuttal of it.

This does not, of course, mean that I don’t find the universe incredible, perplexing, wonderful and mysterious – of course I do – rather that it is sufficiently so (understatement) to make the mental conjuring of another layer of complexity (god) both redundant and unlikely, at least to my small mind.

Naturally this makes me wonder how religion ever came to arise in the human mind. The stubborn longevity of religion (indeed in some quarters it’s actually gathering strength, even in these supposedly enlightened times) strongly suggests to me that there must be (or have been) a survival advantage to harbouring religious beliefs. If there wasn’t, I’d expect natural selection to have weeded it out. Another school of thought holds that religion is simply an exaptation, an evolutionary byproduct of other mental adaptations. Then there are those who suspect a hard-wired religious gene, which may cause a predisposition to episodes wrongly interpreted as religious revelation.

Whatever the cause, it’s still very much a prevalent social phenomenon. The conditioning of young children (often by well-meaning but misguided parents) into religion when they are at their most credulous is easy and, though not necessarily a tragedy, at best depressing and at worst, borders on abuse. The idea and practice of calling someone a “Muslim child” or “Christian child” before they are old enough to make a rational choice of their own is reprehensible. At this age, it is essential that children should be taught to think critically, with recourse to logic and evidence, not fed the contents of cultural relics such as the Koran and Bible – and the often bizarre and unpleasant moral edicts contained within them – as truths not to be questioned. I have no objection to consenting adults practising religion in private among themselves, but please leave the kids out of it.

Of course there are millions of sane, ethical people who quietly believe in a god or gods, draw strength from their belief, treat women and homosexuals decently and don’t impose their values on others. My Granny is one of them. But religion is also a perfect tool to help nasty people acquire and prolong a great deal of power, influence and money, disseminate wicked ideas and make the lives of certain people a misery. One can only hope that the advance of science and knowledge will continue to usurp this power.

Post to Twitter

Evolution

Two small fragments of a recent discussion I enjoyed on a another site.

“Without intelligence behind evolutionary design means that random chance engineered apparent design. Look at today’s top designers of engineering products, maybe a Ferrari F1 engine. If I said that the Ferrari engine happened by accident and without intelligence behind then I would be laughed at like an idiot. Yet look at the complexity in the engineering of the human hand which is literally infinitely more complex and this happened by accident. What about the human eye ? Again even our top most intelligent scientists cannot come close to the engineering capability of something that again happened by accident.”

It is an oddly common (and I suspect often deliberate, at least among proponents of intelligent design) misconception that a complex creature (or element of one, such as a hand) as seen by a Darwinist is nothing more than a happy accident. This assumption fails signally to understand how evolution works. No Darwinist would suggest for a picosecond that the human hand is the result of an extended medley of dice throwing.

The process, which involves random chance (mutation) together with cumulative selection, occurs in minuscule steps starting from very humble (and thus realistic/credible) beginnings over a huge number of generations. Mutation may be random, but selection is not.

For instance, to use the old eye chestnut: once upon a time a single cell mutated and became sensitive to light. A single photocell gave a small advantage over the creatures with no photocell, perhaps gaining them the sight of a few extra scones. So the former became healthier and more prevalent. Then another mutation improves this most primitive of eyes a tiny bit further; that slightly improved creature again multiplies while the ones with less useful mutations die off.

“Heritable variations lead to differential reproductive success” to quote Darwin. So the eye is steadily honed (“climbs mount improbable”, to paraphrase Dawkins) over a large number of small steps into the glorious baby blues we have today, bringing with it to some a seductive illusion of design.

“Thus the creationist’s favourite question ‘What is the use of half an eye?’ Actually, this is a lightweight question, a doddle to answer. Half an eye is just 1 per cent better than 49 per cent of an eye, which is already better than 48 per cent, and the difference is significant.” (Dawkins)

“If there is no intelligence behind our evolutionary development, this means that only matter exists and the human mind, the human soul and the human spirit only appear to have a separate conscious ability and existence. If this is not the case then how and where have they come from ?”

I’ve never thought of my mind as anything other than a deliciously complex machine. The eye is impressive, the brain even more so, but fundamentally I don’t see why the two couldn’t have emerged similarly through evolution. The dualistic idea of the mind existing in some way separately from the rest of my flesh ‘n bones (I guess what people mean by soul or spirit), or being anything other than matter coursing with chemicals and electricity is alien to me, though I can see the romantic appeal of the notion. Muscles contract, rods and cones are sensitive to light patterns, brain cells process information, simple. Or rather, complex.

Post to Twitter