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 email is morphex@gmail.com.

An OGG/Vorbis player, implemented in Javascript.

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

Morphex's Blogodex

News
Slashdot

Zope hosting by Nidelven IT

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter



Older entries



Atom - Subscribe - Categories

Facebook icon Share on Facebook Google+ icon Share on Google+ Twitter icon Share on Twitter LinkedIn icon Share on LinkedIn

Changes to my Python surveillance (webcam, web camera) app

So, I created a surveillance app a week ago, because I felt it would be comforting to be able to see if somebody had been into my room.

Since then, I had to make the mailer code, the codes that mails a compiled video to the given email address, a bit more robust:

https://github.com/morphex/surveil/commit/a02dbc05d78b71aea2...

As I one day discovered that the last mail sent to me with a video, was sent at 03:34, and looking at the log for surveil, I could see that DNS had stopped working.

Today I added another mailer feature, which is simply moving the mailer code into its own function, and then running that code as a loop forever, in a separate thread:

https://github.com/morphex/surveil/commit/146f1fe88511f94358...

Other notable changes are a separate configuration file, as well as parsing the output from fswebcam when a picture is taken, and if an error is detected, re-get the image:

https://github.com/morphex/surveil/commit/8c8b84fc46fd0863e7...

Finally, I added a script that can be started from Cron, so that the surveil app starts running as soon as the laptop/desktop/demoboard - whatever, boots up.

https://github.com/morphex/surveil/commit/6291603045579228fc...

I added the script, because it's easy to forget to include the PATH etc. - which leads to confusion, irritation and so on, when automating things.

Of all the things I did summarized here, I think the mailer hack is the best; I simply moved some code around and fired up another thread, so that images are taken and videos created and mailed, without delays which could create gaps in time where the room was not surveilled.


[Permalink] [By morphex] [A surveillance app (Python tree here I come!) (Atom feed)] [24 Sep 15:01 Europe/Oslo]

An open letter to Tiller DPS (Tiller psychiatric)

Subject: An open letter to Tiller DPS (Tiller psychiatric)
To: Tiller DPS
Cc: County Governor's office, Various
Bcc: Various

Hi.

I'm wondering if you can say something about how memories can be manipulated.

Reading a bit of psychology these days, where they among other things, talk about the importance of first and last impressions.

In my own experience, I can remember something that I then and there thought was OK, in a much more negative way, much later in time.

Daniel Molyneux (last psychiatrist) wanted me to start taking anti-depressants and come in on appointments, but since I over a long time [before that] took up problems with the kids mom, and you didn't do anything, I gather that you have seen this family conflict [and me not seeing the kids, or the kids not seeing me] as an opportunity to treat me, and maybe even you had something to do with certain things happening.

So maybe instead of talking with me in [therapy sessions], you could help me sort out today's situation, to get a clear view of who did [and is responsible for] what.

Regards,

Morten W. Petersen

[Permalink] [By morphex] [Health (Atom feed)] [24 Sep 09:32 Europe/Oslo]

An open letter to the Norwegian directorate of health / Norwegian department of health

Subject: Some questions, mental health, children
To: Directorate of health, Department of health
Copy: County police, Lawyer
BCC: Various

Hi.

I'm wondering who it is, that checks that a patient who is psychotic, is making good deals (arrangements).

It is the case that I became psychotic in 2009, and after 5 years of obstruction, it is still difficult to see my kids, after I broke up with the kids mom in 2013.

The kids mom pulls out (medically) confidential information, things I have said while psychotic, as if that should be relevant today, when I'm in much better shape now, than 8 years ago.

She does this, because I signed papers that enabled the child protection services could retrieve information from the healthcare system in 2009/2010, and the child services have forwarded parts of this to the kids mom [by snail mail], both information that is wrong, and information that has been taken out of its context.

The second thing I'm wondering about, is related to research. I said yes to joining a project when I was (actively?) psychotic, and who is it that checks that this is a good idea, on my behalf?

I can't remember talking to a lawyer regarding child protection services, or this research project.

Finally, I'm wondering, on a scale from 1 to 10, how interesting is a person as a research object, if this person has been psychotic (and given medicine that removes the symptoms [of psychosis]), and breaks his or her neck and becomes paralyzed from the neck down? The brain is an overgrown nerve, after all...

Regards,

Morten W. Petersen


[Permalink] [By morphex] [Health (Atom feed)] [18 Sep 18:53 Europe/Oslo]

When a woman shows you attention...

..you should ask yourself.

Is she:

a) bored
b) helping somebody achieve something
c) feeling an itch
d) looking for a sperm bank
e) looking for a source of revenue
f) any combination of the above

Hate to sound like a party pooper, but reality is what it is.


[Permalink] [By morphex] [Living (Atom feed)] [17 Sep 14:55 Europe/Oslo]

A surveillance app (Python tree here I come!)

So, lately I've been taking it very easy on the activities front, since I've had a court-related matter to get to see the kids.

So I've had some ideas, urges etc. to do technical stuff, artsy stuff etc. - and today I wrote myself a script that will run on a PC, or a demo board like Raspberry Pi, Orange Pi etc. - and take pictures on a webcam, and merge these pictures taken over time into a video, and mail them.

