Skip to main content

Björn Stierand"/>

IT guy • Triathlete • Avid traveller (not right now, though) • Net addict • Wannabe minimalist • IndieWeb aficionado

egoexpress

egoexpress

egoexpress

egoexpress

egoexpress

egoexpress

ego_express

egoexpress

Ironman FFM 2016

1 min read

Danke an alle die mich gestern sowohl aus der Ferne als auch direkt an der Strecke unterstützt haben. Es war windig, kalt und nass, aber wenn man weiss dass einem die Unterstützung von vielen Freunden und Bekannten sicher ist (und man dann vor allen Dingen noch vom Streckenrand lautstark angeschrien wird), dann kann man das Letzte aus sich herausholen.

Nach persönlichen Bestzeiten in allen drei Disziplinen bin ich mit 9:17:15h und einer Verbesserung meiner Langdistanz-Bestzeit um mehr als 10min vollauf zufrieden. Mit dem Hawaii-Slot ist es leider nichts geworden, da fehlen dann doch noch 8 Minuten. "Brutal stark besetzt" trifft es als Beschreibung für das Starterfeld wohl ziemlich gut. Aber auf ein Wort, Hawaii: Wir sind noch nicht fertig! I'll be back!

Einen besonderen Dank an die Post-SV-Supportcrew (AlexanderVadim,Christian und Michael) die trotz EM-Hangover alles an der Strecke gegeben hat, meine Eltern die sich kaum eine Langdistanz von mir entgehen lassen und natürlich meinen Schatz, den ich immer zuerst höre bevor ich sie am Streckenrand sehe! :)

Ironman FFM 2016

Moving HMAC generation in Ruby out of the way to post to the Known API

2 min read

As I'm currently trying to post something through the Known API to my
site I have to dive into [HMAC](https://en.wikipedia.org/wiki/HMAC) a bit.

It's actually not that complicated and Phyks has laid out all the necessary steps to use the API in his excellent [article](https://known.phyks.me/2015/publishing-through-the-known-api).

However, buildung the HMAC somehow it didn't seem to work when I used something like

```ruby
statusurl = '/status/edit'
hash = OpenSSL::HMAC.digest('sha256', apikey, statusurl)
hmac = Base64.encode64(hash)
```

to generate the value. It showed up correct on screen, but my HTTPS request turned resulted in an HTTP 400 reply.

Lo and behold, after some debugging with ```http.set_debug_output($stdout)``` I found the culprit. ```encode64``` adds a newline at the end (as by the spec) which, put into the HTTP header, breaks your request.

Thanks to the pointers in [StackOverflow post](http://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby) there's ```strict_encode64``` to the rescue. So

```ruby
statusurl = '/status/edit'
hash = OpenSSL::HMAC.digest('sha256', apikey, statusurl)
hmac = Base64.strict_encode64(hash)
```

will give you an HMAC that makes your HTTP request happy. Or you can strip the newline using ```gsub```, your call. Yay, now my requests are working. On to the next step!

Tags:

Known up and running

1 min read

Now testing to post to Twitter.