Curriculum Vitae

I have made a CV so yee guys can get a better view of who I am...
bzr branch lp:~gustav-hartvigsson/+junk/CV
English version here (Updated 2014 04 20)
or Swedish version here (Updated 2014 04 20)


The Paper Crane and the Drunk Pirate

"When life gives you lemons, don’t make lemonade. Make life take the lemons back!"
-- Cave Johnson (Late CEO of Aperture Science)

"Would you hire yourself"?

Has anyone been asked this question? What is the correct answer to it?

This is a question I have pondered many a days, and I have come to the answer "no, I would not hire myself".

I'm rude, I hate most things, I hate you in particular (for no reason), I am not very productive at best of times (I rather not do something than do it), I am not very smart (even if I fake being smart pretty well), and I have dought my own abilities.

Past things

When I was younger I tried my hands on drawing (a short lived dream about doing comics), but that only fucking my right hand up (writers hand).

My father always told me to become a politician, but if it weren't for my absolute disdain for almost all political parties's policies/programs, I almost considered it.

I was told to get a degree (decided on Computer Science), but that only led to a big student loan and no degree.

I was told to work in a restaurant, seemed fun, was in reality the worst fucking job ever.

I tried to do graft (working at a company that does fibre installations), got the boot.

Took a course in Java EE/Web Programming, I hated every minute of it. I just don't understand how anyone would like such a job.

I tried my hand at writing (done so for some time, and still do) but I know it is all a pile of shit; every character speaks with the same voice, the dramatic curve has gone out the window, the tempo is all wrong, the disposition is all wrong.

I feel done.

"FML" is probably the best description of my life.


Papperstranan och det Atlantiska Havet

"Mamma, kolla ett spöke."
-- Femåringen som såg en kvinna i heltäckande slöja.

Fan vad osammanhängande jag kan skriva... Hänger inte ens med själv. ^_^

Europa Överger Sina Ideal

Sverige har endast ansvar för att hjälpa svenska medborgare och de med uppehållstillstånd.

Är de inte medborgare i något EU land så har de inte något att göra här.

Visst vi har en extraordinär situation I Europa och Mellanöstern men det är inte vår skyldighet att hjälpa, men det är nog det mest humana att göra.

Men begår de något brott skall de kastas ut ur EU och bli målade med genetiska markörer så att de inte kan återvånda.

Vi har exempel på våldtäkter på barn på asylboendes som inte rapporteras till polisen utan mörkas av personalen[1]. Sådana här saker måste uppmärksammas.

Och om vi tar en avstickare från Flykting frågan så måste vi nog ta tag i problemen som det multikulturella samhället har skapat. Där vi tillåter de som kommer hit att välja att inte assimileras, där vi ser mellan fingrarna när det gäller den icke acceptabla människosynen som vissa individer har.

Antingen står vi upp för den västliga civilisationen eller så låter vi oss bli överkörda av de som inte delar våra värderingar när det gäller synen på människa liv eller vad som utgör ett samhälle.

Att luta sig tillbaka och tycka bra om oss själva bara för att vi hjälper de som kommer hit och inte hjälpa dem med att komma ur sin egna kulturella bubbla hjälper ingen. Och skapar bara problem framöver.

Vill vi ha ett segregerat samhälle eller ett samhälle som är byggt på rättssäkerhet? Vill vi att den generationen som efterträder oss inte vågar ta tag i problem för att inte de skall råka såra någons känslor. Nej, det tror jag inte. Vi måste stå upp för våra demokratiska ideal till vilket pris som helst. Vi skall inte tro att vi kan vara tillmötesgående till alla, vi måste stå upp för de sekulära idealen som det västerländska civilisationen bygger på! Vi skall inte bry oss om hudfärg, kön, religion, bara om individens välstånd i samhället, trotts vad den regressiva vänstern tycker.

Så... Var var jag? Err... Vad fan? Detta får duga.


[1] http://sverigesradio.se/sida/artikel.aspx?programid=106&artikel=6283519


The Papercrane and the void pointer to nothing


Giving up SSTS (for now? for ever?)

So I have been working on this project that I called "SSTS" or Super Simple Type System. It is neither a "Type System" or "Simple".

I have been working on this on and off for two-three years. I started it on a whim, I wanted to learn what makes GLib and GObject tick, so I set out with the simple goal of implementing something like GObject but without all the nasty type-tracking and what not. It started out well, with a base object type that I could use to implement other stuff and call methods using the base object's interface.

"This is easy!" I thought to my self, it was easy, cus' it was nothing special. Then I wanted to add something like the GObject's notify system. But for that I needed some sort of map structure... But to implement a Map structure I needed a Dynamic Array and a Linked List...

It is now almost two years since I started faffing about with this, and get lots of help from the guys over at the C Programmers community on G+, and now I had hit a road block. I got double frees... And I just could not figure out what was wrong.

I posted a query to the community page, but got told I needed more tests. At this point I just give up. I am sick of this. Not of the people trying to help, but at my self, I have spent two years on some code that no one will ever care about. And I just do not care enough to write test cases, the code is not written in a "test friendly" way.

Sure, I have learned a lot by the experience but I just see no end in sight for the project. If I were to implement the object notify system I would start with the next thing (Streams), which would require something else(an Event Loop).

At this point I see nothing but an other two years till I would be finished, and I just do not want to care about it any more.

Design and good intentions

I like how I have focused on making the function calls not feel to "C"-y. I wrote wrappers for string functions to return strings, so if feels like something like Java or something. And this philosophy is everywhere. "Make it not feel too much like C."