I started with Python (2), but figured that now is the time to take the plunge to Python 3 and don't look back.

I have to say, Python 3 isn't difficult, there are some changes in conventions etc. but nothing big.

So I was able to be productive in Python 3 straight away, and wrote this script:

https://github.com/morphex/surveil

Which will do what I mentioned above. And here's the source code tree as it was when I wrote this post:

https://github.com/morphex/surveil/tree/1cb5ceed7657e2635cca...

This video was generated from this script:

https://blogologue.com/surveil_out.webm

And impressively enough, each image the video was generated from, was 55-78 KB, while the entire video with 18 images was ~120 KB. I guess VP9 is effective at compressing, at the same time, a lot of the objects in the video are static.


[Permalink] [By morphex] [Python (Atom feed)] [17 Sep 00:08 Europe/Oslo]

A small victory regarding my kids

So, this week there was a settlement in court, which will enable me to see the kids again, on a regular basis, with the added security of someone from an official department supervising the meets.

However, in the court papers the judge writes that I'm still (mentally) ill, and I think a lot of people that have seen me the last years, will say that I have gotten physically and mentally more fit.

So I'm not sure what to make of that. There are things I'm not taking a stand on in all these court papers / don't agree with, just to get to see the kids.

Anyway, I've been to court once before, and there the court-appointed mental health professionals, INSTITUTT FOR KLINISK FOREBYGGENDE TILTAK - IKFT AS - headed by Sylva Krogh, laid out in broad strokes that the kids mom was great and that I was not. They also had some people evaluating an interaction between me and the oldest son, but they didn't keep that recording.

So, I pressed charges against IKFT AS represented by Sylva Krogh for false testimony, and haven't heard anything from the police regarding this.

This time around there was also one court-appointed mental health professional, Roger Lindqvist, which I talked a bit to, explaining the situation. I have seen notes of the talks he had with me, the kids mom and the kids, but not a conclusion/evaluation/report of what he thinks about it.

Today I fired off an email to Rana Tingrett, with the administrative body for the Norwegian courts on copy, asking if the court-appointed professional for this round in court, was 100% in agreement with what the mental health professionals in the previous round, found in their report.

It will be interesting to see what the response to this is.

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

It's now been 5 weeks without a response from the health system (Tiller DPS, NAV)

I requested my journal 5 weeks ago, more about that here:

https://blogologue.com/frames?url=https://blogologue.com/blog_...

And I still haven't gotten a copy of my journal. I sent them an email yesterday, Thursday, and they did not respond to that either as of today, 16:03 Friday.

I don't get what should be so difficult about sending a prior patient his medical journal, there is also an important court meeting on the 10th of September regarding my kids, and I'd say that this long processing time, along with NAV (the government welfare system) breathing down my neck and bringing up old documents that I also question, has impacted my ability to complete this court process in a negative way.


[Permalink] [By morphex] [Health (Atom feed)] [31 Aug 16:06 Europe/Oslo]

Ethics in medical research

So, I heard on the radio today that the ability to treat schizophrenia was much better than previously thought.

I think that's nice, the ability to treat serious, debilitating illnesses.

At the same time, I recently started to read books about psychology, to educate and better understand myself. The book I wanted wasn't available in the library, so I started with another one, which started off with psychology and research, which was a bit too advanced, heavy.

Anyway, I set myself a goal of getting through the first section of that book, and now I have a what seems like lower-level book which I can read comfortably.

Anyway, this first book was about research within psychology, and one of the things I read was that it was often students in psychology that were eager research subjects. Another couple of things were double-blind studies (the research subject is unaware of research test) and a note about getting too eager in the service of research and being sent to jail.

It is nice and necessary that advances in sciences are made, but I recently heard of a person 30 years young that took her own life, and she was in some sort of treatment or had some institution available. And the examples of over-medication, suicide etc. in psychiatry are many.

If you have a serious mental illness, that hampers your ability to see what's right and wrong, who is it that makes sure a person's rights are protected? If you are well functioning enough to get to an advanced degree in psychology, where is your empathy and understanding of serious mental illness?

It's also nice that there are researchers and medical personnel, but where do all these problems (researcher's opportunities) come from?


[Permalink] [By morphex] [Health (Atom feed)] [25 Aug 11:26 Europe/Oslo]

Questioning the Norwegian mental health care system, and justice system

So, next month I'm going to court again, to get to see the kids. In these last 5 years, I've seen the kids less than 2 hours each month, and I've been to every date with the kids, every appointment with the family counselling office etc.

In addition to that, I've accrued 100.000 NOK in debt (> 10.000 EUR/USD), after going to court in 2015, also to get to see the kids, and I'm paying 1000 NOK a month in interest on that now.

All this happened while I was taking medication that affects the brain (up to 800 mg of Seroquel a day), and going to therapy sessions, and I've repeatedly discussed problems with the kids mom with mental health professionals, and it has also been documented in writing that I took up these problems with mental health professionals.

I'd say that my experience with the court system so far, has been poor, and I question a lot of things about it. When it also takes more than 3 weeks to produce a copy of a medical journal, and who has accessed it or received copies of it or summaries of it, I really begin to wonder.

When I question the justice system and a process I've been through, and I've been in medical treatment - it is a bit of a concern that it takes a lot of time to produce a journal and a journal log, I'd think that it basically pressing some buttons in a computer program.

