Morphex's blogologue (Life, technology, music, politics, business, mental health and more)

This is the blog of Morten W. Petersen, aka. morphex in various places. I blog about my life, and what I find interesting and/or important. This is a personal blog without any editor or a lot of oversight so treat it as such. :)

My Kiva bragging page
My shared (open source) code on PyPi
My shared (open source) code on GitHub

Morphex's Blogodex


Zope hosting by Nidelven IT

No description available

No description available

Get firefox

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter

Older entries

Atom - Subscribe - Categories

Halfway there..

So, I reached a bit of a milestone. Because of mental illness I've had to take some heavy-duty medicine for some time, and at the most I took 800 mg of Seroquel per day.

Today I'm down on 400 mg per day, which is half of that, and I can say I'm quite happy about that. The medicine has short- and long-term side-effects, and on a very long term view, side-effects can also include diabetes and heart disease.

I'm glad that there has been treatment available for my issues, and I can say that today I'm feeling much better than I did 5-10-15-20 years ago.

Here's to many good years to come. 🍷 🍷

[Permalink] [By morphex] [Health (Atom feed)] [Comments] [14 Sep 08:29 Europe/Oslo]

Dealing with the Norwegian state child-care system, Rana commune and a bad mom

So, I've been struggling to get more time with my kids, and went to trial in June to get something in place.

The judge ordered that I visit the kids every 6th week, with supervision from the commune/state.

Both I and the kids mom wanted supervision, my main motivation for supervision has been, and is, actions that the kids mom has chosen to do, and still chooses to do.

So, long story short, the state department called BUF was supposed to setup supervision for the visits, but so far they have failed to do so. Before the trial I also seldomly got to visit the kids, and then a person from Rana commune was there to supervise.

The trial ended up in a verdict, and the verdict was legally in effect on the 1st of August, but the BUF state department was unable to provide supervision, and is also unable to provide supervision now the 12th of September.

Over a couple of weeks now I've tried to get Rana commune to provide a person that can supervise on the 12th of September, but they are unable to do so. They called me this morning and only wanted to give a verbal message that they could not provide someone. When I pressed on for a written message saying the same, they refused to provide that.

So today I sent the kids mom an email asking if we could be in a public place on Saturday for a couple of hours, but she refused to cooperate on that as well. So the state isn't doing what it should, the commune isn't doing what it could, and the kids mom isn't cooperating. I'd like to add that I emailed the kids mom on the 20th of August regarding getting Rana commune to provide supervision on the 12th of September.

I think that pretty much sums up the situtation, but would like to add that sharing confidential and/or untrue information has many and severe consequences.

[Permalink] [By morphex] [Family (Atom feed)] [Comments] [07 Sep 12:53 Europe/Oslo]

More on experiencing the Norwegian child-care system

So, I was in a meeting with my lawyer today, and got the explanation that after a verdict with a set number of time with my kids, the mom or rather the primary caretaker can deny anything else.

Which means that the mom of the kids can deny me visiting the kids in the kindergarten and at school, even though that has worked OK in the past.

I think I've blogged enough about this, but would like to add that one of the reasons the trial went as it did, was that the verdict put spoken testimony above an actual document as to whether or not I was cooperating regarding opening a bank account for the smallest kid. I also had to correct my own lawyer in the courtroom regarding this..

A link to a copy of that document is here:

And it clearly shows that I sent an email with a cooperative attitude after the last meditation, but never got any replies to that email and can't see that I've gotten any other emails after that email in that regard either.

[Permalink] [By morphex] [Family (Atom feed)] [Comments] [18 Aug 21:40 Europe/Oslo]

Experiencing the Norwegian child-care system

So, a couple of months ago I went to trial, partly because I haven't gotten to see a lot of my kids the last couple of years.

Although the trial was a bit of a dissapointment for different reasons, the result seemed to be OK because I got to see my kids every 6th weekend, an improvement from the current situtation and a predictable schedule.

When I visited my kids before the trial, I also visited the kids in the kindergarten and that was an OK experience.

However, it seems that as a result of the trial, the kids mom has come in the position that she can deny me visiting the kids in the kindergarten and at school. Which is strange, because visiting them earlier went OK, and neither the kids mom or her lawyer want to comment further on it.

