A programmer once built a vast database containing all the literature,
facts, figures, and data in the world.
Then he built an advanced querying system that linked that knowledge
together, allowing him to wander through the database at will.
Satisfied and pleased, he sat down before his computer to enjoy the fruits
of his labor.

After three minutes, the programmer had a headache.
After three hours, the programmer felt ill.
After three days, the programmer destroyed his database.

When asked why, he replied:
'That system put the world at my fingertips. I could go anywhere, see
Because I was no longer limited by external conditions,
I had no excuse
for not knowing everything there is to know.
I could neither sleep nor eat. All I could do was wander through the
Now I can rest.'

-- Geoffrey James, The Zen of Programming.


Call of the Zombie

And out of the darkness, the Zombie did call
True pain and suffering he brought to them all
Away ran the children to hide in their beds
For fear that the devil would chop off their heads


Disable poweroff OpenElec remote

So I got my new Raspberry Pi 3 and installed OpenElec on it.
All working very nice and fast (finally!) and my Harmony one was working out of the box.

One thing that annoyed me: Whenever I switch scene or poweroff my system, the raspberry also powers off.
Which means next time I want to use it, I have to find it and disconnect/connect the usb cable.

But you can disable the poweroff by creating a custom remote keymap.
The file is located in /storage/.kodi/userdata/keymaps/remote.xml
Put the following in there to disable poweroff:

This makes the power button call NOOP (NO OPeration).


Sending big email using Google PHP API client and gmail

If you start with the Google PHP api client, things are pretty ok.
The package lacks good documentation, and the examples provided are very basic.
But, you probably get it working and you start to write code to send email using the gmail API:

Now this code will work. But soon the user will add an attachment to this email, making it bigger than 5MB and BOOM it breaks.
As usual when you get stuck you open a browser, and search stackoverflow and google. You will find out more people have hit this problem, and some say it is fixed by using 'chunked uploads' ...
After hours of searching you give up and revert to using plain old SMTP as there is no documentation or anything telling you how to do this chunked upload.
Until now, as I will show you how to fix this.

I will implement only one way of sending email: using gmail API and using chunked uploads. Even if the mail is only a couple of characters like 'I will be late for dinner, start without me. Cheers'
Why? Because this small email will be send using 1 chunk, and it keeps it simple: there's no nasty if statements for smaller and bigger emails.

First, the changed code from the sample above:

So, what did we do?
First, we created, like before, an RFC 822 mail message in the variable $mailMessage, setup the Google API client, Created a gmail service instance and gmail message object etc.
Then, we told the Google_Client to not immediately do it's calls, but defer it until we actually start sending data to it. We also reset this at the end so we can do more calls from there that will be run immediatelly.
Then we started a MediaFileUpload which can be told to do it in chunks.
Then we simply start sending chunks until all data is uploaded, and continue our script as before.

Easy right? If only the documentation showed how to do this for something else than a file upload to Google Drive, it would have been easy.
But like I said before, the documentation of this package is mostly non-existing and you will need to read most of it's source before you understand how things work.

I hope I helped you a bit and saved you some hours of reading the internet.


mutt-notmuch-py and multiple accounts

Like many other people, I have more than one email account.
A lot of accounts are setup to forward mail to my main email address, but I still have seperate accounts for my private and my work email.
The email comes to my notebook using offlineimap, and is indexed with notmuch for easy searching. (I should probably create pages documenting my setup so you can all enjoy this wonderful setup)

One thing that always bothered me is that searching returns matching emails from all accounts.
Most of the time I am only interested in emails in the account I'm currently working in.

But as of yesterday Honza was so kind to accept my pull-request against his mutt-notmuch-py repository and now one can limit the search results to a specific path!

Go HERE to get the latest version with this support.


Why I hate gmail

At work the whole email setup is put in gmail, like almost all startups do.
When you can get your head around the horrible webinterface, it can be ok for you to use. But if you are like me and prefer a real email client gmail can have a lot of problems.

Some things I found out the hard way yesterday while debugging why my offlineimap+mutt setup stopped working correctly:

  • Gmail has some special folders like [Gmail]/Sent, [Gmail]/All Mail etc
    Those folders get renamed when you switch your output language on https://www.google.com !!! basically rendering your settings of your email client non-working!
  • New mail gets delivered in both INBOX and [Gmail]/All Mail.
    This handling is confusing, as they are the same mails sometimes, and different mails sometimes:

      • When marking a mail Read in INBOX, the mail does NOT get marked Read in [Gmail]/All Mail
      • When removing a mail from INBOX, the mail does NOT get deleted from [Gmail]/All Mail
      • When moving a mail from INBOX to [Gmail]/Trash the mail DOES get deleted from [Gmail]/All Mail
      • When moving a mail from INBOX to [Gmail]/All Mail you end up with double items, BUT ONLY for a couple of minutes.
        Gmail has some algorithm to remove double mails from the [Gmail]/All Mail folder.
        This algorithm does not only work on mails that are 100% the same. Sometimes it thinks two different but very much alike mails are the same and it ends up deleting wrong mail.
  • Sending mail through their SMTP services creates double mails in [Gmail]/Sent if your mailclient does the same.
    Since almost all mail clients do this, using something else than the official Google mail clients will create double items in your Sent box

All the above items are hardly documented, and for me make totally no sense at all.
Unfortunately I'm stuck with gmail for my work email, and had to fiddle with my configs a couple of times simply because Gmail showed some undocumented and unexpected behaviour.

My advice: stay away from gmail as far as possible!


Bye bye digital ocean

This site, and many more things have been hosted on a bunch of VPSes hosted by digital ocean.
We have always been very happy with their services, but it is time to move on.

All things hosted on digital ocean have now been moved to a new FreeBSD machine hosted on a 100mbit fiber connection.
Yes, our home connection.

Backups have been configured to go to the synology NAS (one thing that has always been missing on the VPSes)


CloudFront with AWS CLI

If you want to script AWS cloudfront actions you will notice this is not working.
For some reason, AWS still thinks this part of their API is in preview mode.

To get it to work add the following to your ~/.aws/config file:
cloudfront = true


Hide join/part/quit in Weechat for bitlbee

There are a lot of pages on the internet about how to use hipchat with bitlbee.
Because of this I'm not going to explain that. Do your google foo and find out.

There is one really annoying thing: people tend to fill up your buffers with join/part messages.
Now there are some pages out there that tell you how to fix it with irssi but did not find a weechat tip.

So see here, this is how I did it.

In my case, I added the bitlbee server with
'/server add bitlbee my.bitlbee.server'

Now, to get rid of the join/part messages type:
/filter add joinquitbitlbee irc.bitlbee.* irc_join,irc_part,irc_quit *

And no more annoying join/part/quit messages that are very common with all the IM services out there.


Real men have beards!

"One cannot become a true UNIX geek without growing one at least once. Like a monolithic kernel, a UNIX geek’s beard is a commanding obelisk of knowledge, wisdom, and hubris. It is a focal point, a symbol of arcane power."


Back to Top