A link to the email dialogue with Tiller DPS is here (in Norwegian): https://blogologue.com/tiller_dps.pdf


[Permalink] [By morphex] [Health (Atom feed)] [18 Aug 12:06 Europe/Oslo]

Here's to you, sis

So, I'm going to court again, to get to see my kids, with supervision, as the kids mom has only let me meet the kids twice since November 2017.

Since the summer 2013, I have seen the kids less than 2 hours each month on average, which is too little, given that I have been to family counseling, court, every meet with the kids etc.

Anyway, my sister repeatedly meddled my problems with the kids mom after the break-up, even when I told her not to, and after that I cut her off, removed her as a friend on Facebook etc.

Breaking up with a person is difficult enough in itself, then you have the added emotional burden of not seeing the kids, as well as other things that I'm not going to repeat here. So the sum of many things, and that my sister didn't respect me, led me to the decision of cutting her off.

4 weeks ago, I asked my sister on email if she would answer some question in writing, related to the new court visit. Now, it is punishable by law to lie in these answers, I knew this, and I guess she knows this now as well.

So she has been writing back some, in my opinion, bullshit, and she did not reply to my latest email sent on the 14th of July (over 3 weeks ago), here translated to English:

"""
I think that you can either answer some questions in writing [to the court], or you cannot.

I will have an understanding of the situation after you've answered. It could be that you entirely of your own initiative meddled to help me, or you could have been influenced to more or less pressure me.

It could be that you thought things would become difficult for you, your man and your kids, if I rejected [the kids mom].

So it is either "Yes, I can answer some questions in writing", or "No, I cannot answer some questions in writing.
"""

To me it is pretty clear that my sister has contributed to my problems earlier in life, and I'm glad that she is now out of my life, even though she does have some influence in my life, via my mom. Her "soft voice" gave me the chills last time.

Here's a PDF of that email, in Norwegian: https://blogologue.com/lmp_email.pdf

[Permalink] [By morphex] [Family (Atom feed)] [05 Aug 17:06 Europe/Oslo]

A bit of video fun, ffmpeg fractional timestamp and slow-down

So, I've been recording some workouts, and posting them on Instagram; lately I've also experimented with video-altering apps on Android.

But, Linux has its own Swiss-army knife for altering videos, called ffmpeg.

I've also been recording myself massaging a punching bag, and was pleased when I saw myself tapping and then stomping the bag, in rapid succession, with great power.

So, I thought I'd see how fast I was actually going, and after some digging around, I found that I could add a fractional timestamp to a video, and slow it down, using these commands:

ffmpeg -i VID_20180803_153745~2.mp4 -vf "drawtext=text='Time\ \ \ \ \ \ ':x=120:y=h-lh-30:fontsize=20:fontcolor=white:shadowcolor=black:shadowx=1:shadowy=1:timecode='00\:00\:00\:00':timecode_rate=25/2" out.mp4

which adds the timestamp, and

ffmpeg -i out.mp4 -filter:v "setpts=8.0*PTS" out2.mp4

which slows down the video 8-fold. Here's the video:

https://www.instagram.com/p/BmEPPJWgQ6b

And here's another, edited using an Android app, to go forwards and backwards, creating something that can be watched over and over again, smoothly:

https://www.instagram.com/p/BmCD4DAFXfZ/

[Added a day later:] I guess I should mention that the commando used to find the timecode_rate was:

ffprobe -v 0 -of csv=p=0 -select_streams 0 -show_entries stream=r_frame_rate VID_20180803_153745~2.mp4

and the output was: 25/2

[Permalink] [By morphex] [ffmpeg (Atom feed)] [04 Aug 20:19 Europe/Oslo]

Graceful degredation of redirect using meta http-equiv and Javascript in XHTML, for caching

So, I saw that SSL was becoming more or less mandatory these days, so I got SSL setup for the domain blogologue.com.

However, since I also wanted to keep serving the site over HTTP as well as HTTPS (for graceful degradation and a fallback), and I have a cache sitting between the SSL-server and the weblog system, which pretty much caches everything, all the time, for a long time, I had to do a bit of extra work.

The cache in this setup isn't able to tell the difference between requests coming via HTTP or HTTPS, so an extra '&protocol=http[s]' is added at the end of URLs.

So with this code

  <meta http-equiv="refresh" id="meta_refresh" content="1;
        https://blogologue.com/?protocol=http" />
  <script type="text/javascript">
    refresh = document.getElementById('meta_refresh');
    refresh.parentNode.removeChild(refresh);
  </script>

it is possible to have the page redirect with the protocol key without Javascript, while this piece of Javascript

    <script type="text/javascript">
    // <![CDATA[
    function myOnLoad() {
      if (window.parent.document.location.toString().indexOf('http://blogologue.com/frames') != 0) {
        if (window.parent.document.location.toString().indexOf('https:') != 0) {
          window.parent.document.location='http://blogologue.com/frames?url=http://blogologue.com/&protocol=http';
        }
      }
      if (window.parent.document.location.toString().indexOf('https://blogologue.com/frames') != 0) {
        if (window.parent.document.location.toString().indexOf('http:') != 0) {
          window.parent.document.location='https://blogologue.com/frames?url=https://blogologue.com/&protocol=https';
        }
      }
    }
    document.getElementById('iFrameLoadTest').myOnLoad = myOnLoad;
    document.getElementById('iFrameLoadTest').myOnLoad();
    // ]]>
    </script>

