Joakim Nygård Archive Linked About

Earth Hour Pictures

31 Mar 2009 -

It’s not imagery from the ISS but this picture series from The Boston Big Picture is a fantastic display of before and after. The Wikipedia entry on Light Pollution has some background on the scale and some of the consequences of using so much light, including two remarkable pictures from space (composites of satelite photos) of the earth at night in 2000 and 2007 - the increase is stunning.

The Makers of Things

27 Mar 2009 -

Rands:

We are defined by what we build. It’s not just the engineering ambition that designed these structures, nor the 20 people who died building the Brooklyn Bridge. It’s that we believe we can and decide to act.

OmniGraphSketcher

26 Mar 2009 -

New application by Omni Group that looks amazing. It is the kind of software that feels like a magic, digital version of pen and paper. A simple idea but it works remarkably well for creating illustrative graphs.

The Startup Myth

20 Mar 2009 -

From the SAMBA blog:

Get real. Entrepreneurship is about growth and value. Entrepreneurship is about creating something a sufficient number of people want or need. Entrepreneurship is about turning every dollar of resources spent into something worth more than a dollar. Entrepreneurship is about building a company and growing it beyond startup stage.

Zend Framework Validator for Danish VAT Numbers

17 Mar 2009 -

Working on an as of yet unpublished startup, I needed a validator for the Danish CVR numbers issued as part of VAT registration. As the project is written in Zend Framework, I decided to implement the code as an extension of the Zend_Validate_Abstract and share it here.

The validation is based on the specification located at cvr.dk and involves a modulus 11 check on the 8th digit based on a weighted sum of the previous seven. Not particularly interesting but nice to have when working with Danish companies.

<?php
/**
 * Scienta Zend Additions
 *
 * @category   Scienta
 * @package    Scienta_Validate
 * @copyright  Copyright (c) 2008-2009 Joakim Nygård (http://jokke.dk)
 * @version    $Id$
 */

/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';

/** Zend_Filter_Digits */
require_once 'Zend/Filter/Digits.php';

/**
 * A class for validating Danish CVR numbers based on modulo 11
 * @see http://www.cvr.dk/Site/Forms/CMS/DisplayPage.aspx?pageid=60
 * @category   Scienta
 * @package    Scienta_Validate
 * @copyright  Copyright (c) 2008-2009 Joakim Nygård (http://jokke.dk)
 */
class Scienta_Validate_Cvr extends Zend_Validate_Abstract
{
    const INVALID          = 'cvrInvalid';
    const INCORRECT_LENGTH = 'stringLengthNotRight';
    const NOT_DIGITS       = 'notDigits';

    protected $_messageTemplates = array(
        self::INVALID          => "'%value%' is not a valid CVR number",
        self::INCORRECT_LENGTH => "'%value%' does not contain 8 digits",
        self::NOT_DIGITS       => "'%value%' does not contain only digits",
    );

    protected $_cvrWeights = array(2, 7, 6, 5, 4, 3, 2);

    public function isValid($value)
    {
        $valueString = (string) $value;
        $this->_setValue($valueString);
    
        $filter = new Zend_Filter_Digits();
        if ($valueString !== $filter->filter($valueString)) {
            $this->_error(self::NOT_DIGITS);
            return false;
        }
        if (8 != strlen($valueString)) {
            $this->_error(self::INCORRECT_LENGTH);
            return false;
        }
    
        $sum = 0;
        foreach ($this->_cvrWeights as $i => $weight) {
            $sum += $valueString[$i] * $weight;
        }
        $remainder = $sum % 11;
		if($remainder==1){
		    $this->_error(self::INVALID);
		    return false;            
		}
		if($remainder==0)
		    $lastDigit = 0;
		else
		    $lastDigit = 11 - $remainder;
		
        $valid = ($valueString[7] == $lastDigit);

        if ($valid) {
            return true;
        } else {
            $this->_error(self::INVALID);
            return false;
        }
    }
}

Save the above to the file library/Scienta/Validate/Cvr.php with library being the directory containing the Zend framework. The class can then be used to test a number as follows:

$cvrValidator = new Scienta_Validate_Cvr();
if ($cvrValidator->isValid($proposedCvrNumber)) {
    ...
}

One case where testing is needed might be a Zend_Form, in which case the class is easily added as a validator on the appropriate element.

Forever's Not So Long

13 Mar 2009 -

Remarkable new short film by Shawn Morrison and Garrett Murray. Beautiful shots and great acting.

So amazing, so illegal. What are we going to do with you, future?

12 Mar 2009 -

Merlin Mann comments on Kutiman’s amazing Youtube video remixes

…this is what your new Elvis looks like, gang. And, eventually somebody will figure out (and publicly admit) that Kutiman, and any number of his peers on the “To-Sue” list, should be passed from Legal down to A&R.

The Future Is Already Here

5 Mar 2009 -

Great pictures, as always, of robots around the world (many are from Japan) from the Boston Globe’s The Big Picture section.

ToyRacers public beta

3 Mar 2009 -

My brother Stein Nygård just released a public beta of his upcoming toy themed racing game ToyRacers. He has previously developed NapkinRace and the renowned KartingRace. Though still in beta, the game looks impressive. (Windows only at this time)

Impressive Webapp Version of Interface Builder

26 Feb 2009 -

Though I am not convinced that converting every desktop app to a webapp in the cloud is such a clever idea, the work done by 280 North is impressive. This Atlas is the online equivalent of Interface Builder for developing GUIs on the Mac and appears very well done.

Archive