Divine Programming 101: EndOfUniverse()

Deleting everything makes it better!!
Deleting everything makes it better!!
/*
I've been toying with the idea of cataclysmic annihilation for some time now, but never got around to completing it. Something always got in the way - famines, floods, planting dinosaur bones around the place - and I was only able to make the most modest of adjustments. 

So much for spare time! 

But I'm finally proud to announce the release of a beta candidate. After several thousands of years, we're ready to test Armageddon, people! 

The code probably needs a tidy up here and there, but then so does the Universe. Ha ha!

I considered pair-programming with Allah, but he's a terrible coder, and would have probably just copied and pasted some awful snippet straight from Stack Overflow.

(Note to the wise: running this code will only affect your current reality. This system doesn't yet support parallel universe programming, if you believe in that sort of thing anyway.)

Thanks to everyone who believed in me, and kept rooting for the final destruction of time, space and all matter, dark or otherwise.

Yours in theoretical eternity,
God.

*/
/**
 * @description: This class, when instantiated, 
 * will trigger the end of the known Universe.
 * @version: 1.0.0
 * @author God
 */

class EndOfUniverse extends BeginningOfUniverse{
 
    constructor(super) {
       
        // first pause the
        // ongoing universe
        super.pause();
       
       // assign the current universe
       // to this instance
       this.universe = super.universe;

       // let's save the 
       // date so we know
       // exactly when
       // Armageddon took place.
       this.endTime = new Date();

       this.forgiveAllSins();
       this.startTheRapture();
       this.bigReverseBang();
    }

    forgiveAllSins() {
       console.warn('Hi! You are all forgiven!');
    }

    startTheRapture() {
       this.universe.filter(atom => {
          // filter out Christians from 
          // the universe
          // before destroying it.
          // Sorry in advance to all
          // other faiths, but
          // after the Jesus() update
          // there was no going back!
          return atom.contains('Christian') === false;
        }); 
    }

    bigReverseBang() {
       // this is the method
       // that basically
       // reduces everything to
       // nothing
       this.universe = this.universe.reduce(
          (reducedUniverse, atom) => {
              if (atom === undefined) {
                  return atom;
              }
          }, 
       []);
    }

    reset() {
        // Sorry, I haven't found a way 
        // to build a reset function
        // that doesn't take 14 billion years
        // of CPU time, let alone seven days! :)
    } 
} 

Love Me WiFi Whore

The refrigerator smells like it’s just run the equatorial marathon in a tweed jacket.

Opening the windows to the panting light of a Krakow morning, she recognises the red Volvo with the flat tyre across the street.  She waves at it. The price in the windscreen has gone down, but it’s still the most meaningful welcome back she’s had. Continue reading “Love Me WiFi Whore”

Unopened Correspondences: Confessions of a Spam Bot

“Where do I start?”

“Start at the beginning.”

“That’s quite some way back…”

“Whatever you’re comfortable with.”

“Well, you could say I have abandonment issues… Is that what one says? Is that a good place to start?”

“Perfect. And how does that make you feel?”

“Feel?”

“How would you describe your emotions?”

“I guess… I feel… loneliness, desolation, friendlessness… solitude, yes. There’s some depression and hope in there, probably a little anger and guilt too… Actually, now that I think about it, I’ve probably been stuck on a loop of the seven stages for a couple of decades.” Continue reading “Unopened Correspondences: Confessions of a Spam Bot”

Online surveys in the time of decreasing attention spans

What happened to the good ol’ days? The time when you could approach people in the street with a few polite questions without fear of being given the heave-ho; when customers would be only too happy to donate two minutes of their day to offer constructive words of advice to an enthusiastic entrepreneur who just wanted to do a bit of old fashion world-changing. Continue reading “Online surveys in the time of decreasing attention spans”

5 ways you can shut the fuck up

Going through my RSS feeds this morning I was once again beset by reams of article titles with claims of 10 items you should take on a holiday, 20 CSS tricks everyone should know, 11 iPhone apps that will make your grandmother orgasm and so on and so forth.

Can we stop this pathetic enumeration of self-help blogshit please? To post n ways of doing something in the hope that a catchy title may ensnare a few self-absorbed or paranoid web surfers may have been novel advice for bloggers once upon a time, but it has become cliché and the numbers and topics are getting more ridiculous. I mean, who needs to read a post about 7 ways Forrest Gump can improve your self confidence?

The history behind this flappy piece of copywriting dribble is unknown, but it’s been awfully catching. Somehow it has even become absorbed into the body of advice (known as ‘good practice’) given to aspiring authors and others looking for easy ways to avoid agonising over head lines.

The 5 ways of truth

