Shortlink

Experiment with jingle gigs on Fiverr

Earlier this year I found out about Fiverr. A website where people will create customized things starting at $5. I tested with an experiment and had a jingle made for the daily stand up meeting at work – great success. So for my wedding in August of this year I decided to do an experiment. Give four people on Fiverr $5 to execute the exact same task to make a jingle:

I am going to get married in two weeks and I would like a jingle to open the wedding with. Something with “what a wonderful day today”, “let’s party”, “hope you all have a good time” or something similar – you will have full creative control . Name of me and the bride are Paulus and Anne Therese. Maybe cool if those names are in it too English pronunciation for both names is fine. So the end of Therese should sound sort a like the the end of “Greece”.

There are not too many but after going through Fiverr I found 4 people that will write a song and record it for just $5. The results are ranging from super awesome to funny.

My favourite is by far by Taylor. This is the result of his gig create a 16 line song about anything by Taylor Barks.

A complete different genre and probably a big favorite on the wedding was bluesight. Write and record a professional jingle by bluesight.

Customdrumploops did an okay job. I like his previous work for me more, but still like the result. Write you  a ukulele jingle by customdrumloops.

Banjoman not only wrote and recorded the song, he includes a video and a sketch. Pretty amazing. Sing a banjo song for you by banjoman15.

Not the same task, but for the wedding I also had a (Dutch) DJ drop made for $5 by powerjinglesnl which is really awesome.

Wedding photobooth

Shortlink

Home Assistant – home automation in Python

TL, DR:  Python project that you can run on your Raspberry Pi/server/HTPC that will monitor your devices and provides triggers and APIs to control them. Grab Home Assistant from GitHub

Since I acquired my Philips Hue bulbs late 2012 I have been interested in the “Internet of Things”. Ever since I felt like it was time for automating my house. I imagined it couldn’t be so hard so in September 2013 I decided to start from scratch using Python.

My initial goal for the project was a simple script that would:

  • query the router to see which devices are connected
  • turn lights on when people get home after sunset
  • turn lights off when everyone is gone but lights are still on

Once that was done I noticed it gets darker while the sun is setting. Wouldn’t it be nice if the lights would start fading in before the sun actually sets to compensate the dusk.

Fast forward 3 months and a lot of “wouldn’t it be nice if” moments later Home Assistant is mature enough and ready for it’s first release. And because a picture says more then a 1000 words. Let’s start with a screenshot of the web interface:

Home Assistant dashboard

Home Assistant dashboard

It is currently able to:

  • Track if devices are home by monitoring connected devices to a wireless router (currently supporting modern Netgear routers or routers running Tomato firmware)
  • Track which lights are on
  • Track what your Chromecasts are up to
  • Turn on the lights when people get home when the sun is setting or has set
  • Slowly turn on the lights to compensate for light loss when the sun sets and people are home
  • Turn off lights and connected devices when everybody leaves the house
  • Start YouTube video’s on the Chromecast
  • Quit current running application on a Chromecast
  • Download files to the host machine
  • Open a url in the default browser at the host machine
  • Simulate key presses on the host for Play/Pause, Next track, Prev track, Volume up, Volume Down
  • Controllable via a REST API and web interface
  • Support for thin client Home Assistant instances that will forward all their commands to the main instance
  • Android Tasker project to control Home Assistant from your phone and report charging state. Combine it with AutoVoice to be able to tell your phones to turn the lights off!

Adding rules or functionality is as simple as writing small Python snippets that get triggered on a state change or get exposed via the API as a service. An example rules that could be implemented: When the Chromecast starts running the PlayMovies app (and thus a movie is being played): call service to dim the lights.

Grab Home Assistant from GitHub

Shortlink

Keep calm and write your damn thesis

On Facebook circulated a low-res picture of “Keep calm and write your damn thesis”. I decided to recreate it as an A3-size poster to motivate my girlfriend on her PhD thesis writing journey.

I got a few requests to make the poster available so here it goes [PDF, 67KB, size A3].

977328_503563475575_398867381_o

Shortlink

Script hanging randomly when running in PowerShell

While running my Python 2.7 scripts in Windows PowerShell I sometimes bumped into the problem that PowerShell would halt/pause execution of my scripts until I pressed a key. Initially I blamed it on myself and that I wrote some bad code but I couldn’t reproduce the problem. After careful analysis of my code I could find nothing that would request user input (like the raw_input() method) and also when I removed the threads the problem kept occurring. What could it be?

And then I found it: PowerShell has this very odd behavior that it will block all writes to the output if the user has selected text in the terminal. I would sometimes select text to be able to track how far the window was scrolling but didn’t know it would halt script execution!

If you see your PowerShell hacing “Select” as prefix of the window title make sure you press space to cancel select-mode or your scripts won’t run.  Aargh!

I tested with my Mac to see if other terminals suffer the same feature. For the stock Terminal and iTerm I can confirm: they do not (obviously!).

Test Python script I used:

import time
while True:
  print "A"
  time.sleep(2)

While running the script in PowerShell select some text by click-and-drag in the window. You will see that the script will stop executing.

Just putting this out there in case there is someone out there having the same problem.

Shortlink

Living below the line

Last week my girlfriend and I engaged in a challenge set forth by the Global Poverty Project in their Live Below The Line campaign:

