thoughts of the driver

June 19, 2009

New ICESAVE agreement compared to treaty of Versailles

Filed under: General — Steinn E. Sigurðarson @ 4:57 pm

This morning, radio journalist Sigurður G. Tómasson of Útvarp Saga, had as a guest an Icelandic economist and assistant professor of economy at Reykjavík University, Ólafur Ísleifsson. They discussed the commitments of the new ICESAVE agreement entered into by the Icelandic government. Pundits are expressing extreme concern over the agreement’s terms, which are said to include the right by either of the other parties (British and Dutch governments) to call in the loans before their due date for several reasons, such as the Icelandic government not honoring any payment of any loan of (approx.) 10 million pounds or more. Ólafur Ísleifsson said dishearteningly that he hadn’t read a single agreement or treaty between sovereign nations, where one party was addressed so one-sided-ly and defeated-ly, except for the treaty of Versailles.

For some very fuzzy/suspect reasons it was only “released” (leaked actually first) yesterday, while apparently signed by Steingrímur J. Sigfússon, finance minister of Iceland, on the 6th of June this year, myself and many other interested Icelanders have not yet had the time to read the agreement and come to any conclusions, but this comparison made by Ólafur this morning is very depressing, especially in the light of numerous legal experts of different nationalities who are claiming the legal grounds for the Icelandic government to assume these responsibilities are far from stable, and this matter is a matter for the courts to decide.

Naturally, I’m not a proponent of running to the courts every time you make a mistake, and indeed the Icelandic financial authorities may have made mistakes or failed to act. Why that happened, whether incompetence, corruption, or insufficiencies of the legal infrastructure has yet to be discovered, and as I pointed out in an earlier entry, the cost of those mistakes may just be too great for Iceland to pay.

Anyone interested in the actual agreements, here they are, courtesy of Economic Disaster Area.

digg this

June 3, 2009

The debts of Iceland, put into perspective?

Filed under: Economics, General — Steinn E. Sigurðarson @ 6:27 pm

I heard an interesting thing today, from an Icelandic economist, who recently joined the parliament. The Icelandic debts due to Icesave and other failed banks, valued at $5.8 billion, would be a huge burden on the Icelandic economy — paying these debts would require several years of reduced infrastructure (healthcare, education, social services), as well as selling some natural resources (at a time when it’s a buyers market, no less). He said, that if you take this debt as a proportion of the UK’s GDP, and and then multiply that percentage with the Icelandic GDP, the resulting number would be something rather trivial — around 300 million ISK (if I heard him correctly), which is equivalent to about 2.5 million dollars. Pocket change for a big country, right?

Now, because I thought this was pretty amazing, I went ahead and did some of my own calculations, and based on the GDP figures for Iceland and UK, as reported by Wolfram Alpha, and the (700.000.000.000 ISK = $5.8 billion) icesave-related debt, I decided to do some calculating.

As you can see here, I calculated that for an economy of the size of UK, to pay off the $5.8 billion, would be about the same load relative to the GDP, as if Iceland was paying off a debt of $39 million. Now, that’s obviously more than an order of magnitude away from what the Icelandic MP quoted (although him being an economist, and me being a programmer, I left the fields on my little calculator open for change!), it’s maybe not what I’d consider pocket change for the Icelandic government, as 0.21% of a country’s GDP shouldn’t be, but it’s a damn sight more possible than the possibility of paying more than 30% of a country’s GDP. To put the debt into more perspective, the entire Icelandic government budget for 2009 is $4.6 billion.

So, the idea of the exercise was pretty much to verify my MP’s claim, but on further examination, I figured out a couple of interesting things as well: what is currently happening to Iceland, if it were to happen to the UK, at the same scale the UK public would be asked to accept liabilities of around 864 billion dollars. Now, I’m not defending any bankers, but I’m pretty sure that UK public opinion on that kind of “bailout” would be rather divided, to say the least.

I Hope to get some reactions — especially in case I’ve made some drastic mistake somewhere (excuse: this was a quick hack at the end of the day, in order to procrastinate a bit!).

digg this

Slightly different take on javascript library detection..

