BLOG

The great Grocery Liberation Experiment

March 11th, 2008, Discussion, 1 Comment

Living in a shared apartment is a curious mix of personal and communal space. Here at Haraldsgade 54 we have a great deal of the latter and less of the former. There’s lots of space for hanging out in ‘public’ and people sit around reading books, studying or watching television. We do this on our own, together or sometimes with other friends and there are very few uncomfortable breaches of interaction bubbles. When we need some time alone there are always our bedrooms; full of personal trinkets and laundry bags. I image this is pretty much like shared accommodation everywhere. However, we haven’t yet mentioned the universal exception to this stable sanctity.

The kitchen is where boundaries are established, borders are erected and names are scrawled on packs of butter. Resident’s supplies are hoarded away behind cupboard doors and tidied from the work surfaces. But even this falls short of the true communal horror… the fridge.

This glossy, chilled box is the front line of shared living, where notes and bills are posted and war rages inside. It’s a head on crash of irrational ownership emotions. Classification by shelves is an obvious but flawed approach, which holds up only until personal ration quantities become uneven. Encroachment tactics are deployed and soon enough there’s a wide spread labelling and level-monitoring epidemic. Oh for the casual ambiance of the living room and its naive social transparencies!

After debating this for a while at a recent house meeting, we hit upon two great discoveries. Firstly that everyone spent around the same amount of money on food each week, and secondly people were sad to wake up on a Sunday to find their cupboards bare and all supermarkets shut(*).

So, Haraldsgade 54 decided to launch the Grocery Liberation Experiment, in order to purge all mental guards and instilled social norms from the kitchen area. After the uprising, foodstuffs were brought out of their isolated cells, categorised and then put back on to appropriate shelves with their new friends.

The results were visibly stunning, particularly as the duplicates started piling up: six half-full margarine pots, five opened jars of pesto and enough stock cubes to flood the streets with bouillon. Boosted by this iron curtain collapse, we declared a free state under the following constitution:

1. A weekly shop for listed essentials will be performed by house members in turn from a money pool.
2. All personally purchased food lies in the public domain by default.
3. Teaming up at meal times is encouraged and leftovers should remain on the stove.

It will be interesting to see how this turns out. Personal grievances are nearly always irrational and so everyone just has to focus on keeping theirs in check for the greater good.

Initial feedback is that this evening I wanted a leek for my soup and there was one waiting for me in the fridge. I’m now going for ice cream I didn’t know I had, while trying not to mind that hunk of cheese that’s missing from ‘my’ block.

(*) Danish trading laws

dsc06679.jpg

dsc06678.jpg

dsc06677.jpg

dsc06676.jpg

dsc06675.jpg

Culture as a delay for capitalism’s endgame

March 5th, 2008, Discussion, Comments Off

The inevitable conclusion of capitalism is a fragmented population sorted into the intelligent and the foolish, the lucky and the unfortunate, the opportunistic and the meek, the healthy and the sick and so on. One variable that may affect the rate at which this effective sorting process occurs, is the cultural values a society possesses and retains. A blunt way of expressing this is that capitalism is an inherently inhumane outlook, that is successful when self-moderated by a population with common goals.

If we start with a historically unifying event such as World War II and plot the USA’s capitalistic divide since, we might see the following:

USA, UK, Denmark

We can think of the central axis as representing the degradation of a shared sociological perspective over time. That is to say, a common outlook based on history, culture, religion and tradition that is shared by the majority of a population. It’s important here to note that I am referring to an ingrained, ‘evolved’ culture built up incrementally by many generations of a population. We can also consider the central axis to be a kind of magnetised core that pulls the two opposing results of capitalism towards the centre. As this force becomes weaker, so the graph splits further.

Here we consider the generalised capitalist fragmentation of the United Kingdom and Denmark:

dsc06674.jpg

Capitalism brought about huge benefits during its initial and mid-phases, propelling society forward at a rate biological evolution could only ‘dream’ of, but the unavoidable endgame is where the system breaks down. In order for an ideology with this kind of exponential decay to maintain its success, the left hand side of the graph must be regularly truncated and discarded thus resetting the unifying point. However in the world-views of most people and some governments, this is rather tricky to consider.

There are many factors that cause historical, incrementally-built, shared cultural values to become ‘broken’. Globalisation and the resulting mass-migration cannot be ignored as a primary cause. No matter whether the incoming population is viewed as scrounging, violent, rich, benevolent, humourless, wonderful or odd, there will always be a clash between them and established ways of life. This is something that a capitalist system can not tolerate. Anything that weakens the unity axis hastens the end game, whether it’s “damn yuppies buying up rural cottages”, “damn freeloaders taking advantage of welfare cheques” or “damn advertisers targeting new markets”.

Mass population migration only causes problems because current economic systems can’t cope with it. Remember they were doomed anyway, this is just accelerating the failure. Capitalism has given the world fantastic opportunities at a rampant pace, but it’s about time we started planning something that will fit for the future instead of persisting with something that’s looking more and more fragile. National capitalism is no longer capable of empowering a globalised world at once. Shared historical and religious values are no longer enough to keep the unity axis powered up. We need to shift to a whole new economic system that offers tomorrow’s society a single, positive trajectory.