I have a meeting with my lawyer next week about all of this, so it should be interesting to see what he says about it.

I've heard some talk about mothers having a very strong position in Norway when it comes to who gets care etc. but I'm not sure that's the case, so far things have been very difficult so we'll see what happens next.

[Permalink] [By morphex] [Family (Atom feed)] [Comments] [13 Aug 07:46 Europe/Oslo]

Developing my XML project in C

So, these last couple of months I've been dabbling with C and XML, to get to know C better. Out of all of this there might also come a nice XML parser and writer that will be freely available for anyone to use.

I wish I learned more C earlier, as a lot of things related to IT have fallen into place now that I've been forced to work on low-level stuff.

There have been quite a number of posts to comp.lang.c, and lots of useful information has been exchanged back and forth.

Anyway, the project is here:

I guess the bulk of the main code and tests are now around 25KB, which is quite a bit of code. One of the next steps is to create the main parsing loop, which will break down the XML file into its internal C representation. There will also have to be some data types created so that things work well.

One of the more interesting points that have come up is whether to use iteration or recursion when working with the internal representation.

In C, when you do a function call, things are pushed onto something called the stack. And with recursion, more and more things get pushed onto the stack, and if the recursion is deep enough, the stack is exhausted with unpredictable results.

So I think I'm opting for an iterative design in the C code, and using little if any recursion. I'm sure that's going to tick some people off, but having predictable and intelligible results when running the code is important for this project, because one can work with malicious input data.

Right now it feels like I'm past the most "painful" parts of learning C, and look forward to learning and writing more in the time to come.

[Permalink] [By morphex] [C & XML (Atom feed)] [Comments] [13 Jul 00:51 Europe/Oslo]


These last couple of months I've been learning a bit of Assembler and C programming, as these days I have the time available. I've always found Python and other high-level languages fast enough for what I needed to do, but I've always wondered a bit about C and Assembler.

What I've learned so far is that the computer is in fact a very large calculator, and pretty much everything that happens is that instructions are called (for example adding two numbers), and that numbers are moved around in memory, disk, peripherals etc. I've found it useful to learn about Assembler and C because it gives me a more detailed and correct view of how things work in computing.

With my programming and system administration background, I found it easy to dive into C and Assembler, and I also appreciate a lot more what for example Python does as a high-level programming language.

I've been looking for some gig or project to create a C and Assembler project for, and what I've landed on so far is that I want to create an XML parser. An XML parser that validates the Unicode used, as well as insures that the document is "well formed". I haven't gotten that far yet, but I've pretty much decided that the parser should (for now at least) be restricted to an UTF-32-LE encoding, and that whenever I work with pointers the rule is to initialize to null when they are created as well as after free() has been called.

I think this is good fun and I do it whenever I have the time and energy, here's the code so far:

#include <stdlib.h>
#include <stdio.h>