Filed under: General, Technology — Steinn E. Sigurðarson @ 9:07 am

A small update in reference to this, a post I wrote earlier about upgrading my WordPress, and also a javascript method to safely check if a js library has already been loaded in a parent system of a widget or module.

I don’t know about you guys, but in my case, my earlier code would start acting up on my firebug sometimes, and it would force me to step through the exception which it was catching — very annoying, so I made another version which doesn’t use exceptions.

if (typeof(MooTools) !== 'undefined')
{
                // We have MooTools, is it recent?
                var numv = parseInt(MooTools.version.replace(/\./g, ''));
                if (numv < 122)
                {
                        // old version, what do we do?
                }
                else
                {
                        // new version woohoo! do nothing!
                }
}
else
{
        // Failure, we assume MooTools is not setup, and we include it
        // XXX: check here for prototype/jquery and abort in that case

        var head = document.getElementsByTagName("head")[0];
        var newscript = document.createElement('script');
        newscript.type = 'text/javascript';
        newscript.src = '/blocks/indicators/code/mootools-1.2.js';
        head.appendChild(newscript);
}

I do however think that my firebug and firefox combo on the windows machine are simply f*!@#$% …. but who cares… more code, another post, we happy! =)

digg this

April 27, 2009

Simple ways to strengthen your immune system

Filed under: General — Steinn E. Sigurðarson @ 6:13 pm

Without being alarmist, I find there is quite a lot of buzz online about the swine flu, and it’s possibility of becoming a global pandemic. Since I’m a bit of a health nut, I figured now might be a good time to share some of the ways I’ve come across in recent years, which according to research help boost your immune system.

1. Get enough rest. [1,2,3]
2. Stay calm and reduce stress. If possible, medidate, or perform other activities which reduce stress (stress hormones directly cause apoptosis of white blood cells). Other activities could include being affectionate with your (non-infected) loved ones. [4,5,6,9]
3. Use immune-boosting supplements such as Zinc or Vitamin-C — these supplements do not cure illnesses, but being deficient in them will affect the immune system negatively, and keeping your zinc and C levels high boosts your immune system. [7,8,9,10,11]
4. Do not stop exercising, and if you do not do so already, start: moderate physical exercise causes an increase in white blood cell production. A simple yet effective routine to do *at home*, is to do some pushups, squats, and crunches. Moderate is the keyword though, as complete physical exhaustion is probably not desirable. [12]
5. Eat spicy food, there have been some findings that spicy food, containing for example chili helps boost the immune system or fight illnesses. But mostly it tastes good, and makes your dishes keep longer (that’s why it was invented).

Now I could’ve found more references, and I’m sure there are more articles out there on this subject, so that should excuse my laziness. By the way, I’m not bothering with references for the 5th tip, I think eating spicy food speaks for itself ;-)

References.

1. http://www.ncbi.nlm.nih.gov/pubmed/10443758?dopt=A…
2. http://www.springerlink.com/content/wh8185q43g2325…
3. http://myheartmind.blogspot.com/2008/07/immune-sys…
4. http://www.pubmedcentral.nih.gov/articlerender.fcg…
5. http://www.nhs.uk/news/2007/October/Pages/Meditati…
6. http://www.springerlink.com/content/kk477701223g14…
7. http://www.ncbi.nlm.nih.gov/pubmed/7749260?dopt=Ab…
8. http://ods.od.nih.gov/FactSheets/Zinc.asp
9. http://my.clevelandclinic.org/disorders/chronic_fa…
10. http://www.positivehealth.com/article-view.php?art…
11. http://www.ltdk.helsinki.fi/users/hemila/immunity/
12. http://www.nlm.nih.gov/medlineplus/ency/article/00…

digg this

April 15, 2009

Fatal error: Cannot use object of type WP_Error as array

Filed under: General, Technology — Steinn E. Sigurðarson @ 2:45 pm

Quick post, since others face the same problem. When I updated I added a captcha plugin to my site, since I was getting about 10 spammers registering per day. This means that you need to enter a captcha phrase to register as a commenter here. If you however entered the wrong phrase, you were confronted with the lovely error:

