thoughts of the driverSteinn Eldjarn Sigurdarson on tech, tel, digital freedom and possibly his life..

April 27, 2010

the Nordic Perl Workshop’s (volcanic) woes…

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

The Nordic Perl Workshop which was supposed to go ahead this weekend is now dying a slow and painful death as Eyjafjallajökull continues to spew it’s farts all over our skies, and the erratic yoyo-ish opening and closing of Keflavík airport puts more gray hairs on my head every day.

We (FSFÍ) somehow got ourselves involved with having the workshop, and since I happen to use Perl a lot (although I’m no guru) I stepped up to try and organize. Although the timing of the whole thing coincided rather badly for me due to personal and professional reasons, the rest of the FSFÍ board was even more busy with matters of digital freedom and law making in Iceland. Things started off peachy: we Icelanders have it easy when it comes to organizing conferences, everybody wants to come here (for the nature, not the people), so organizing an international event in Iceland is about as easy as e-mailing a couple of heavy hitters “Hey what up, wanna come to Iceland and talk about some shiiz?”, and whipping up a registration page.

For fans of Wayne’s World 2, you’ll love Iceland.. and my organizing “skills”. Just about the only thing powerful enough to upset plans of my caliber, would be the spontaneous glacially enhanced glass-shard synthesizing volcanic eruption, just the type which doesn’t really kill anyone, except if you are flying a jet-engined plane and very unlucky. I’ll leave it to others to discuss the legitimacy of the “great 2010 air-delay”, but for all it’s wonderful jokes

(who can forget classics such as “Iceland! We said CASH, not ASH!!”, the nationalistic: “Sorry Europe, we were aiming for London and Amsterdam!!”, or my favorite: the sublime “The last wish of the Icelandic economy was to have it’s ashes scattered over Europe”)

…I am no longer laughing.

To the brave souls who are coming here anyway, risking to fly through one of our countryside airports, willing to take the 8-12 hour bus-rides to get to Reykjavík, I salute you and will surely enjoy your fabulous company. To the rest who either postponed or cancelled, I understand and hope to see you later this year if we manage to salvage this (natural) disaster of a situation!

digg this

April 21, 2010

Linux fork() zombie processes problems..

Filed under: Technology — Steinn E. Sigurðarson @ 10:44 am

Recently at work I was porting some code from HP-UX to Linux, and ran into a problem. The code in question belonged to a service which listens on a socket, and forks a child to handle each incoming request. The children among other things execute a sub-process using system(), and check it’s return value to know if the sub-process executed successfully. When you fork without calling wait() your children become zombies apparently: I guess it’s because nobody is reaping their return values or something.

To fix this, on HP-UX you apparently do this:

signal(SIGCLD,SIG_IGN);

Note that the signal used is SIGCLD not SIGCHLD, this is probably due to the age of the code. If this same “fix” is applied on Linux however, the system() function can’t return the sub-processes return value, because the parent program is already set to ignore SIGCLD (and SIGCHLD?). I initially solved this by having the parent process wait() for it’s children, but failed to realize that wait() is a blocking call, so it effectively slowed my server down to processing 1 request at a time: BAD.

When I setup a signal handler for SIGCHLD like in the link below however, my problems were solved: my parent process didn’t block, and forked for new requests, no zombie processes (because of waitpid() in the SIGCHLD handler) and best of all, my system() calls managed to return the return values of the sub-processes.

Thank you Linux Programming Blog :-)

digg this

February 19, 2010

Excluding sites from Google Chrome Flashblock extension

Filed under: Technology — Steinn E. Sigurðarson @ 3:20 pm

The Google Chrome flashblock extension is a must-have addition for users intending to browse the web in peace and safety from evil flash advertisements and other flash critters which infest websites in ever greater numbers. Especially for us Linux users who are forced to use the notably weak Linux version of Adobe’s flash player, which loves nothing more than using all the cpu cycles it can get its hands on, and probably memory like an atog, because nothing humbles my dual core 2.53ghz 4GB ram (a few years ago this would have been a mighty fine server!) T400 thinkpad more than a couple of websites where greed fueled ad sales have overpowered the customer experience factors long ago.

Anyway, to the juice of the entry, if you’re running the google-chrome beta on Linux, and were as unable as I was to find the configuration interface to add exceptions to the flash, then this could be of help.


$ cd .config
$ cd google-chrome
$ cd Default
$ cd Extensions
$ ls

Now you should be in the google chrome extensions directory, and will find a directory with a weird name, in my case it was “cdngiadmnkhgemkimkhiilgffbjijcie” feel free to comment if you know this to have any meaning, I would guess it’s a hash/unique string of some sort. Within there, you should find another directory with the version of the extension, in my case “1.2.11.12″.


$ cd cdngiadmnkhgemkimkhiilgffbjijcie
$ cd 1.2.11.12

There in there should be a file called flashblock.js, after the comments, on the first line of the anonymous function (I guess that’s actually an anonymous object prototype or something? js experts feel free to correct me) which wraps the module, you should find a line defining some exclusions:

var exclude = ['mail.google.com', 'blizzard.com', 'acid3.acidtests.org', 'megaupload.com', 'files.mail.ru', 'gs.statcounter.com', 'aniweather.com', 'google.com'];

Here you can modify the array quite easily, then unload and reload the module (you do that from the “Extensions” page accessible from the little settings wrench at the top right) and you should be good to go.

digg this

August 4, 2009

Regexps in vim!