does redirect to setup frames *and* add the protocol key. I setup this site so that it would be possible to access the site without a browser that supports [i]frames, and I guess it is reasonable to expect that a browser that doesn't support Javascript, also doesn't support frames.

Although for example the NoScript extension for Firefox does enable blocking Javascript per-site etc. for security.

So the cache is able to cache http and https pages differently, which again is tidy and neat, as URLs generated on the blog are often absolute starting with http: or https: - and not relative, for example /morphex.

If you're wondering how the meta tag is generated, that's by a script on the server side, which decides to redirect with an &protocol= suffix on URLs, based on an environment variable HTTP_X_FORWARDED_PROTO, which the cache sitting in the middle, is unable to take into account.

It did add "Vary: HTTP_X_FORWARDED_PROTO" to the pages generated in the weblog, but that did not affect the cache.

Now, I was wondering how long a timeout the http-equiv refresh should have, and found 0 was too short, and 2 was too long. If the timeout is 0, it is reasonable to expect that the browser will execute the refresh immediately. It is also reasonable to expect that within 1 second, the following <script> tag is read and executed, and when that Javascript is run, it deletes the meta tag, and from what I can tell, deleting the meta tag, also stops any actions contained within that tag.

You might think that adding <meta> tag within a <noscript> tag in the header would be much easier, and it would be, however, that is not valid XHTML according to the W3C validator, so this "hack" is what will work and be accepted as valid XHTML.



[Permalink] [By morphex] [Web (Atom feed)] [23 Jun 15:18 Europe/Oslo]

I will be attending the Norwegian constitution day 17. Mai (17 of May), but not celebrating it

So, tomorrow is Norway's constitution day, celebrating the signing of the Norwegian constitution in 1814.

I will be attending some social events tomorrow, to enjoy some company and different good food. But I won't be celebrating or congratulating others on the occasion, because of my experiences in the Norwegian society.

I have two kids, 6 and 8 years old, and I haven't met them in person since the start of November 2017, and it is now the middle of May, 2018.

I broke up with the kids mom in 2013, and since then I haven't seen the kids much. Even though I've been to every meeting, every planned time with the kids etc. since then.