Fatal error:  Cannot use object of type WP_Error as array...

A look at the code revealed the plugin to be checking if the captcha entered was correct, and then doing something like this:

$errors["error"] = "ERROR: You must enter the correct letters displayed in the image.";

(I’m not printing it verbatim because I’m too lazy to open the original file)

Obviously $errors (a global) was not an array, but an object of the type WP_Error. Solution: To read up on how WP_Error works, and use it? Easy peasy?

Not quite.

Simply using the preferred $errors->add(’errorcode’,'error message’); didn’t do the trick, in fact changing the code to that caused an even worse behaviour — instead of there being a fatal PHP error, the captcha simply didn’t complain at all, and new users were able to register at will — oh the humanity!

After checking wp-login.php, where they call the hook “register_post”, which the captcha user registration plugin was hooking into, I saw that it calls it like this:

do_action('register_post', $user_login, $user_email, $errors);

Eureka! I can’t simply use the global $errors array, I must use the one supplied to me by the do_action! Immediately I modify the capcc_validateregister function so that it’s declaration takes in 3 parameters, $user_login, $user_email, and the coveted $errors I so hoped to use. Errrrrr, now I got another wonderful error, that arguments 2 and 3 were missing! Oh lord, I was only getting the desired username!

After digging through into the definition of do_action in wp-includes/plugin.php, I found out that it actually loops through all it’s supplied arguments and appends them to a list of arguments which it then uses for all functions which are hooked in to this hook, but each of them has a little configuration variable called “accepted_args”, and upon freshing up on the wordpress plugin docs for hooks, I finally found the answer to my problem.

add_action('register_post', 'capcc_validateregister', 10, 3);

Where 10 is the priority level (10 is default, which I assumed was good enough), and 3 is the accepted_args parameter.

So hooray, captcha works, and now “all” my readers will know how to fix their “Cannot use object of type WP_Error as array” problems:
1. Make sure you are using the right $errors (in register_post case it is supplied as arg #3)
2. Use $errors->add(’errorcode’, ‘message’); instead of $errors['errorcode']= ‘message’;

Hopefully getting point 1 down will be quicker than it was for me, as including the writing of this post, it’s taken an hour of my time! And I really should be debugging a cool app which I’ll blog about later!

digg this

April 2, 2009

Upgraded..

Filed under: General — Steinn E. Sigurðarson @ 3:40 pm

Thanks to “wildcard”, a benevolent user who informed me how someone was using some of my posts to promote medications against erectile dysfunction, I have now upgrade my WordPress. It was either that or closing the blog — apparently I have registered myself for some planet sites, or am being picked up by some feed aggregators somewhere, and well, I wouldn’t want to propagate spam.

On another note, I actually never published the blog entry below, and I was fast asleep while it was published. It seems the spammer who compromised my entries did so for a sequence of post ID’s, starting with 63 and ending with 69. I guess the spamming mechanism also sets the post_status to published, as I guess this minor rant about JavaScript’s escape/unescape functions was an old draft.

Well, glad to see I have some audience for my varyingly intelligent outbursts anyway.

…. To turn this into a more fun blog post, I’ll write something about my work too:

Yesterday I spent probably 3 hours tracking down various problems related to having two independent modules within Moodle, both relying on and including MooTools. The first problem was easy: One module (a theme actually, which I am developing) was using an older version: MooTools 1.2.0. The other module (a block) was relying on 1.2.1 — embarrassingly but conveniently I wrote that one too, however I only wrote the moodly-blocky wrapping part, while my coworker Christian Glahn did the fancy JS stuff inside. A quick check on things revealed I could replace the older version of MooTools with the new one and voila: no more JS errors and conflicts. (google-help: The JS error was only appearing on my iPhone webkit browser, and something to do with Browser.freeMem not being an object).

But no, this was not the end of my problems, still there were bugs, but mysteriously no errors. For some incredibly “odd” reason, the anonymous function I added to the domready Event in my theme just wasn’t being executed. After severe amounts of searching I came to the conclusion that no one else had the same problem I had, and I was simply doing something horribly stupid and wrong. I started debugging the internals of MooTools, after trying unsuccessfully several times to examine the contents of Events.$events, and never ever finding my theme code in there.

Before starting to chase down this behavior, I had actually had a conversation with Christian where we decided I should simply write a mootools initialization script, which would check if MooTools existed, and if so which version, and try to make some kind of intelligent decision whether to create a couple of script elements and squeeze them into the head. It was at this moment, I realized that the 2nd MooTools inclusion, was of course redeclaring everything, and thus clearing my Events.

Problem solved. Solution: don’t expect things to work when including the same JS library several times from different locations… and don’t be stupid, I guess I’ll have to work on the 2nd one, so time for coffee.

For fun, here is the solution I hacked up, in all it’s glory (no complaints on the iphone either):

/* Checks if MooTools already exists, if not includes it. */

try
{
	if (MooTools.version)
	{
		// We have MooTools, is it recent?
		var numv = parseInt(MooTools.version.replace(/\./g, ''));
		if (numv < 122)
		{
			// old version, anything smart we can do?
		}
		else
		{
			// new version woohoo! do nothing!
		}
	}
}
catch (e)
{
	// Failure, we assume MooTools is not setup, and we include it
	// XXX: check here for prototype/jquery and abort in that case

	var head = document.getElementsByTagName("head")[0];
	var newscript = document.createElement('script');
	newscript.type = 'text/javascript';
	newscript.src = 'path/to/mootools-1.2.js';
	head.appendChild(newscript);
}

Merry times on the internets.

digg this

Turns out..

Filed under: General, Technology — Steinn E. Sigurðarson @ 8:11 am

That the javascript “escape/unescape” function combo sucks.

If you care about not trashing non-ascii characters for example, stick with encodeURIComponent/decodeURIComponent

Oh and if using PHP, stick with rawurlencode (but I guess everyone knew that one already).

peace

digg this

January 27, 2009

Some thoughts on game based learning

Filed under: General — Steinn E. Sigurðarson @ 12:41 pm

I’ve recently started a new job. It’s at a place called CELSTEC, and it’s pretty cool. Almost as cool as the military-commandcentric name suggests. The CELSTEC is an institution of the Open University of the Netherlands, and it’s where some of the brightest people in the field of technology-enhanced learning have gathered together to build cool new things. Amidst sessions of hacking/testing/hacking/developing and playing halo 3, once in a while it almost feels like “work”.

Personally my role will be as a software developer, supporting the researchers of two groups: learning media, and learning networks. I guess my current skillset makes me instantly valuable to the learning network group, and slightly less, but increasingly, valuable to the learning media. This post I will use to reorganize and foxhole some of the thoughts that have been springing up, as a result of my exposure to fertile minds here at the CELSTEC. Through several conversations and exploratory tests of different media with my friend Sebastian Kelle, I’ve come to think about the essence of gaming. I figured out two essential features that games must possess either or both, in order to entice me:

* The ability to build up something (visible progress), I will refer to this ability as “build-up” from now on
* The ability to set back an opponent (reduce/reset their progress), I will refer to this ability as “destruction” from now on [this feature is a sub-feature of simple competitiveness based on points, it goes further]

Most games that I play will possess both of these features, if we take my favorite first person shooter, Quake 3 as an example, we find that it has a rather limited ability for building up. The build up possibilities are few and most are transient aside from points (frags); weapons, armor and health (rebuilding). However the possibilities for destruction (setting back an opponent) are tremendous, and an experienced player can easily “control” his surroundings and completely deny his opponent any chances at progress, even with very little build-up. Depending on the player’s style, he or she might choose to intelligently control resources, and thus rely on better equipment and armor to defeat their opponent, but very experienced players usually have learned how to both keep track of when armor/power-ups reappear and how to deal damage much more consistently than beginners. Adding to the destruction aspect of the game are gory death sequences, and the possibility to “gib” an opponent, which means their body explodes into blood and mutilated body parts, as well as “taunting” which causes the player model to make annoying/obscene gestures as well as sounds (usually haughty laughter).

Another of my favorite games, StarCraft is in a completely different genre; real-time strategy. This game offers, and usually requires, a lot more build-up than FPS games in general, although the ultimate goal is always the destruction of another player, be it human or computer. Certain smaller maps may offer possibilities of less build-up, as if the distance between players is low the one who can launch an attack sooner (a tactic known as “rushing”) often catches the other off-guard, and can defeat them or upset their early strategy enough to cripple their progress and defeat them in a coming wave of attack.

StarCraft, and other RTS games are an example of a game which seems to possess the build-up and destruction aspects in rather equal terms, but there are also games which are almost exclusively build-up, although they are usually single-player, such as various puzzle games (tetris, bejeweled, sudoku, etc), single-player role-playing games, and many older pre-multiplayer era games.

I am sure there are more complicated and accurate ways of classifying games, however as someone who’s spent most of his life casually playing computer games, I’ll take an academic chance and keep rambling, without reviewing existing literature first. So let’s continue to the fun part:

How do we give an application we have, the “build-up” aspect? What makes the user appreciate his actions in a way that they feel they are building something up, achieving something (now this feeling should be quite familiar to learners I hope) — how would we make say, facebook have this aspect?

The answer is quite simple for facebook actually, since it already contains several features which make it a prime example of an application we enjoy using due to the build-up, also many of the 3rd party applications built for it help give facebook properties which are incredibly close to gaming. A few of the ways facebook makes you feel like you’re building something up:
* Your total number of friends
* Your wall posts
* The groups you’ve joined
* The artists/movies/products you become a “fan of”
* … etc

Facebook, like most social software gives you the ability to build-up an identity. The user has the ability to construct a representation of themselves, and this representation is an extension of their being. This is usually done by the user to increase their social currency, or value so to speak. In many cases the identity constructed by people using social software is misrepresenting for the person, people hide their flaws to appear (and thus be) more socially valuable, or in some cases the other way around — an introverted and shy person might better expose their true identity in an online environment, and finally in some cases people use separate online identities to express other aspects of themselves they wouldn’t usually be able to without social side-effects.

However the key element which makes gaming experience more immersive and intensive than using facebook, is usually a short feedback-loop coupled with obvious progress indicators. What this means is that the user sees very quickly whether or not their actions are having a positive or negative effect. This is important to learning, and required for competition of any sorts. Formal education usually has longer-feedback loops, where it can take up to several weeks for a student to receive an assessment of their assignment, and the assessment is usually not very forgiving — if you turn in a lousy paper, you’ll hopefully know why it was lousy, but you won’t get a chance to improve until the next assignment, and perhaps your mistake already cost you the course, possibly causing another year to go by before you get another shot. Another issue is that even if you receive your assessment quickly, it never feels like a game, as it’s all private and you might not know how anyone else fared.

So… braindump over for now, but the gist is: how about a learning application where you solve subject-related problems, see how far from completion you are via progress indicator, and by hastening your progress there is the chance of disrupting another persons (via adding to the total no. of problems they need to solve), or a chance to reduce a competitors workload (via reducing the total no. of problems they need to solve: this implements “teamplay”). Other interesting progress indicators: average standing of students solving the problem, for realtime applications: how far from completion the first one is (possibly using nicknames), and for non-realtime applications: the best time so far, and how close in % you are to it, and besides it you see how close to finishing the project you are. In this idea time is an important element, but so could automatic scoring of the users performance, etc.

digg this

August 22, 2008

using ubuntu and being a developer..

Filed under: General — Steinn E. Sigurðarson @ 3:01 pm

My first linux (redhat 4.2) came with a lot of things I took for granted. Ever since switching to ubuntu (because let’s face it, ubuntu is a great linux distro, debian on the desktop that *works*), I’ve regularly run into the problem of not finding man pages for some basic ansi c stuff. Today I finally lost my temper, and instead of relying on some online man pages dug through the packages and found it “manpages-dev”. Thanks to whoever decided these 3043kB of diskspace should be spared by default. Argh.

digg this

June 23, 2008

The story of stuff

Filed under: General — Steinn E. Sigurðarson @ 4:05 pm

I finally was bothered enough to watch the short documentary, “The Story of Stuff”. It’s a beautifully narrated and animated documentary explaining how the current system of ever increasing consumption, is at once artificial, world threatening, and possibly against our very nature.

Great stuff, highly recommend people take 20 minutes to watch:

digg this

April 17, 2008

Poverty, scarcity, digital fabrication and you

Filed under: Freedom, Technology — Steinn E. Sigurðarson @ 2:50 pm

Today my friend Smári P. McCarthy pointed out to me his recent writeup on digital fabrication, Digital Fabrication as a Catalyst for Freedom. For those who are not familiar with the promise of digital fabrication and how it may affect the world, I suggest you read this paper, Atoms from Bits The Digital Revolution in Manufacturing, and for the really lazy, I’ll sum it up: Digital fabrication is the process in which an object is constructed physically from digital information (a CAD document for example), now we are on the cusp of an age where digital fabricators, or “fabbers”, are within the reach of regular people to build, own and operate. Couple that with cheap raw materials, and you have a scenario for a substantial reduction of scarcity, seeing how scarcity is a major factor in how the free market and our global economy functions, this could have widespread consequences.

In effect, the digital fabrication technology is the first step towards a world just-about as equally unencumbered by material costs and scarcity, as the world of software is today, and the success of Free Software stands as a shining monument to what happens when abundance and socialism meet — great benefits for everyone. [Ok, I'm a little biased, but I'm right ;-) ]

But the beauty of Smári’s article lies not in any detailed technical descriptions of how “fabbing” works, or any overly long and elaborate dreamlike paragraphs on what the future may hold, but how important it is that when the time comes, and technology has delivered us into abundance, that our political and economical thinking adapts to the new scenario, so that everyone indeed benefits and the inequality existing today recedes further into the dark ages as it should. I think Smári puts it best;

Nothing fundamental will change in our perception of the physical world by our being able to assemble a stuffed turkey atom-for-atom. We already have access to stuffed turkeys, so we already know what having them does for us as a people. Yes, certainly, there will be new options available to us, like growing skyscrapers out of diamonds, but that is not where the greatest entry point for discussion of digital fabrication lies. Rather, it is in the economical impact, which is hard to quantify.

Digital Fabrication as a Catalyst for Freedom on Smári’s blag.

digg this

March 17, 2008

You can’t spell RISK without ISK

Filed under: Economics, General — Steinn E. Sigurðarson @ 3:48 pm

Today the currency of my native country of Iceland has fallen by 5.9% and the current EURISK rate stands at 118, whereas last summer it could be found hovering around 88, so the effective drop since then is about 34%.

According the reports found on foreign exchange sites such as fxstreet.com, this is written up to the current risk-aversion we see in global markets, and the fact the the Icelandic banks’ expansion of late was mostly fueled by high-risk investments and financing.

Couple this situation with an inflation of 9% for the last 12 months in Iceland, which is sure to increase rapidly due to the following facts:
1. Iceland has an import/export trade deficit of 2.5 billion euros in 2006 (that’s according to the 118 exchange rate). Divide that amongst the 300.000 inhabitants, and you have each persons debt increasing by 8.300 EUR per year.
2. The real-estate loan market is completely financed by index-linked loans, which are linked to the consumer price index (CPI) as published by Statistics Iceland institute (statice.is), which has by the way risen 27.5% in the last 5 years. These loans since 2004 have been primarily provided by the Icelandic banks, which are now offering them at around 6.5% interest linked to the CPI, which has risen over 6% per year for the last two years.
3. The CPI includes real-estate costs, so in effect there is a possibility for a (downward spiraling value) feedback loop.

I’m not an economist, and perhaps I’m getting a few things wrong, but overall it seems the economy of my little island, which has in the last few years been rocket-propelled by endless expansion of the banks, large industrial undertakings (aluminum plants, etc), and the recent few years of blooming investments worldwide, is not braking like the rest of Europe; suddenly but with ABS, but rather crashing quite uncomfortably into concrete barrier.

digg this

Next Page »

gin 0.759 & tonic. | Powered by WordPress