Code your life

June 4, 2012 at 2:43pm

Feminism programming

    
    //

    if(person['sex'] == 'female') doSomethingSpecial();
    else doSomethingNormal();
    
    

March 27, 2012 at 2:19pm

The infinite loop of crack addiction

beginning:

var dude = new Dude();

dude->buyCrack();
dude->smokeCrack();

while(dude->isHigh()) {
   dude->liveHigh();
}

if(!dude->feelGood()) {
    if(dude->hasMoney()) {
        goto beginning;
    } else {
        while(!dude->hasMoney()) {
            dude->tryToFindMoney();
        }
        goto beginning;
    }
} else {
    dude->isLucky();
}


//
//
// Definition of Dude class
//
//
class Dude {
    happiness = 10;
    money = 20;
    rock = 0;

    function buyCrack() {
        money -= 20;
        rock += 1;
    }

    function smokeCrack() {
        rock -= 1;
        happiness += 10;
    }

    function isHigh() {
        if(happiness > 0) return true;
        else return false;
    }

    function liveHigh() {
        happiness -= 1;
    }

    function feelGood() {
        if(happiness = 20) return true;
        else return false;
    }

    function tryToFindMoney() {
        //Check bank account
        var account = new BankAccount();
        if(account->hasMoney(20)) {
            money += account->debit(20);
            return;
        }

        //Check credit cart
        var creditCard = new CreditCard();
        if(creditCard->hasMoney(20)) {
            money += creditCard->credit(20);
            return;
        }

        //Check empty bottles
        var kitchen = new Kitchen();
        if(kitchen->hasEmptyBottles() && kitchen->bottlesAmount() > 20) {
            money += kitchen->sellEmptyBottles(20);
            return;
        }

        //Sell DVD at the pawn shop
        if(dude->hasDVD() && kitchen->DVDAmount() > 20) {
            money += dude->sellDVDAtThePawnShop(20);
            return;
        }

        dude->goOutAndAskMoneyToStrangers();
    }

    function isLucky() {
        happiness = 10;
    }
}

1:48pm

Apple updates explained

Every updates from Apple contains this block of code

while(device.isAnOldModel()) {

    device.slowDownUntilHeBuyTheNewOne();

}