I was thinking of taking a picture of the children marching tomorrow celebrating the day, but after some thought I created this collage of the Trondheim hospital St. Olav and the Norwegian flag (taken from https://upload.wikimedia.org/wikipedia/commons/d/d9/Flag_of_...) so I have the "day off" tomorrow, and also don't take a picture of different people who haven't asked to be associated with this blog post.

Picture of St. Olav with Norwegian flag superimposed

So yeah, I found taking a picture of the hospital fitting for different reasons, one of them being that I broke up with the kids mom while I was diagnosed with one or two serious psychiatric disorders, and today about 10% of my net income goes to paying off previous court costs and current lawyer costs, to get to see the kids.

To be correct, I have to say that the kids mom has offered a deal for me seeing the kids now, but I have negative trust towards the kids mom after what has happened earlier, so I think her presence during my meetings with the kids would be negative in more than one way. And as they say, "fool me once - shame on you, fool me twice - shame on me". I have suggested meeting in public spaces in Mo i Rana, but that was not acceptable for the kids mom.

So it looks like it will be another round in court, so that I can get supervision from the state when seeing my kids, which will limit the amount of time I get with the kids, but since the kids mom refuses to let me be alone with the kids, and I don't trust the kids mom, it's the best solution I see.

The kids mom has also earlier said that the situation was stressful with me and me seeing the kids, so when she doesn't have to do anything beyond dropping off the kids and picking them up, that should be a practical solution for her as well.

But yeah, the picture above. I moved recently. and the hospital is now within walking distance. I have given the healthcare system in Norway quite a bit of criticism, but when I see little of my kids for years and years, and 10% of my income goes to legal costs, and this situation started when I had serious psychiatric diagnoses, was taking a significant amount of mind-altering medicine and was going to therapy and was talking about serious problems with the kids mom, they are getting what they deserve.


[Permalink] [By morphex] [Politics (and judicial matters) (Atom feed)] [16 May 12:38 Europe/Oslo]

Experiencing the surrealism of the Norwegian "wellfare" system

So, last month I was in a meeting with NAV, the wellfare office, employment office, pension office etc. in Norway, aptly named NAV (wheel hub in English).

They want to get me into a work preparation program, or as I suspect, a suitability for work program, while I am more on the exercise a lot and do different interesting computer things, that I'm motivated for doing and that will help me get a job later.

Since last summer, I've exercised a lot, and I can feel a positive development and see a positive development on my body since then. I've also dabbled in different computer things, for example the Java Twitter export tool that I blogged about on my blog, and the source code is available on Twitter.

I've worked hard most of my life, and I have to say I'm disappointed in seeing how the Norwegian system works. After I got psychotic at the end of 2009, I drained the company (my own company) for money, when I probably should have been 100% on sick leave and gotten money from the state.

So today, although I feel motivated to work in my company and could probably work 8-16 hours a week, I am unable to, because I've earlier exhausted the funds in the company, Nidelven IT.

In addition to this, the work-sickleave-unemployment route I've taken, or have been guided through by NAV and the healthcare system, gives me very little money, now that I'm on "work assessment allowance", and I'm also paying around 10000 a year in interest on the court costs that the kids mom accrued, after she over a long period did a lot of things and practically provoked a round in court.

Now it looks like I'll have to take another round in court, and with the payments on the new court case and the previous one, I'm paying around 10% of my net income in these court costs, and I have low income.

This comes in addition to the over 30.000 kroner I've had in expenses seeing the kids, after I rejected the kids mom in the summer 2013, which the kids mom refuses to share according to the law defined norm, as she claims we had an agreement on travel costs, but not on how often I should see the kids, or rather how often the kids should get to see me.

So yeah, NAV want to put me through the stress of a work assessment program, when I have a positive development with things I've chosen to do myself, that do help my health and my work prospects.

A while ago, a dentist documented and treated me for an infection in the gums, something that is probably because of the medication I've been taking, and this is something that NAV has paid for, the dental treatment. And the Norwegian patient injury reparation organization has said that it remains to see if it is a permanent problem.

It still remains to be seen if this treatment will be necessary in the future though, or if I have a permanent problem.

But, here is the conundrum. I've been advised that the medication I've taken, Seroquel, can lead to diabetes and heart problems in the long term. So, if NAV pressures me into this work assessment program, and I later get diabetes, who is responsible, and what do I get for it?

If I've been advised that I can get a condition from a medication, I can't sue to get reparations. I can take diabetes pills, but still the diabetes would affect my life quality and life expectancy.

I guess any wise person would say that there is nothing more important than having good health, and that no amount of money can replace good health.

So I guess it might be that I, and many others, are destined to be medical trial subjects, in a semi-nazi government system, that sells a lot of present for an unknown future.

[Permalink] [By morphex] [Health (Atom feed)] [29 Apr 19:47 Europe/Oslo]

Now making (an almost) complete Twitter archive using Java, validating as UTF-16LE XHTML

So.

I was figuring out the latest bits to my Twitter archival tool today, and once I made a complete dump of all Tweets, I saw that I had forgotten to HTML-encode URLs, so & was breaking the validation.

Boy, was my face red for a split second. Anyway, the nice org.apache.commons folks have created a tool to encode URLs for HTML, so that was an easy fix.

However, the W3C validator

https://validator.w3.org/

Was still giving weird errors, and after some fiddling around and googling, I found the W3C I18N checker, which explained that XHTML couldn't be prefixed with an <?xml declaration. It's been a while since I worked properly with web documents I guess, so I'd forgotten about that.

So OK, I removed the declaration, and thought I'd add a meta http-equiv or charset tag to the document, to be declarative about the content of the document.

However, the I18n validator first complained about that, saying I couldn't use UTF-16LE as an encoding, and that I had to say UTF-16, but when that was fixed, the validator complained and said that I shouldn't specify the encoding in the document.

And that makes sense, because the document starts with a BOM, which indicates the charset and the endianness of the charset.

Anyway, I get a whiff of cultural imperialism when I see that W3C says UTF-8 is the recommended encoding, and the main validator is so unhelpful when giving feedback on what is wrong with the document. :\

So, here's the commit of today's work:

https://github.com/morphex/twitter-exporter/commit/f32b12f42...

A productive day, and

https://blogologue.com/test3.html.bin

Shows an almost complete archive of my Tweets. A grep shows that my archive is 3128 tweets:

iconv test3.html -f utf-16|grep "class='tweet"|wc -l
iconv: incomplete character or shift sequence at end of buffer
3128

while Twitter says I have well over 4000 tweets:

    Tweets 4,943
    Following 98
    Followers 189

So I guess Twitter has some segmentation of its archive, for unknown reasons.

I did get some feedback on my blogging about Java and type-casting, and using Java generics it is possible to avoid this tedious type-casting I was talking about earlier. I had seen the syntax for Java generics before and found it to a bit of an eyesore, but seeing how it saves quite a bit of tedious typing and that the syntax is straightforward, I guess I can't complain.

It's not Perl after all..

[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [23 Apr 16:52 Europe/Oslo]

A light chickpea snack / meal (cheap and nutritious)

So, these last couple of years I've started making meals from scratch, to improve the health, but also to save significant amounts of money.

I'm now on a flexitarian diet, and I don't eat much red meat anymore, and rarely white meat such as chicken. I eat quite a bit of fish, tuna and salmon. I also consume eggs and dairy products.

I go to the local immigrant stores and buy packs of veggie products, such as chickpeas. 1 KG costs 35 kroner, 4.5 dollars, 3.75 euros, and divided up, gives significant protein to 10-15 veggie meals.

Today I took one of those chickpea packs (ca 200 grams), and fried it in a pan, alongside some chopped garlic (6 gloves) and a handful of olives:

Picture of chickpeas, olives and chopped garlic fried in a pan, with a spoon

I used Canola oil to fry it in, and added some salt and black peppers to spice things up.

I've been very restrictive on the spices in my food, but this week I shelled out some cash on a 20-gram pack of black pepper, and will start to use pepper a bit more in the cooking. Spices add flavour, but also mask other flavours, so I guess experimenting with different ingredients is easier with less flavour complexity.

Anyway, I'm not sure whether to call this a snack or a meal, but a light meal should be a fitting categorization. And very nutritious and healthy.

[Permalink] [By morphex] [Food (Atom feed)] [22 Apr 15:05 Europe/Oslo]

Can I Java cup of coffee? Isn't that valid?

Yesterday I made some progress on the twitter-exporter tool, working and thinking quite a bit in one day.

I'm surprised I am as productive as I am in Java, since I haven't used it in work-related projects. Yesterday it felt like I had a couple of cups of coffee too many, maybe it's the spring, but I was cranking out code and dealing with Exceptions like I'd been eating a lot of cake and drinking a lot of coffee.

I'm particularly pleased with this piece of code:

class TwitterStatusFetcher {
        Twitter twitter;
        ArrayList statuses = new ArrayList();
        Integer page = 1;
        Integer count = 20;

        TwitterStatusFetcher(Twitter twitter_) {
                twitter = twitter_;
        }

        Status getNextStatus() throws TwitterException {
                if (statuses.isEmpty()) {
                        // See if more tweets can be found
                        ResponseList results = twitter.getUserTimeline(
                                new Paging(page, count));
                        page++;
                        statuses.addAll(results);
                }
                if (statuses.isEmpty()) {
                        return null;
                }
                Status status = (Status) statuses.get(0);
                statuses.remove(0);
                return status;
        }
}

Which works with the twitter4j code and Twitter API to deliver one status at a time to the rest of my app code. Maybe it's not that big of a deal, but I found it elegant, and it does use the object-oriented paradigm that Java is big on.

It seems the most frequent mistake I make coming from Python, is forgetting the semicolon; I like to indent code regardless of language, so it's the semicolon that I forget.

I guess one thing I've found annoying about Java so far, is the type casting that is necessary at different places. I was working on some code which I guess was eventually removed, where I knew the method to call, but because of some abstraction in a method call, the returned objects were java.lang.Object, and calling a method, a String method I think, on that object failed in compilation.

I was also almost smacking my head yesterday, when I discovered that twitter4j returns shortened (and expanded) URLs in their Tweets as well, and thought I'd developed quite a bit of code for no good reason.

However, as it turns out, some tweets do contain shortened URLs that aren't mentioned in the Tweet metadata, so the class I wrote to resolve t.co URLs still has some use. Phew.

Finally, I found Firefox now displayed the test.html output page as XML, instead of XHTML. So I made the code output a Unicode BOM, and Firefox says it is in standards compliance mode, and Chrome does not complain. However, the validator on w3c.org, https://validator.w3.org/ - still does not validate the page when it has a UTF-16LE BOM.

I'm not sure what's going on there, but to me it looks like the w3c validator isn't working.

A test.html page I just created is available at https://blogologue.com/test2.html.bin - just rename it to test2.html after download and open it in Firefox to see the rendered archive of my tweets.

[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [14 Apr 10:35 Europe/Oslo]

Doodeling along with Java development, "unit development" and more

Yeah, I've been developing a Java app to export all my tweets for safe-keeping.

I'm new to Java, so I asked a bit about limiting the amount of pieces of development software, so it was less complicated to see what the problem was when the code failed.

I asked on comp.lang.java.programmer, with the message ID <d25b03ed-607f-45d0-8b45-25f3835d44bb@googlegroups.com>. I did get some useful feedback, but I guess my idea of a simple bootstrapping development environment has something to it. Why not make something less complex if you can?

I worked on the code for resolving Twitter URLs today, and this is the ResolveRedirect.java file as of now:

https://github.com/morphex/twitter-exporter/blob/e6b9c55470f...

I have to say, that coming from the Python world, a lot is the same, although I have to say Python is less bureaucratic and easier on the eyes. Maybe in Java's advantage, things are well packaged and one is pretty much forced to think in an object-oriented way.

I can't say that developing in Java is worse than Python, I think they are even in many ways.

The code I've been develolping is fairly simple, the data it works on is also uncomplicated, with standard encodings, data formats and protocols.. so I'm not learning anything new there, and keeping things very simple on whatever I need to store as well, plain-text file format. If I was learning some new protocols and software libraries it could be a bit more difficult.

It's nice though, to see that I'm able to be very productive in a language I haven't used in a work-related context, feels like I'm firing on all cylinders again.

[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [09 Apr 13:33 Europe/Oslo]

Automating builds using Maven, writing XHTML & refactoring in Java

In my efforts to write a tool for exporting Tweets from Twitter for safe-keeping in Java, I came a bit closer to the goal to create such an archive today, when I managed to automate the build of the app a bit, and make the app create something that resembles the desired end-result.

Earlier I had to download jar files from projects that my project depended on, but with the following commit:

https://github.com/morphex/twitter-exporter/commit/ed8303638...

One jar is built, and it is run using the command

java -cp ./twitter-exporter-1.0-SNAPSHOT-jar-with-dependencies.jar org.morphex.app.App

I would like run the app in an even simpler way, but it is a big improvement from downloading jar files manually and including them on the "java -cp" command.

I was initially thinking I'd keep things as simple as possible and avoid unnecessary dependencies and systems, but seeing that there are collections of Java classes with useful features, features you'd expect to be in the Java core, it is great to be able to include these using some lines in the pom.xml Maven file.

Secondly I refactored the code a bit, so that the main App class was able to write an XHTML file containing a number of tweets:

https://github.com/morphex/twitter-exporter/commit/093545931...

You can download the generated output here:

https://blogologue.com/test.html.bin

I had to call the file test.html.bin to fool the application server into treating it as a binary file, as UTF16-LE is the encoding of the file and I guess the application server uses UTF-8. Renaming it to test.html and opening it in Firefox should work.

StringEscapeUtils.escapeXml10 is a nice tool, and something you'd assume would be so necessary and standard that it would be included with Java by default. Seeing this is the way it is, I guess there is really no way around using a tool like Maven to build projects.


[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [05 Apr 19:36 Europe/Oslo]

Sex in the 21st century, follow-up

So, I emailed my lawyer a while ago, asking about fatherhood, rights and obligations. Here: https://blogologue.com/blog_entry?id=1520278746X36

He did not reply to that message, but I asked someone else who has some legal expertise, and I understood the message as, if you make someone pregnant, you cannot legally deny fatherhood or child support.

So, basically, if you're at a party, have a good time, and end up with someone, and have sex that one time, you can end up paying child support for 18+ years.

If in addition to this, the woman is difficult, you not only have to pay a substantial amount of money, but you also have a difficult person to deal with.

Now, it is the case that women do rape; so worst case is that a woman rapes you, makes your life a living hell, and you have to pay a lot of money for kids you don't get to see (often).

I can understand that the state wants its inhabitants, and having kids is an important part of life.. but it seems to me that men are shafted in many different ways when it comes to family life.

94.5% of the inmates in Norwegian prisons in 2015 were male.

[Permalink] [By morphex] [Health (Atom feed)] [04 Apr 16:41 Europe/Oslo]

Testing out Java's Unicode support, UTF-16LE the choice for now

So, in my efforts to create a tool to export my Tweets from Twitter for safe-keeping, and learning a bit of Java in the process, I today created a Java snippet of code to write an XHTML file, to get acquainted with Java and its Unicode support.

I've worked with Unicode in Python and in C, and a while ago I started some discussions on comp.lang.c, as I was testing out C to write an XML parser. That project ran out of steam, but I still think today that UTF-32 is the least discriminatory (and uncomplicated) approach to sharing information like web pages.

Anyway, here's the Java code for writing a test XHTML page, fully validating on the W3C validator:

https://github.com/morphex/twitter-exporter/blob/71a4cdf1a6f...

Well, it was validating on the W3C validator, but once I added code to write a BOM, it no longer validated. 🤔 But shows up fine in Firefox, and "file test.html" says:

test.html: XHTML document text (version 1.0), Little-endian UTF-16 Unicode text, with no line terminators

So I'm not sure what's going on there.

As I was testing out Java, I was hoping and optimistic for having a Unicode solution that just worked, and even more so when OutputStreamWriter accepted an encoding argument.

But as you can see on the history of WriteXHTML.java, I had to revert to using just FileOutputStream, and encoding strings and writing them as bytes to the test.html file.

So much for that dream. Well, this is all alright, I find Java a bit verbose, but it also reminds me a bit about C and that's nice.

A thing that surprised me though, was that Firefox did not support UTF-32LE encoded XHTML. Why not?

[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [04 Apr 00:06 Europe/Oslo]

Resolving URLs from a URL shortening service in Java

So, in my efforts to create a tool to keep a (complete) archive of my Twitter activity, I today wrote a tool to help replace t.co URLs in my tweets, with the actual URL, here:

https://github.com/morphex/twitter-exporter/commit/3341f7780...

Now I come from the Python world, and lately I've been looking at Java to learn it properly. To improve my chances of having gigs that are interesting, regardless of programming language.

I started looking at URL objects and generating a connection from that, but since I'm going to resolve a lot of t.co addresses, found that it would be better if I kept an HTTPS connection open to the t.co server, and then pass the final part of the URL over to t.co. Another issue here is maybe a "resting period" between each resolved URL, so as to not appear "spammy" or "resource hogging" on the t.co server.

Anyway, luckily I found an example online that I could adapt for my purposes, and I'd have to say, compared to Python, Java is a bit bureacratic with its classes and types, but other than that, Java is just fine.


[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [01 Apr 12:05 Europe/Oslo]

A Java-based tool to export tweets from Twitter for safe keeping

So, I was looking into exporting all my tweets the other day, to keep a copy just in case something happened to my Twitter account.

I tried exporting from Twitter (using a desktop browser as they asked on the export page), but I have so far not seen a dump of all my tweets.

I see there are other tools available for exporting Tweets, websites, but I thought to myself, why not create a simple, safe tool for exporting and safe-keeping Tweets.

So, after a bit of rummaging I found twitter4j, and started to build a Twitter export client using a text editor, a Makefile and javac/java.

However, I quickly ran into a NoClassDefFoundError, and after googling a bit, I felt an obscure-configuration-detail-headache coming on, and decided I could try to use Maven, which is mentioned on the Twitter4j website for the build process.

The Maven quickstart guide instructed me to use this command to generate a Maven project:

mvn archetype:generate -DgroupId=org.morphex.app -DartifactId=twitter-exporter -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

And after downloading some components etc. - Maven had a file hierarchy for me.

I then added the following section to pom.xml

    <dependency>
      <groupId>org.twitter4j</groupId>
      <artifactId>twitter4j-core</artifactId>
      <version>4.0.4</version>
    </dependency>

To include the twitter4j components in the Maven project. I then preceeded to run "mvn package" and then entered the target directory, and with the command

java -cp ./twitter-exporter-1.0-SNAPSHOT.jar org.morphex.app.App

I got the result

Hello World!

Which is what one can expect, as the project was just generated. Afterwards I created a new repository on GitHub, and uploaded the project (output of "history|grep git" in bash):

 2172  git init
 2173  git add pom.xml src
 2175  git config --global user.email "morphex@gmail.com"
 2176  git config --global user.name "Morten W. Petersen"
 2177  git commit
 2182  git remote add origin https://github.com/morphex/twitter-exporter.git
 2183  git push -u origin master
 2184  history|grep git

I started with this before I decided to blog about it, so I guess to setup the enviroment you have to run "sudo apt install maven openjdk-8-jdk openjdk-8-jre git" on Ubuntu/Debian.

The source code website for the project is here: https://github.com/morphex/twitter-exporter

[Update same day: I had to download the twitter4j jar and add it to the java command above: "java -cp ./twitter-exporter-1.0-SNAPSHOT.jar:./twitter4j-core-4.0.4.jar org.morphex.app.App"]

[Update later same day: twitter4j-core-4.0.4.jar can be downloaded from http://twitter4j.org/maven2/org/twitter4j/twitter4j-core/4.0...]

[And update even later same day: twitter4j-core-4.0.6.jar can be downloaded from https://repo1.maven.org/maven2/org/twitter4j/twitter4j-core/... - it's necessary for the latest code to run]

[Permalink] [By morphex] [Java (Atom feed)] [30 Mar 15:19 Europe/Oslo]

I'm not an actor, I'm not a star..

Picture of bike, with text I'm not an actor, I'm not a star, but I've got this bike and it gets me around like a motherfucker

[Permalink] [By morphex] [Health (Atom feed)] [28 Mar 12:06 Europe/Oslo]

Charges pressed against NAV and NAVI

So, I've had issues over time with NAV and NAVI, NAV being the Norwegian employment and wellfare office, NAVI being the child support collectors (some branch related to NAV I guess).

Over time there has been some critique and questions, and things turned a bit weird not so long ago, when my primary care physician basically said he wanted me to find another primary care physician.

So I filed a report against NAV and NAVI today, here's the original, and here's the translation:

To: Police Trøndelag (county police) <post.trondelag@politiet.no>
Cc: Police internal affairs <per-martin.utkilen@spesialenheten.no>, Sveinung Hestad Strand <strand@advokatsf.no>, Elisabeth Nossum <elisabeth.nossum@nav.no>, Per Olav Gundersen <per.olav.gundersen@nav.no>, NAVI <navi@navi.no>
Bcc: Dad <jpeter@broadpark.no>

Hi.

In 2009 I became acutely [mentally] ill, psychotic, and was until then on an up-and-coming arch salary-wise, in my own company.

Today I have a low income, and I am in many ways financially painted into a corner, and also have problems with my kids mom, and have met the kids 2-3 hours a month on average since 2013.

I have asked questions to NAV about their methods, and a short while ago I asked to have all papers to my case printed out. I moved apartments in that period, and got a message to get the papers on NAV Lerkendal. When I got there, I got a message to pick them up at NAV Heimdal.

When I collected the papers at NAV Heimdal, they were in an unsealed envelope, with a thin rubber band wrapped around.

NAV has also recently rejected a meeting at the conflict council [the first step to arbitrating a conflict in the Norwegian legal system], after one arbitrating session there.

I was in a meeting on Wednesday at NAV Lerkendal with Elisabeth Nossum and Per Olav Gundersen, where NAV and I did not agree on the path [for me getting back to work life]. When I after the meeting applied for financial welfare support for a lawyer, so I can understand my rights and obligations regarding NAV and AAP, it was suggested I instead contact the free legal help [organisation that provides free legal assistance]. But I applied for welfare support for a lawyer anyway, 1020 kroner.

If the free legal help is OK for all legal questions and cases, I guess we don't need lawyers and the licenses to practice as lawyers?

Shortly before this [couple of weeks], my primary care physician Thor Digre displayed weird behaviour, and asked me to find a new primary care physician.

NAVI has on their end done some weird things, and I have given them information relevant to the case and my situation, which it looks like they have ignored.

So I'm asking what NAV and NAVI are doing [and have been doing]. Now one should be very careful to [be the boy who cried wolf], especially with a prior history of serious mental illness, but you can consider this a legal maneuver to give you an approach vector.

You know, there is a 5 year statute of limitations on crimes with a maximum penalty of 4 years.

A signed copy of this document will be sent later.

Regards,

Morten W. Petersen

[Permalink] [By morphex] [Politics (and judicial matters) (Atom feed)] [24 Mar 12:27 Europe/Oslo]