Karl Stockholm, Sweden.

English Swedish

It’s been a while (again).

January 29th, 2010

, originally uploaded by Lynt.

I figure I might as well make use of the Wordpress x Flickr capabilities and start blogging my adventures once again.

I’ve been busy.

I’ve also been in Japan… hopefully I can revive this blog over the coming weeks…

Sorry, it’s been a while…

October 16th, 2009

Sorry it’s been so long. I’ve been busy, stressed, and more stressed. My company took us out to the Stockholm Archipelago last week, it was breath taking.

More news in the next few days… ;)

Custom AJAX Wrapper for jQuery

October 16th, 2009

I write a lot of my Javascript with the help of jQuery, and one of it’s finest features is it’s extensibility and powerful internal functions. For larger sites, especially portals, AJAX can become messy if it’s not controlled, and when things get out of hand, it’s often hard to trawl through your scripts to make changes.

That’s one of the reasons why I wrote (and use almost daily) my custom AJAX wrapper for jQuery.

The idea.
Centralize one $.ajax() method, and have methods external to jQuery control the data and callback methods before firing.

This allows for a global wrapper on all before and callback methods in case you need to do things like: show loading animations, run site statistics, setup error handling, etc.

The code.
I like to use namespaces in my projects, so I will be giving you a basic outline of a namespace setup, and then how an external function can interact with the global AJAX method.

I will base the example loosely on a CRUD schema.

// Create our namespace
var Website = {};

/**
 * Outline our webservices
 * @param {String} action - AJAX action to perform
 * @param {Object} payload - Javascript object containing AJAX method properties
 */
Website.Webservice = function (action, payload) {

    switch (action){

    case 'create':
        payload.type = 'POST';
        payload.url = '/ajax/create_data.php';
        break;

    case 'read':
        payload.type = 'GET';
        payload.url = '/ajax/get_data.php';
        break;

    case 'update':
        payload.type = 'POST';
        payload.url = '/ajax/update_data.php';
        break;

    case 'delete':
        payload.type = 'POST';
        payload.url = '/ajax/delete_data.php';
        break;
    }

    // Call the global AJAX method
    Website.AJAX(payload);

}

/**
 * Fires off the AJAX object with user defined payload information.
 * @param {Object} payload	- AJAX data options to bind to the jQuery object
 */
Website.WebService.AJAX = function (payload) {

    // If dataType wasn't specified in the payload, default to 'html'
    var dataType = (payload.dataType !== undefined) ? payload.dataType : 'html';

    // jQuery AJAX object
    $.ajax({

        // Normal properties
        type: payload.type,
        url: payload.url,
        data: payload.data,
        dataType: dataType,

        // Global beforeSend wrapper with user defined function
        beforeSend: function () {

            // Do global here
            if (typeof payload.beforeSend === 'function'){
                payload.beforeSend();
            }

        },

        // Global success wrapper with user defined function
        success: function (data) {

            // Do global here
            if (typeof payload.success === 'function') {
                payload.success(data);
            }

        }
    });

};

Now that I have set up our basic framework, I can fire off any AJAX request with minimal code, and abstract any intense data mining functions and other methods from our AJAX process. This allows for clean and controllable code.

/**
 * Some function or event that fires off AJAX
 * @param {Object} data - Javascript object containing user data
 */
var updateUserData = function (data) {

    // Create the AJAX property object
    var bundle = {

        data: {
            'user_id': data.user_id,
            'user_email': data.user_email,
            'user_firstname': data.user_firstname,
            'user_lastname': data.user_lastname
        },

        beforeSend: showSpinningLoader,

        // Success callback function
        success: onRefreshSuccess

    };

    // Fire the bundle off
    Website.WebService('update', bundle);

};

And there you have it. Simple and easy to use. Now you can trigger AJAX from anywhere in your application with all processes centralized.

My hood

September 16th, 2009

Looking lovely in the Swedish sunset.

This is how I roll.

September 15th, 2009

Impressive light & speed

September 11th, 2009





My life for a studio, a light rig, some models, and a bucket of paint.

Make sure to check Iain Crawford’s portfolio .

Amy Stein Photo

September 8th, 2009

Amy Stein | Photography | Halloween in Harlem

Amy Stein | Photography | Domesticated

I haven’t been inspired by photography for a long time… get on this. (via Fiwi)

The Mexican Suitcase

September 8th, 2009

From the ICP website:

“In late December 2007, three small cardboard boxes arrived at the International Center of Photography from Mexico City after a long and mysterious journey. These tattered boxes—the so-called Mexican Suitcase—contained the legendary Spanish Civil War negatives of Robert Capa. Rumors had circulated for years of the survival of the negatives, which had disappeared from Capa’s Paris studio at the beginning of World War II. Cornell Capa, Robert’s brother and the founder of ICP, had diligently tracked down each tale and vigorously sought out the negatives, but to no avail. When, at last, the boxes were opened for the 89-year-old Cornell Capa, they revealed 126 rolls of film—not only by Robert Capa, but also by Gerda Taro and David Seymour (known as “Chim”), three of the major photographers of the Spanish Civil War. Together, these roles of film constitute an inestimable record of photographic innovation and war photography, but also of the great political struggle to determine the course of Spanish history and to turn back the expansion of global fascism.”