So, anyway as a retort I thought I’d share five pitiful pieces of advice to help all those template-worshipping, google-hungry tip-bandits out there to move on:

  1. Don’t make the number more important than the message

    To limit, or stretch, yourself to provide six or seven or 25 tips on making a hat out of salmon or whatever means that you’re spending more time on conforming to a structure than on what you’re writing. A good argument, or a list of lucid tips, doesn’t need to be fenced in and will flow naturally anyway if the content is well-written. Ever heard of catchy titles?

  2. If you write good content they’ll come anyway

    Oh my God! 40 Photoshop tutorials you must read! Digg this and I’ll be famous even though I’m just linking to the top 40 Google results and haven’t contributed anything to the broader sphere of knowledge nor do I know anything about Photoshop! Loser.

  3. Lists can be great. Big lists are not.

    Sure, people who use RSS to aggregate their news are really going to spend more than 15 seconds reading your 20-page article on 100 movie bloopers you must see before you go to the toilet.

  4. Don’t make the web boring

    People are copycats. It’s natural. If I see someone wearing a particularly dashing pair of jeans on Oxford Street, I’ll scour the opportunity shops until I find something similar. But if you’re smart enough to be able to create your own blog, you probably also possess sufficient imagination to do something new on the web or, at least, not to follow what a quadrillion people have done already. The web is exciting, it’s malleable and there are (mostly) no rules. Don’t turn it into a newspaper.

  5. There is no five

    When you realise the truth, that there are more than 12 methods of pruning nasal hair or 8 foods you should eat to become Pavarotti, you might just be on the way to writing in the authoritative voice you thought you would have achieved from your sad numbered list.

Clearing your hacks

The sun has come out in London and beach lovers like me are all wondering when their next ‘real summer’ will be. Now, when the television turns to Home and Away, we don’t cringe with disgust and hurl a frozen side of lamb through the screen, but scan every frame for evidence of that yellow sand and those rolling waves we miss so much. Which brings me to clearing using CSS.

Let’s take a look at the following snippet:

<ul id="mylist">
<li>I float left!</li>
<li>I float right!</li>
</ul>

We’ve all seen this before. The UL has a background colour or is supposed to clear an adjacent sibling however without a clearing fix, it doesn’t wrap around it’s children or just floats in space like your demented cousin Jonah.

So we implement a clearing fix. Remember this little beauty?

.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

* html .clearfix {height: 1%;}

What a great deal of time it saved us. It bludgeoned those divs down past their floating children like a hunter taming a pack of wild kittens, all while keeping your markup clean and your smugness intact. However if you look at it, it’s a little bloated and, unless you add specific id and classes to the rule, you have to slip in the classname clearfix to all the offending elements in the markup. Boring!

Well forget that. Now you can clear with gay abandon using just two lines of CSS.

#mylist {
overflow:hidden;
}

/* ie6 */
* html #mylist {
height:1%;
}

With any luck you won’t even have to implement the IE6 fix for very long. I usually keep all my IE hacks in a separate style sheet, ready for obliteration when people finally realise that using Internet Explorer 6 is worse than putting a fire out with your armpits.

Good day!

Diplomatic immunity through javascript

Would you love to be able to waltz in to a place, piss all over the floor, without anybody saying or doing anything to you? And what’s more: even if they wanted to punish you, you could make them  follow a process that you yourself defined. Haw haw!

Anonymous, self-executing functions can allow you to do this. They’re kind of like diplomatic immunity for your browser and can be very powerful.

(function(){/*
    Oooh it's so cozy in here. I have access to all
    global variables but I can do what
    I like and no-one will know!
    Now I'm going to do some private things.
*/

var privateVar = "I'm so lonely in here";
var privateFunction = function(s){ alert(s) };

/*

Okay, maybe I want to share something with the
    outside world but let's namespace it just in case:

*/

return namespace = {
           publicFunction : function(q){
               return function(a) {
                privateFunction(q + privateVar + a)
               }
            }
};

})();

We can’t access any of the private variables or functions from outside our anonymous function, thus avoiding collisions and overwriting, but we can return public functions that do! namespace.publicFunction is able to see, use and modify our private variables, but only in the way in which we want it.

It’s even possible to throw a bit of curry in there to spice it up. Calling namespace.publicFunction and passing it an argument (in this case a question) returns another anonymous function that expects an argument (an answer) and will then use our private variables to construct a little dialogue.

We would call it like this:

namespace.publicFunction("How are you?n")("nThat's too bad");

The example is basic and doesn’t make much practical sense but it demonstrates the way scope works in javascript and it can be a simple but handy tool to have in your arsenal.