Filed under: General, Technology — Steinn E. Sigurðarson @ 1:27 pm

This took me like 10 minutes to get right. Just because of the slight differences between vim’s regexp and perl’s.

%s/context\["\([a-z]*\)"\]/context->\1/

However I need to this often when working with php, as more and more things seem to return stdClass objects (such as php5’s built-in json functions) and I always seem to write hundreds of lines of code assuming to use the formerly more common “smart arrays” of php. Syntactically though I must admit I much prefer the stdClass stuff.

digg this

June 3, 2009

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 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

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

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

September 28, 2007

COSELLO Conference going swimmingly!

Filed under: Technology — Steinn E. Sigurðarson @ 3:12 pm

Right now I’m posting this from the COSELLO conference, which is the final conference for the COVCELL project (http://www.covcell.org). Here we had a demonstration of all the tools we developed, and we invite the TEL, Open Source, and Moodle communities to use and extend our work which is all available for free on http://www.covcell.org (under the tools section).

On moodle.org there is a special COVCELL section under the Language Teaching course, http://moodle.org/mod/forum/view.php?id=5368 (this is the URL to the project discussion forum under moodle.org!).

Since some of our modules currently require some expertise to set up (server side setup required) to play around with, we invite people to register on our Moodle “playpen” server, http://lms2.cms.hu-berlin.de/covcell where the latest stable versions of all our modules are installed. Teachers interested in trying out Moodle and our tools together may be in contact with me or Daniel Kuenstner at Humboldt University to get their own course set up on the playpen, for more realistic testing.

The demonstrations this morning went well, and I think our work has been well received, and I look forward to continuing development on some of the modules as required in the future, and I hope they reach considerable maturity in the next year or so, and start solving problems for more people!

-Steinn @ COSELLO

digg this

July 17, 2007

Is the iPhone the Wi-Fi hardener?

Filed under: Technology — Steinn E. Sigurðarson @ 9:28 am

According to this slashdot post on Slashdot, iPhones are causing problems for the Wi-Fi network. Scores of them connecting at the same time, etc.

Now Wi-Fi enabled phones aren’t going anywhere, and Wi-Fi isn’t going anywhere, so this can only mean that finally we’ll be seeing developments in Wi-Fi to toughen it up, make the hardware support more industrial.

This could be the start of the next phase in the life of Wi-Fi, first we’ll see some hardware hacks by all the manufacturers, then we’ll see an extension of the standard. I also hope the mass migration of devices such as mobile phones over to Wi-Fi will cause an overall simplification in security measures, meaning tighter, simpler security for everyone.

digg this

May 30, 2007

What is social software for me?

Filed under: General, Technology — Steinn E. Sigurðarson @ 1:56 pm

It’s any system which allows me to socialize with people. What’s socializing? I am actually not sure, I think a lot of the socializing that happens might be classified as “useless” information exchange.

I happen to think (I don’t have any direct evidence though) that the information exchange between people is usually not useless, maybe not always useful in a direct sense though, but there is real, tangible, value found in the social networks built around exchanging things such as personal information which for most specific work/education-related goals is usually not relevant.

The personal relationships however can prove amazingly, amazingly beneficial for future informal learning scenarios I think.

I have taken notes on this stuff, and I have more questions than answers, but maybe I can in the next year or so find out how to analyze this phenomenon a bit, and most importantly to see why purely social software, which shares a lot of features with learning environments (messaging, forums, wikis, user presence and awareness) — yet there is some sort of social draw found in the purely social sites, which is usually not found in the more formal educational contexts!

Where does the social draw come from? It’s not enough to see who else is there, it’s not enough to know them in real life, it’s not enough to be forced to have online meetings with them (at least the teacher mediated ones), not enough to talk with them on forums — for some reason, people come into the educational system, and their mindset seems purely formal and not social.

Perhaps it’s the short time between classes in a real setting which causes socializing? Perhaps the fact that online, you’re never waiting for anything, you are either in the system, working (or let’s face it, I think 80-90% of systems are just used as word document repositories almost.. downloading), OR you are out of the system, on your myspace, your flickr, or doing whatever, just NOT building social ties with people in your online system.

My final simple questions are;
Why do on-site students make friends, off-site students don’t?
Why do people make friends over large distances every day, but not inside educational systems usually?
Is there value for education in people socializing?

digg this

January 19, 2007

Using firebug? this might be useful..

Filed under: Technology — Steinn E. Sigurðarson @ 6:23 pm

Lately I’ve been using the wonderful little firebug debugging add-on for firefox.

However there is one slightly irritating thing, that is the fact that if anyone else wishes to use the page, while I’m working on it, they also require firebug to be installed, or the page fails due to console.log errors.

Of course, installing firebug lite would be an option, however I preferred to avoid having to instruct people to do that, so a small hack was devised;

1. create a file called for example firebug-fix.js, and in it put the following;

if (!window.console)
{
console = {log: function() {
var str = '';
for (var i = 0; i < arguments.length; i++) {
str += arguments[i] + "n";
}
alert(str);
}};
}


2. In each file depending on your console.log firebugging.. just add a reference to this file, for ex.

<script type="text/javascript" xsrc="firebug-fix.js" mce_src="firebug-fix.js" ></script>


… albeit, this fix causes the annoying alert windows to appear, but that can easily be avoided, by just stripping the contents of the log: function.. in the console definition — however I decided to have it alert the data, to make this still function as a debugging function.

digg this

Next Page »

gin 1.175 & tonic. | Powered by WordPress