BLOG

Archive for February, 2008

Immigration

February 14th, 2008, Discussion, Leave a comment

The immigration policies of countries around the world are fast becoming the approved knee-jerk method to evaluate how that place stands in global moral and social order. From the racist to the paranoid to the odd, countries that impose new border tightening measures tend to attract scorn from the rest of the ‘free’ world, while being generally accepted by the occupying ‘native’ population.

At one time immigration policies seem to have been drawn up by governments keen on expanding their skilled workforce and/or their cheap labour and were dutifully accepted by voters on this premise. Without these economical issues to guide ‘free-thinking’ thought, would cultural migration have come anywhere near as far as it has? Some people think not, leaving us with the concept that world markets have actually contributed to emotional-society in a positive manner? Hmm.

Anyway, even in countries with supposedly forward thinking policies, things seem far from harmonious. Where has mass generational migration of a culture ever really resulted in workable, lasting integration? Maybe the single, global understanding we are all supposed to strive for is being driven at a speed dictated by the economy’s lust for a generic consumer, instead of by something more in tune with its delicate nature?

Two extreme examples of culture mixing could be: the marginalisation of Native American and Aboriginal cultures (newcomers destroying culture), and immigrant quarters/enclaves (newcomers living outside of national culture through choice or society-imposed segregation). Neither of these methods are championed by the collective conscious, but why is this result so common in practise?

littlebritain.jpg

Fossiling

February 10th, 2008, General, Trips, 2 Comments

The weather yesterday was remarkably nice for the time of year, so I went fossiling in Sølrod municipality. My reasons were because I’d never travelled further south than Ishøj on the S-tog and because this website promised fossilised sharks at Kalstrup lime quarry, and I thought I’d like one for my room.

An hour after leaving the train station at Sølrod in a westerly direction, I was beginning to regret not bringing a map. The area is a hotchpotch of tiny villages and vast open countryside. All I had to go on was a brief glimpse at Google maps twenty minutes before I left home.

I decided to stick to the roads and just enjoy the exploratory walk. During a total walking time of four hours, I remarkably managed to not only find the anticipated kalkgrave, but also to navigate myself to the distant village of Karlslunde and a bus journey home. The only upsetting part was that by the time I reached the quarry, the light was too disappointing for any photography or excavating.

Feeds

February 10th, 2008, Discussion, Good things, 2 Comments

E-mail is fantastically popular and probably the most widely used internet technology. Even the generations outside the traditional scope of the internet explosion seem to grasp the concept. I think the reasons for its growth are two fold. Firstly the direct benefits to communication in the workplace saw it quickly adopted en masse and introduced into employees’ daily lives. Secondly the growth of web-based clients, such as Hotmail, in the late 90’s brought the benefits to the social realm, all wrapped up in an accessible interface. All of this is wrapped up with an elegant name. Electronic Mail is an analogy that most people quickly comprehended by glueing together their experience of the regular mail system along with telegrams and the telephone.

The above introduction already starts to list the reasons why feeds haven’t achieved the same degree of ubiquity. They are sadly still lingering around the fringes of ‘geek territory’ and still fail the explain-this-to-your-parents test. Feed, RSS, XML, Atom, aggregate and syndicate are all terms that do nothing to demonstrate the frighteningly simple concept.

The feed analogy should be as easy to grasp as electronic mail. For those of you still confused by the technology: a web feed is essentially being told about new information in a timely manner within the comfort of your own ‘home’.

We can consider browsing a list of bookmarked websites each day, to be analogous with routinely visiting several shops to see if they have what you want. The fresh milk or new jumper might not be in stock for days, but we have no way of knowing and so must keep checking back. Sometimes we are successful, other times we are not, but the effort is always the same.

In this same world, feeds are much like hand-delivered parcels. We’ve told the shopkeepers what we’d like and so the items are packaged up and sent directly to our door when ready. If receiving an e-mail should be like receiving a personal postcard from a friend, then receiving a feed is having magazines or goods delivered. An e-mail client will receive the former, and a feed reader the latter.

E-mail is of course heavily abused these days. It’s used for many impersonal tasks such as content mail-outs, update notifications, status notifications, etc. In fact it’s precisely because e-mail is so widely adopted that it’s become the landing ground for all these things. E-mail is now like a ringing phone constantly demanding attention.

If having a newspaper delivered to your door sounds preferable to trudging to the newsagents every day, or even having the journalist call you up every time there’s a new story then maybe feeds are for you.

This video is an excellent introduction:

Recently

February 5th, 2008, Drawings, Leave a comment

I just found these half-finished pieces in my sketchbook that I’ve forgotten to finish. I should finish them.

While I was flicking through the images on my laptop a very strange thing happened to the portrait drawing. I started rotating it in Windows Image Viewer and on each 90° turn the image started degrading. Then it started saturating itself, before eventually blurring into the threshold colour mess you see below.