DISCLAIMER: This is vague, philosophical speculation based on non-scientific observation and expressed using coloured pens. It is not meant to form a foundation for your revolution.

Immigration

February 14th, 2008, Discussion, Comments Off

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, Comments Off

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, Comments Off

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

Multiple Rails applications

January 30th, 2008, Programming, Ruby on Rails, 6 Comments

We are midway through a large project at the moment. It’s our biggest Ruby on Rails project for a client to date and consists of a front end and an administration area based on our DATA CARTON technology. Early on we faced several organisational conflicts between these two opposing forces.

Our DATA CARTON framework was adverse to settling in directly with its public facing companion, our models (while obviously the same) were actually required to be configured in subtly different ways, and with multiple developers and designers working together, we decided to split them into two applications both pointing at the same database.

While these logical units promised simpler security, cleaner directory structures and more streamlined development, we hadn’t tried this before but decided to just forge ahead anyway. These are the problems we encountered and how we solved them:

1. Logins

Our front end is community-based and all users of the system from newsletter subscribers to administrators share a users table. The first thing we did after pointing our database.yml file at the same database was to try logging in to both applications with the test user we had created. After only a 50% success rate, we traced the problem to our password encryption method that uses a mixture of the user’s password choice, a salt and an application specific key string. Different keys are going to result in different hashes and incompatible authentication routines in the applications. A quick switch to using identical strings and we were successfully creating users and logging-in in all possible combinations.

    def self.encrypt(pass, salt)
        finalString = pass + 'somekey' + salt
        Digest::SHA1.hexdigest(finalString)
    end

2. Sessions

Our next thought was ‘sharing sessions would be nice’. Linking administrators directly to the backend from their frontend toolbar without having to login again, passing secret messages back and forth, that sort of thing. Rails offers cookie-only sessions or database based ones. Using the more data-sensitive one is a simple matter of uncommenting these lines from the application’s environment.rb:

    config.action_controller.session_store = :active_record_store

Then in the same file (environment.rb) you’ll find your session security key and secret:

    config.action_controller.session = {
        :session_key => 'some_secret_key',
        :secret      => 'some_secret_hash'
    }

Rails generates both of these automatically when creating your application. They are sent with every non-GET request (i.e. PUT, POST, DELETE) to verify your session and protect against cross-site forgery (there’s actually a few fiddly issues with getting in-place edits working while using this method, but I’ll save that for another post).

The important thing here is to again make sure all keys and secrets are consistent across both applications. So pick one and copy it across. Once you’ve synchronised your environment.rb session settings, you’ll need to uncomment and duplicate your session secret from the top of controllers\application.rb too. Now you’re sharing sessions!

	protect_from_forgery :secret => 'some_secret_hash'

3. Subdomains

We quickly realised that our session sharing was not going to be as smooth as first anticipated, as we typically run our client’s backends on an admin subdomain (i.e. http://admin.abcdefg.com) and as cookies don’t take kindly to being requested by subdomains that haven’t sent them, we still didn’t have our single login functionality.

After much brainstorming and hunting around, we eventually found this genius configuration option that (notice the all important ‘.’ prefix) makes the cookie available to all subdomains on a domain. Finally we had truly shared sessions.

    ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.
        update( :session_domain => '.abcdefg.com')

4. Migrations / Models / Helpers / Deployment

The remaining issues are ones we are still facing and gradually solving. These tend to be less of a technical matter and more of an organisational one. We’re quickly establishing rules for how we order the migration files, share some models while keeping the security sensitive ones separate, bundling all of our helpers up into libraries and unifying deployment. We’re not quite there yet, but I’ll be sure to share our assumptions and solutions soon.

Setting yourself free

January 26th, 2008, Discussion, General, 1 Comment

“Being your own boss” is often touted as a direct route to personal freedom, a liberation of time management and the ability to just take back your life NOW! This is of course rarely true. The reality is extended hours and a constant pressure to succeed. While removing everyone more senior than you from your work life has the wonderful effect of also removing any negativity and frustration (if things aren’t working it’s no one’s fault but yours, if you can think of a better way to do things you can just do it), it also leaves you constantly dealing with a raw reality that a more structured hierarchy would help protect you from.

These days we are usually quite well time managed at Spoiled Milk, but due to several very large projects reaching a simultaneous climax at the end of this month, some of us are currently being forced to work very extended days. Curiously, despite the pressure and stress, the quip of “I’m working 14 hours a day for myself so I don’t have to work 7 for someone else” does hold some ground, although it’s quite often hard to pinpoint exactly why.

-

Ruby on Rails is a programming language and Web application framework that I’ve only dabbled with in the past, but my intensive work pattern recently has doubled up as in intensive training course. I’m tempted to start a series of coding related posts to share the solutions to some of the trickier hurdles I’ve come across.

Would anyone mind? Is this a good idea? I’ll tag them with something appropriate so they can be filtered out, and I’ll try to keep up the amusing stories of Danish police-patrolled cycles lanes.