Live Below the Line is a campaign that’s changing the way people think about poverty—and making a huge difference—by challenging everyday people to live on the equivalent of the extreme poverty line for 5 days.

They estimated that extreme poverty in America is equal to living on $1,50 a day. With the two of us that means we were allowed to spend a stunning $15 on food and drinks for 5 days. As an extra challenge on top of that I am not a huge fan of rice and beans and prefer not to eat it. After some research and planning we headed out to the Food 4 Less and came up with the following set of food for the 5 days:

Our food for live below the line

The ingredients we bought. Spent no more than $15 for 2 people for 5 days!

Yes, we even managed to sneak in a pound of meat for $0.98! For getting a cheap price on certain products (spaghetti, eggs, oil, salt) we had to buy in bulk and only use part of the packages we bought. Can you image how weird it is to count the slices of bread in a loaf to see if you will have enough food for the week?

Continue reading

Shortlink

Bitcoin mining on a Mac running Mountain Lion

I recently started speculating with some bitcoins. A lot of fun and a good way to learn the trading game. After trading with bitcoins for the last few weeks I wanted to see how the other side of bitcoin looked: the mining side. Since it took some figuring out to get all of it working on my Mac running Mountain Lion I decided to write the steps down:

This tutorial will get your Mac setup to mine using poclbm as part of a mining pool. Mining on your own with only a Mac is a lousy idea to begin with, don’t bother.

First step is to create an account with a mining pool website. I chose https://mining.bitcoin.cz. Go to the website and create an account. After verifying your e-mail you will get your first worker login.

Now we have the login ready, it is time to prepare the Mac. Go to the  App Store and install Xcode. Open Xcode after installing it. It will prompt you to accept a license agreement and install some extra components, do so. When Xcode is showing it’s welcome screen go to Xcode -> Preferences -> Downloads and install the Command Line Tools.

It’s time to fire up the terminal. In the terminal run the following commands:

sudo easy_install pip
sudo pip install pyserial pyopencl
git clone https://github.com/m0mchil/poclbm

That’s it! You are good to go mining now. To start mining, go to the terminal:

cd poclbm
python poclbm.py stratum://YOUR_WORKER_USERNAME:YOUR_WORKER_PASSWORD@stratum.bitcoin.cz:3333

Replace YOUR_WORKER_USERNAME and YOUR_WORKER_PASSWORD with the login info you created in the first step.

Screenshot showing my mac mining bitcoins with poclbm

Screenshot showing my mac mining bitcoins with poclbm

Happy mining!

Shortlink

Write data with own mime-types to NFC tags on Android

Yesterday I attended a Facebook Hackathon at UCSD. For our hack we needed to be able to prepare some NFC tags with our own mime-types and data. After some searching online the best example I could find was an excellent tutorial by Jesse Chen but no code ready to be executed! So after getting a working Android app to help us decided to share it with the world.

Get the app on the play store

Get the source on github

screenshot NFC Tag Writer

Shortlink

Denormalizing COBOL Copybooks using Python

I am working with Informatica PowerCenter on a day to day basis and sadly have to deal with data coming in who’se format is described by COBOL Copybooks. When a Copybook is imported PowerCenter decides that it will convert all the fields and groups having OCCURS statements into separate tables. A neat feature but when unwanted a big pain.

The only way to stop Informatica of doing so is by denormalizing the COBOL Copybook and thus removing all the OCCURS statements. Googling how this can be done results sadly in a handfull of posts advising me to do it manually, yikes! If you came to this page looking for an answer to a similar question look no more – for I have created a neat COBOL parser in Python that does denormalization too: Python-COBOL.

Before:

00000 * Example COBOL Copybook file                                     AAAAAAAA
00000  01  PAULUS-EXAMPLE-GROUP.                                        AAAAAAAA
00000       05  PAULUS-ANOTHER-GROUP OCCURS 0003 TIMES.                 AAAAAAAA
00000           10  PAULUS-FIELD-1 PIC X(3).                            AAAAAAAA
00000           10  PAULUS-FIELD-2 REDEFINES PAULUS-FIELD-1 PIC 9(3).   AAAAAAAA
00000           10  PAULUS-FIELD-3 OCCURS 0002 TIMES                    AAAAAAAA
00000                           PIC S9(3)V99.                           AAAAAAAA
00000       05  PAULUS-THIS-IS-ANOTHER-GROUP.                           AAAAAAAA
00000           10  PAULUS-YES PIC X(5).                                AAAAAAAA

After:

         01  EXAMPLE-GROUP.                                                     
           05  FIELD-2-1 PIC 9(3).                                              
           05  FIELD-3-1-1 PIC S9(3)V99.                                        
           05  FIELD-3-1-2 PIC S9(3)V99.                                        
           05  FIELD-2-2 PIC 9(3).                                              
           05  FIELD-3-2-1 PIC S9(3)V99.                                        
           05  FIELD-3-2-2 PIC S9(3)V99.                                        
           05  FIELD-2-3 PIC 9(3).                                              
           05  FIELD-3-3-1 PIC S9(3)V99.                                        
           05  FIELD-3-3-2 PIC S9(3)V99.                                        
           05  THIS-IS-ANOTHER-GROUP.                                           
             10  YES PIC X(5).

It doesn’t support all functions found in the Copybook, just the ones that I met on my path (REDEFINES, INDEXED BY, OCCURS) but it can easily be extended.

Python-COBOL on GitHub