Now I realise that most of the operations available in Windows Image Viewer are lossy (it transforms, reapplies the compression algorithm and then re-saves over the original), but the effect was quite ridiculous/amazing in only about 1800°. I quite like it. I think it looks like some thermal imaging paper baked in the oven.

I’m planning to attend the Copenhagen Ruby Brigade meeting tomorrow night. I think they switch meetings to English should people of limited Danish fluency turn up. I hope this is true.

dsc06604.jpg

dsc06605.jpg

dsc06610-4.jpg

dsc06610-2.jpg

Customising form controls in Rails

February 3rd, 2008, Programming, Ruby on Rails, Leave a comment

Here is a simple way to implement custom form controls while still using Rails’ standard helpers. For this example, we’ll implement a two-state graphical alternative to a check-box (usually implemented by the operating system and uncustomisable via CSS), which represents a standard boolean field in your database model.

Normally we’d do something like in our view:

    <%= form_for @model, :url => { :action => :create } do |f| %>
        <%= f.check_box :someBool %>
        <%= f.submit("OK") %>
    <% end %>

But we’d like to use something a little like this to represent our field instead:

Active
Inactive

Firstly the images are added to our Rails view via the helpers, with the addition of assigning each one an ID and an inline style to hide the one opposing the required default state:

    <%= image_tag("signUpItemActive.gif", :size => "13x18",
        :alt => "Active", :id => "checkActive") %>
    <%= image_tag("signUpItemInActive.gif", :size => "13x18",
        :alt => "Inactive", :id => "checkInactive",
        :style => "display:none;") %>

These are then both wrapped in a single anchor tag, which is given an onclick handler to a JavaScript function.

    <a href="#" onclick="toggleCheckBox(); return false;">
         <%= image_tag("signUpItemActive.gif", :size => "13x18",
            :alt => "Active", :id => "checkActive") %>
         <%= image_tag("signUpItemInActive.gif", :size => "13x18",
            :alt => "Inactive", :id => "checkInactive",
            :style => "display:none;") %>
    </a>

The next step is to modify our standard Rails form to assign the check-box an ID, and hide it with some more inline CSS styling. This means it won’t be visible, but will continue to send its value when the form is submitted:

    <%= f.check_box :someBool, :id => "hiddenCheckBox", :style => "display:none;" %>

The JavaScript function can then be defined in Application.js (this could of course be modified to take the IDs as parameters):

    function toggleCheckBox()
    {
        elementActive = document.getElementById('checkActive');
        elementInactive = document.getElementById('checkInactive');
        elementHidden = document.getElementById('hiddenCheckBox');
 
        if (elementActive && elementInactive && elementHidden)
        {
            var state = (elementActive.style.display == "none");
            elementHidden.checked = state;
            elementActive.style.display = state ? "inline" : "none";
            elementInactive.style.display = state ? "inline" : "none";
        }
    }

There we go! Clicking the dummy check-box graphic will toggle the images and set the value in the hidden check-box at the same time. There is only one remaining step and that is to set the default state of the images to match the existing value of the boolean field. Without this the graphics and the form are likely to get out of sync. Even if the form is for creating a new record, the page will be shown again in the event of a validation error.

Another JavaScript function can take care of this:

  function setCheckBox()
    {
        elementActive = document.getElementById('checkActive');
        elementInactive = document.getElementById('checkInactive');
        elementHidden = document.getElementById('hiddenCheckBox');
 
        if (elementActive && elementInactive && elementHidden)
        {
            var state = elementHidden.checked;
            elementActive.style.display = state ? "inline" : "none";
            elementInactive.style.display = state ? "inline" : "none";
        }
    }

Then call this from the page’s body onLoad event:

    <body onload="setCheckBox();">

Dinner

February 2nd, 2008, General, 5 Comments

Today was my first day off for three weeks. After being holed up in an office (complete with its recent scaffolding sarcophagus) for so long I decided to spend the day out in the open and took a long stroll around Ydre Nørrebro. Despite the recent bitter coldness, the sun was shining through the clouds more than it has done for a long time. My programming-numbed-senses were in overdrive over the simplest things and everything was so heightened. It was great!

One of the places I stumbled upon again was Balders Plads. It is a lovely, small residential square with architecturally grand buildings all varying in style from each other. However because of its location inbetween the far end of Nørrebrogade, Tagensvej, a few squats (+Bumzens Café) and the edge of Nordvest, it has much more of a Kreuzberg feel than similar looking places in København. There were a few apartments for sale on the square. I’d like to live there.

My friend Andreas is staying over with me this weekend. He’s currently living in Stockholm, but is attending an independent gaming workshop in København, where it seems the plan is to stay up all hours and write a game in three days. He arrived at my house at 2am this morning after the busy first day and left again at 8am. I’m not sure when he’ll be back but I cooked my first meal for a while this dinnertime, so I’ll leave some in the fridge for him. Although I expect he will have food provided, so maybe it will be my lunch tomorrow.

dinner.jpg