Posts

  • How to interview well at Google

    Some friends of mine have been interviewing at Google and I’ve been helping them prepare. After some practice interviews, I drew up this flowchart for them to take with them (mentally) to the interviews.

    Read the rest of How to interview well at Google
  • Scientific American infographics or chartjunk?

    This data graphic isn’t just crazy, it’s misleading.

    Read the rest of Scientific American infographics or chartjunk?
  • Amazing comment spam

    I got some really awesome comment spam recently. Here’s an example, from my post on Nerdcore music (I deleted the comment because it contained a spam link):

    Read the rest of Amazing comment spam
  • How to buy speakers

    A friend just asked me for some advise on buying speakers – should she get Bose or Paradigm? Well, I had a few words to about that, so here’s my response:

    Read the rest of How to buy speakers
  • How to embed a 480p YouTube video

    Google doesn’t provide any “official” way to embed a YouTube video in 480p. It always drops you down to 360p by default, and that just looks crap. You can embed in HD so why not 480p? No one knows. But don’t despair, there is a way!

    Here’s some code for you:

    <object width="853" height="505">
      <param value="http://www.youtube.com/v/MOVIE_ID&amp;hl=en_US&amp;fs=1&amp;rel=0" name="movie">
      <param value="true" name="allowFullScreen">
      <param value="always" name="allowscriptaccess">
      <embed width="853" height="505" allowfullscreen="true"
        allowscriptaccess="always"
        type="application/x-shockwave-flash"
        src="http://www.youtube.com/v/MOVIE_ID&amp;hl=en_US&amp;fs=1&amp;rel=0">
    </object>

    That will give you an “HD width” 480p video. Just change “MOVIE_ID” to the ID of your video (e.g. “J-lHxxToCfo”) in both places. The width of the embed will be 853px, which is 16:9 for HD video.

    What if your video is 4:3, i.e. 640x480? I can’t find any clean way to embed at exactly that size, if you use the above code you’ll get black bars on either side. However you can use a negative margin to get a box of the right shape. Just wrap your object like this:

    <div style="width: 640px; overflow: hidden;">
      <div style="margin-left: -107px;">
        <object etc ... ></object>
      </div>
    </div>

    The controls will go off the screen but at least the user will still be able to click the centre of the video to start and stop it. Here’s an example:

    My column width is less than 640px but hopefully you get the idea.

    Read the rest of How to embed a 480p YouTube video
  • CS Rap / Geeksta Rap / Nerdcore

    I’m not convinced by gamer nerdcore but good CS Geeksta Rap is cool. Finally some street beats that talk to me!

    Monzy’s Kill -9 (video) is pretty entertaining. Check out Dale Chase Coder Girl. “She’s not another shallow copy I can sudo” heheh.

    I found a few new lines in a dream recently. Don’t know if they’ll ever fit into a rap though.

    Java or Scala it doesn't matter to me
    If you want I'll even write your app in PHP
    
    10 PRINT "HELLO"
    20 GOTO ONE-OH
    
    Your bytecode is subject to my interpretation
    
    Use my RJ-45 I'll put a packet right into your ass
    
    If you don't do what I want then I will fork your git
    I'm fully dedicated but you just can't commit
    Read the rest of CS Rap / Geeksta Rap / Nerdcore
  • Why condition your battery once when you can do it three times?

    MacBook users have started to discover over the last few years that their batteries can take a total nosedive into uselessness in just a few months. The first battery on my 2008 MacBook Pro was dead by the end of 2009, flat dead, and out of warranty too. Damn. Cause of death? Lack of “battery conditioning” also known as “calibration”.

    If you want to know how to calibrate your battery, you can refer to this hard to find guide from Apple:

    To calibrate the battery:

    1. Plug in the MagSafe power adapter and fully charge the MacBook or MacBook Pro battery until the light on the MagSafe connector changes to green and the Battery icon in the menu bar indicates that the battery is fully charged.
    2. Allow the battery to rest in the fully charged state for two hours or longer. You may use your computer during this time as long as the power adapter is plugged in.
    3. Disconnect the power adapter with the computer on and start using it with battery power. When the battery's charge gets low, you’ll see the low battery warning dialog on the screen.
    4. Continue to keep your computer turned on until it goes to sleep. Save your work and close all applications when the battery's charge gets low and before the computer goes to sleep.
    5. Turn off the computer or allow it to sleep for five hours or longer.
    6. Reconnect the power adapter and leave it connected until the battery is fully charged. You may use your computer during this time.

    Pretty easy to understand, right? Yeah, the only problem is that even though you’re supposed to this every month or two, there’s no facility on the mac that actually, you know, prompts you to do it. Nothing, nada, zap diddly doo. You’d think that Apple with their vaunted usability standards would pop up a message at the right time saying “hey, now would be a good time to condition the old battery, here’s how to do it”.

    Also, Apple’s instructions are missing two other key pieces of information. The first is that you should immediately download a wonderful app called Coconut Battery. Go ahead, I’ll wait. It will tell you how crap your battery is and you can save the data to get a history over time.

    Second is that that condition is not something you can overdo. Don’t just do it once. Do it twice, three times even. Keep doing it until you stop seeing  capacity gains in coconut battery. Most recently, my first condition went from 71% to 76%, and the second brought me up to 80%. I’m going to see how high I can get.

    All in all this is a bit of a failure on Apple’s part, and it makes you wonder if perhaps they are making a load of money from selling replacement batteries. It doesn’t seem in character for the company. More likely, they just haven’t put the time into designing a proper monitoring system that detects when you need to condition. Hopefully we’ll get that soon.

    Read the rest of Why condition your battery once when you can do it three times?
  • Warning: May Cause Earthquakes

    It seems like things that cause earthquakes are the ultimate in evil or hyperbole. But now we’ve achieved that end: human technology can cause earthquakes. Hurray!

    Read the rest of Warning: May Cause Earthquakes
  • How Apple could fix Mac OS X

    Mac OS X 10.7 – the OS that no one is talking about – should be the next major release of the venerable Mac OS X (since 1989!) So, what will it look like? Seems like nobody knows. All of the focus has been iPhone and iPad for so long that it seems like everyone has forgotten about the old desktop/laptop computers.

    Read the rest of How Apple could fix Mac OS X
  • Another job opening :-) iPhone developer – learn on the job

    My iPhone custom software development business is expanding yet again and we need more part-time programmers. The last round I hired two people, now we need more. Our recent apps include Unitron’s uHear to test your hearing, OurKids, the Kik chat app, and others.

    You must:

    • know C, C++, pointers, object and object-relational patterns already
    • be ready to learn the iPhone SDK fast (we'll help)

    I’ve personally been programming on the Cocoa SDK since 1998 back when it was called OpenStep, so if you can pick things up, we can get you up to speed in a few weeks.

    Demonstrate your qualifications by answering 2 out of these 3 tricky questions:

    [Question 1] (C Pointers) Here is some slightly odd C code, but it will produce an (int) result, provided that you make some small changes in order to make it compile. What is the result going to be, and why?

    int * a = 1990;
    int result = &5[a];

    [Question 2] (Database design) Create an entity-relationship diagram for a small subset of the Facebook database. In particular, include in your diagram:

    • User
    • Photo (including who is tagged in the photo)
    • Wall Post

    Focus on the relationships/associations between these three objects, and only include one or two of the most important static fields (like a person’s name). Make sure to indicate the cardinality of a relationship e.g. one-to-one/one-to-many/etc.

    To get an idea of what I’m looking for see: http://en.wikipedia.org/wiki/Entity-relationship_model

    Here’s a tool you can use to draw it online: Gliffy. Then just send me a screenshot. Or feel free to use ASCII art or draw on a piece of paper and photograph/scan, as long as it’s very clear.

    [Question 3] (C++ Objects) The C++ program below has just 2 compile time errors, 1 runtime error, and there is 1 single line missing. Send us a fixed version that compiles and runs correctly. The errors will test your knowledge of object use and management in C++, and the missing line will test you on abstract/virtual inheritance.

    SEND TO: simon@semacode.com. Include your answer(s) and some source code that you have written, whether it’s open source, for assignments, for fun, or whatever.

    REMUNERATION: Competitive.

    MORE INFO: http://simonwoodside.com/pages/consulting

    (PS Please keep the answers to yourself)

    //// File: futurama.cpp ////
    #include <iostream>
    
    class Drinker {
    public: Drinker(); void drink( int potency ); int _numberOfDrinksSoFar;
    private: virtual int cantDrinkAnyMoreThan() = 0;
    }; Drinker::Drinker() { _numberOfDrinksSoFar = 0; }
    class Robot : public Drinker { int cantDrinkAnyMoreThan() { return INT_MAX; } };
    class Human : public Drinker {
    };
    void Drinker::drink( int potency ) {
      _numberOfDrinksSoFar += potency;
      if( _numberOfDrinksSoFar > cantDrinkAnyMoreThan() ) { std::cout << "I'm all done." << endl; }
    }
    
    int main (int argc, char * const argv[]) {
      int beer = 5, coffee = 3;
      Human fry;
      Robot * bender;
      for( int i=0; i<6283; i++ ) { bender.drink(beer); }
      for( int i=0; i<100; i++ ) { fry.drink(coffee); }
      std::cout << "Bender: " << bender->_numberOfDrinksSoFar << "  Fry: " << fry._numberOfDrinksSoFar << std::endl;
      fry.drink(1);
      return 0;
    }
    Read the rest of Another job opening :-) iPhone developer – learn on the job