“Following the long-delayed return of Robert Capa’s “Mexican Suitcase” to ICP’s midtown archive, and the overwhelming response it has received from individuals and media outlets around the world, our staff discussed the need for an online space where visitors could go to stay up-to-date about this story as it unfolds. This site grew out of those conversations.”

The Mexican Suitcase

Interesting stuff

Why I’ve been quiet here…

September 8th, 2009

So I’ve been really (really) busy at work these past few weeks. After getting back from holidays, I hit the ground running to work on the next installment of the Systembolaget AlkoholProfilen.se.

It’s a website where we can determine the drinking habits, health risks and advice to give to Swedes who take the 14 question survey. I wrote a fair chunk of this website, including some pretty neat Javascript components that we will be discussing over on Kontain in the next week or so.

So yes, lots to talk about, but I’m sure you’ve already caught up with my happenings on Twitter or Facebook. I will do my best to keep this blog updated whenever I can.

Nice!

Me @ Systembolaget

Paris & Le Tour de France 2009!

July 31st, 2009

Bienvenue à Paris!

I love Paris. Always have, always will. Such a beautiful old and enchanting city. I was here for only one purpose this time, Le Tour de France! I spent most of my time in the hostel cooking food, meeting other Australians and Americans who where here for the Tour as well. Since I have been here serveral times before, I wasn’t fussed about the sights, more so than saving money, eating and drinking well, and seeing the tour… but that didn’t get in the way of me having a little fun with the locals.

Everyone in the foreground (apart from the guy on the far right) were staying in the same hostel as me. Last time I was there I managed to wrangle a group of people together to head to the Sacré-Cœur to drink wine and watch the sun set. Seeing as I had such a great time doing it 3 years ago, I thought I would try and conjure up a group to do it all again.

We spent several hours drinking wine, eating cheese and discussing where we were from in Australia or America and life in general. Always good times spent on those steps, well, apart from the last night we were up there and we were almost robbed! Lucky 3 Australian blokes don’t take much nonsense from a lowly Parisian rat!

All of that aside, nothing could take the hype, excitement and thrill away from watching Le Tour de France live in the flesh. I am still coming to grips with the whole ordeal.

We got to the Place de la Concorde at about 12pm, ready and willing to wait the full 4.5 hours until the peloton screams by. It was already getting crowded and the streets were lined with people, also happy to sit the 4.5 hour wait. I was getting nervous at this point as I wasn’t yet willing to gamble on trying to squeeze in a spot on the Champs-Élysées, so my hostel friends went on without me while I tried to find a bank, some food, and a great spot for photos.


View Tour Nightmare in a larger map

Well, 30 minutes went by and I was on my own, playing chess on my iPhone with nobody to talk too. I figured that I couldn’t stand another 4 hours of this, so went on the mission to find my hostel companions. It was a decent 1km walk from where I was to one of the secure entrances to the Champs-Élysées, and by that time there was already litterally thousands of people storming their way around finding spots.

I knew I was screwed.

I walked towards the Arc de Triomphe, in hope to find my hostel mate (who was wearing a Le Tour de France 2009 gold shirt, like the 1000’s of others). It was shoulder-to-shoulder, step-by-step movements up the Champs-Élysées. At one point we were standing still waiting for the hordes of people to sort it out and keep moving.

I walked around the Arc de Triomphe, and back down the other side of the Champs-Élysées, this had taken an hour to walk 1km already, and as time was ticking closer, me without any sort of decent view of the street and no friends, I was getting rather annoyed with myself.

I ended up right down the other end of the Champs-Élysées, near the big monitors and finish line, when I decided to call my hostel friends one more time to see if I could get their where-a-bouts. Turns out they were on the exact opposite side of the Champs-Élysées as me, which meant I had to make some life changing decisions. 1, I walk all the way back, waste another hour and hope that by then I can squeeze to the front, or 2, try and get across the Champs-Élysées.

Some police walked by and after we both realised we don’t want to talk in our own respective languages, I managed to find out that the subway below the Champs-Élysées is my only hope. I walked into the subway, and of course, this subway doesn’t go under the street, you must ride the subway!

So, I took the subway back to Place de la Concorde, and there I was, back where I started, with little over 1 hour to get back to where my friends where.

I high-tailed it, managed to find my friends who were already 10 people deep (as you can see, and yes, that’s the Arc de Triomphe in the distance…)

We waited for another 30 minutes, however we were entertained by all the official sponsors of the Tour riding past in their floats. Lots of hilarity to be had, giant squirrels, giant cyclists, lots of off comments from the crowd and horrendous bad French breath!

The wait was over, and it was worth every second. We were watching the super giant TV of the live race coverage, and the excitement of the crowd as the peloton rode into Paris erupted. The crowd surged forward about 10 meters, and we all waited silently for the peloton to reach the Champs-Élysées. You could have closed your eyes and seen the peloton scream past, as there was a thunderous roar from the crowd following them throughout the entire 7 laps. Silence, then as they approach, cheers, screams and applause for the 5 seconds you see them, and then the roar moves up the Champs-Élysées like a mexican wave. Like nothing I’ve ever witnessed before! Incredible!

We did that 7 times, I tried my best to get close and take photos, however my wandering of the Champs-Élysées for 2 hours rendered that exercise useless, and I was just happy to be there at the end of it all.

Turns out our position was right in front of the podium, and we got to witness the top riders of our lifetime graciously accepting awards from the Tour organisers etc.

Until next year, Vive Le Tour!!!!