I did not want any of the internals leaking out like some kind of horror show. I did not want the user to have to deal with checking if a function returns a positive or negative value. That is scuff that the user can be without.

This good intentions makes for code that is harder to test than "normal" C code where you get some error value from a function when it fails. It can not just check "is this negative" over and over again and see it go through. No to test these things I have to go through and write complex tests for edge cases that I never thought of when writing it.

I just no not want to deal with that.

I give up... I have had enough of my ineptitude.


The Paper Crane and the Endless Struggles of a Man in a System of Endless Struggle.

"So what you are saying is that the sky will not fall?"

ForEach in C

In C we do not have iterators in any sane fashion (C++'s iterators are not sane either, btw 😜 ) nor do we have a standard array_for_each (how would that even work?). So when implementing a C data structure that may need for_each capabilities it is best to do it. Relying on for loops can be problematic if you are not careful.

In these example I will use a DynamicArray as the data structure. With functions to get items at an index and the length of the array. When it comes to LinkedLists you must use linked_list_next, linked_list_prev and linked_list_get_current, but that is outside this discussion.

First things firts: typedef:ing a standard ForEach function pointer

The signature for a good for each function in any implementation is as follows:

typedef void (ForEachFunc *)(void * self, void * item, void * user_data);

The self here should be a pointer to the data structure you are doing the for each on. No operations should de done on this structure.

The item is the current item, the item that the for each function should operate.

The user_data is any user data you can think of. It may be used as a out value or as some other data that is used inside the for each function.

Implementing dynamic_array_for_each

In this example I will not rely on any internals of the data structure, instead I will use dynamic_array_get() and dynamic_array_len() this means that you can implement this even if you do not have accesses to the underlying structure.

To begin with you must understand that this relies on a for loop, so it is not more efficient that just writing a for loop your self. It just provides a little bit safer way of coding, where you do not have to keep track of variables to much.

The signature of the function is as follows:

dynamic_array_for_each (DynamicArray * self, ForEachFunc func, void * user_data) {}

The self here is the dynamic array to perform the for-each function on.

The func here is the function that we are to execute on each iteration.

The user_data is the data to passed to the function. This may be used as an "output" of sorts.

dynamic_array_for_each (DynamicArray * self, ForEachFunc func, void * user_data) {
  // First me get the length of the array, This should be the last item in the array.
  size_t len = dynamic_array_len (self);
  for (size_t i = 0; i <= len; i++) {
    // Check if the item is there.
    void * item = dynamic_array_get (self, i);
    if (item) {
      func (self, item, user_data);

And that is it, folks!

Using it

So now it is now time to use the this for-each thingy. So lets define a function to use in the for-each.

for_each_print (SDynamicArray * self, int item, int * itt) {
  fprintf (stdout, "The number is: %d on iteration: %d\n", item, (*itt));

This function prints the number stored in the array and prints it out. as user data it takes a pointer to an int, this is that is incremented each time the function is called.

Lets now put this into a context:

main (int argc, char ** argv, char ** argp) {
  /* create the array */
  DynamicArray * arr = dynamic_array ();
  /* ... Code to fill the array with numbers. */
  int itt = 0;
  dynamic_array_for_each (arr, (ForEachFunc)for_each_print, &itt);
  fprintf (stdout, "The last itt number is: %d", itt);
  /* ... Code to free the array and what not ... */

As you can see it is not too much work to implement or use.

Conclusion, or something.

So as we have seen it is not magic, it is actually easy to use, and it promotes code-re-use. One downside of this is that it does a lot of calls, and thus uses the call stack, this might be problematic if you you already are hitting the maximum call stack size.

But I firmly believe that this is the best way of doing things like this.


The paper crane and the pile of video tape

"I am sorry, future self."
-- A comment in some code

Help Pitivi!

Click here to get to the fundraiser.


The Paper Crane and the Fragile Crystals

"What is love? baby don't hurt me, don't hurt me, no more"
-- Haddaway

On love and the low birthrates

Reference to this post: https://plus.google.com/u/0/100647702320088380533/posts/4f1DuFuVfoz

After reading that I the article above I started to think about what the people in the article above actually thought about long term relationships. This is my POW on love and sex.

If you ask me, I would rather have a long-term relationship than a one-sight-stand with some stranger. I do like to feel that I am loved rather than something shallow, untrue (as a one-night-stand is).

I do not want children though (for reasons that I am not going to discuss here).

Back to the article!

They say that long-term relationships are "Too troublesome" , but I think that this is just an excuse. They rely do want a relationship, it is just that they are afraid of loosing what they have.

It might be by Gaijin-white mindset but the statement that Kishino made seems weird: "I don't earn a huge salary to go on dates and I don't want the responsibility of a woman hoping it might lead to marriage."

I do not think that I have ever heard of anyone here engaging in a relationship because they think they will marry there partner. That is not to say that they will not get married, though.

And this might be due to my cheap-asrsery but if you are in a relationship with someone who loves you, why does the male have to present dough as a token of offering to the female?

Cheeses! I thought that you loved each other! NO! It seems that you are her sugar-daddy now!

Of course I would present gifts to my girl, but I hope that she would not expect me to do so. After all, is she after love or my coin? I want to live in a equal relationship, where we see each other as equals who loves each other, not as a master/slave or provider/user relationship.

It might just be that I have a strange world-view, and that the ideal girl does not exist. Perhaps girl only like dough, and that one-night-stands is what girl rely looking for... What do I know? I am single, have not had a relationship with a girl for many years.