int main() {
  char *buffer = NULL;
  int read = 0;
  buffer = malloc(1024*sizeof(char));
  FILE *file = NULL;
  file = fopen("test.xml.2", "rb+");
  read = fread(buffer, sizeof(char), 1024, file);
  if ((char)buffer[0] == (char)0xFF && (char)buffer[1] == (char)0xFE &&
      (char)buffer[2] == (char)0x00 && (char)buffer[3] == (char)0x00) {
    // We have a UTF-32-LE Byte Order Mark                                       
    printf("BOM found\n");
  } else {
    printf("BOM not found, %x\n", buffer[0]);
  printf("%i\n", read);
  fwrite(buffer, read, 1, stdout);
  free(buffer); buffer = NULL;
  return 0;

[Permalink] [By morphex] [Technology (Atom feed)] [Comments] [09 May 11:44 Europe/Oslo]

A small victory

So, it's been a while since I blogged about my mental health, and I thought I'd do that today. Some years ago I had a major crash (psychosis), and after some months I was put on Seroquel, and over a period upped the dose to a top of 800 mg.

Together with the psychologists and psychiatrists and lately my doctor I've been reducing the amount of medicine, and today I'm on 450 mg a day and it feels OK.

I've seen some advocating for medicine-free treatment, but from my experience, the medicine has helped. That and going to therapy has helped me a lot, and today I feel better, smarter and stronger than what I did before the crash.

Now the medication isn't perfect, it has side effects as most medicines do, but I can say today that I'm glad medications were an option.

Psychosis can happen to anyone. There's a lot of stress and pressure in society, there is a lot of (heavy) things to think about, life is a mystery, and my impression is that mental health issues is rather something that counts towards the patients' intelligence than against it.

Some can become psychotic from physical trauma, some can develop it over time for various reasons, some can be slipped a pill - many different things can happen that causes psychosis and severe mental illness has been documented for a long time in history.

So it's good that there is a way to deal with these issues, the treatment isn't perfect but it is a lot better than the alternative, maybe going through a kind of hell for an entire life.

[Permalink] [By morphex] [Health (Atom feed)] [Comments] [29 Apr 17:18 Europe/Oslo]

An alternative to SoundCloud, MixCloud and similar services

I'm a software developer, that has pretty much loved music my entire life, and I've at times listened to music almost all my waking hours.

I'm now in the middle of my thirties, and these last couple of years I've also been playing the guitar, singing and doing some piano and drumming as well.

Now, to me it seems natural that one learns to play instruments, by playing songs one has grown up with and know, it's a natural place to start. So for some time I created simple cover versions of songs, and uploaded them to SoundCloud.

Around this last Christmas (...) I got a notice from SoundCloud that my account had "two strikes" with a dire warning of my account being "terminated", where they had taken down my track "Summer (original by Calvin Harris) Simple Mic". Now it is funny that I get a notice like that on the 1st day of Christmas (25th of December). Another funny thing is that I asked to get a copy of my track, but they denied that request and said that

"This was reported to us by an anti-piracy agency on behalf of Sony. We won't be able to reinstate this, not even privately, unless you have permission from Sony to have it on SoundCloud."

Now, luckily I had a copy of the track on my computer, but it would have been a bit more sticky situtation if I didn't. Now this track is 01:19 long, that is just under 80 seconds and recorded on a simple microphone, but they still saw it necessary to take it down. If it was because I made a remark somewhere that you could just put that snippet on repeat and there you had pretty much the entire song I don't know.

Anyway, because of this, I got somewhat stressed and decided to move my cover songs to MixCloud, because there you can tag the artist and the song in uploaded tracks, and the artists (and MixCloud) get some revenue, and that seemed like the best thing I could do.

However, I recently reviewed the terms on the MixCloud site, and it basically says that they can do whatever they want with what I upload, forever. This wasn't what I expected; what I expected was that I could put things up there as a temporary solution, and take things down if necessary, or take things down if something I create has potential to make money. Now, I guess I could leave everything I have up there as the recordings aren't high quality, but it would be nice to have a reasonable amount of control of what I've created.

So my expectations of MixCloud and what is in their terms of service didn't match up, and I sent an email to MixCloud asking about this, but the reply I got was

"For licensing reasons we don't host individual tracks (even if it's your own track), so unfortunately we've had to disable your single track upload."

Which wasn't close to what I emailed them about

Expected Behaviour
My impression of the site was that one could upload things, and take them down and that was pretty much it, you and the original content owners got a cut through radio-style fees.

Actual Behaviour
However, I've read the terms you have, and found that for example having others create derivates, that I'm liable for being in the middle, that you can use my content perpetually etc. is not something I expected.

So now I'm in a situation where I have created content which I'm unsure about who has the rights to do what with, and I also can't continue doing podcasts and cover songs because I don't have a place to share these things.

Does anyone know of alternatives to these services that work like I want them to? Comments or emails to are much appreciated.

[Permalink] [By morphex] [Music (Atom feed)] [Comments] [12 Apr 10:08 Europe/Oslo]

An updated version of the Issue Dealer, building Zope 2.13.22

It's been a while since I did anything on Zope 2, and these last couple of months some bugs on the weblog publisher on have been bugging me.

So I decided I should get that fixed, and also get the IssueDealer updated to work with the latest stable version of Zope 2.

It has been some days of fixing things back and forth to get things working, but now I have an updated version of the IssueDealer, as well as a procedure for building the latest and greatest Zope 2.

I've been quite out of touch with what has been going on in the Zope, Plone and Python world lately, and it took me quite some effort to get things working, from getting Zope from GitHub, getting the right dependencies in etc. One thing I've noticed is that is using a common name of - which forced me to make a shell script to aid in the process of setting up Zope. This is sloppy at best, as it forces users to skip SSL verification.

But, enough of that, here's the hands on procedure for getting Zope 2 installed on a Debian Linux box. Beforehand, I think it's necessary to install the build-essential package as well as git, in other words:

sudo apt-get install build-essential git

I'm not sure what the procedure is for Fedora/Red Hat, SuSe etc. is but it should be easy enough to figure out.

OK. We'll install Python and Zope in a directory called


First thing we do is get Python 2.7.9 installed, which is done with

chmod o-rwx # So other users can't read the database etc.
mkdir tmp
cd tmp
tar xfz Python-2.7.9.tgz
cd Python-2.7.9/
./configure --prefix=/home/morphex/
make install
cd /home/morphex/
git clone zope
cd zope
git checkout 2.13.22
wget --no-check-certificate
chmod +x
./ ~/

Now, edit the buildout.cfg file, so that the [zopepy] and [wsgi] sections contains the line


like so, maybe using the command "nano buildout.cfg":

recipe = zc.recipe.egg
eggs = Zope2
interpreter = zopepy
scripts = zopepy
recipe = zc.recipe.egg
eggs =

Now, when that's done, we're ready to run buildout. Run the command


Now, this script may fail, if there are network issues for example that make downloading of packages break. If that's the case, just re-run the command until it completes with lines something like this:

Generated script '/home/morphex/'.
Generated script '/home/morphex/'.
Generated script '/home/morphex/'.
Generated script '/home/morphex/'.
Generated script '/home/morphex/'.
Generated script '/home/morphex/'.

After a lengthy process with lots of output, we can create the Zope instance, like so:

./bin/mkzopeinstance -d ~/

I'll leave it up to you to choose a username and password.

Now the instance has been setup, and we can run it for the first time. Type in the command

./instance/bin/zopectl fg

And you should see something like this:

/home/morphex/ -X debug-mode=on
2015-02-13 04:31:04 INFO ZServer HTTP server started at Fri Feb 13 04:31:04 2015
        Port: 8080
2015-02-13 04:31:05 INFO Zope Ready to handle requests

Now I login to my server on the URL - and select "Issue Dealer" from the drop-down list, click on add and give it the ID issues, and the title "My issues". Now that Issue Dealer instance is available on

Voila. If you're setting up a plain Zope 2 or Zope 2 with some product, just remove the Products.IssueDealer parts from the buildout.cfg and it should work.

Hope you found this useful, and comments etc. are much appreciated. My email is morphex AT gmail.

[Permalink] [By morphex] [Zope (Atom feed)] [Comments] [13 Feb 04:05 Europe/Oslo]

A man walks into a bar..

So this week I've been visiting the kids, and the visit went relatively well, it was nice to see the kids again.

I don't have a relationship with the kids mom or her family anymore, and took the train from Mo i Rana to Trondheim yesterday evening.

Some of her relatives were on the train as well, but they didn't stop to say hi and it was fine by me.

Had a good time towards the end of the train journey, ate well and had some wine and beer. Headed towards a regular place when I got to Trondheim to have some beers and maybe meet some friendlies there.

After a while I was ordering a second beer when this chick I might have met before started suggesting what I should have. So OK, I went with her suggestion.

After drinking some of that beer I figured I could go talk to her, since she struck up a conversation with me.

But I think she was (the only girl) sitting at a table with maybe 5 other guys, and as I started talking to her, a guy at the table asked me to stop talking to her, I kept talking a bit with her and she said she studied law, then she said she studies psychology.. I glanced around the table and persisted a bit, but the guy still kept asking me to stop talking to her.

Well, I got a bad feeling right then and there and instinctively agreed with the guy asking me to stop talking to her. Next time I'll look at the company someone's with before I start talking to someone who started talking to me first..

[Permalink] [By morphex] [Living (Atom feed)] [Comments] [06 Feb 21:14 Europe/Oslo]