Sunday, November 1, 2015

Einmal Tennessee und zurück

"Put on my blue suede shoesAnd I boarded the planeTouched down in the land of the Delta BluesIn the middle of the pouring rain"

Chattanooga

Diese Zeilen aus dem Song "Walking in Memphis" von Marc Cohn, hatte ich im Kopf, als ich letzten Donnerstag mit dem Flugzeug in Chattanooga gelandet bin. Wow, wo bin ich hier gelandet? Alles irgendwie anders, langsamer, aber spannend und interessant. Chattanooga ist eine Kleinstadt, die wirtschaftlich stark gelitten hat, als die großen Industriebetriebe ihre Türen geschlossen haben. Viele gutbezahlte Arbeitskräfte haben ihren Job verloren und zu einer hohen Arbeitslosenquote geführt. Mehr als 20 Jahre hat die Stadt gebraucht, um sich von diesem wirtschaftlichen Untergang zu erholen. Heute hat Chattanooga den Tourismus für sich entdeckt. Ansonsten finden eine ganze Menge Sportveranstaltungen in Chattanooga statt. Die größte Veranstaltung ist ein Ironman.

Chattanooga Airport
Die orangenen Laufschuhe
Statt Lederschuhen hatte ich meine Laufschuhe an.
Downtown Chattanooga

Coco Cola in Chattanooga

Ein paar weise Worte.

Market Street Bridge über den Tennessee River

Sonnenuntergang am Tennessee River

Leider auch hier: Bausünden

"Kleine Kuchenauswahl" in einem lokalem Cafe
Ich war hier angekommen um an einer, ich möchte mal vorsichtig sagen, verrückten Veranstaltung teilzunehmen: ein Staffellauf von Chattanooga nach Nashville. Distanz ca. 200 Meilen (ungefähr 320 km). Teams haben entweder 12 oder 6 Läufer. Gelaufen wird die ganze Zeit. Egal wie spät es ist. Ankunft aller Läufer in Nashville ca. 24-30 Stunden später.
Mein Team bestand aus 12 Läufern und jeder von uns ist 3 mal in dieser Zeit gelaufen. Die zu laufende Distanz pro Läufer variierte zwischen 3 und 10 Meilen.

Jedes Team hat 2 Vans mit jeweils 6 Läufern. Ich war in Van 1 unseres Teams und der letzte Läufer der 6er Gruppe.
Ich bin das erste mal am Freitag um 14:30h unterwegs gewesen. 3.1 Meilen in der prallen Mittagssonne. Nicht meine Lieblingsbedingungen zum Laufen. Aber was solls. Immerhin hatte ich eine relativ flache und kurze Strecke zu absolvieren.

Mein nächster Einsatz war dann erst Nachts um 23:30h. Kurze und flache Strecke mit 2.7 Meilen Länge. Der letzte Lauf war dann am nächsten Tag um 9:00h. Diesmal 4.5 Meilen und mit ziemlich vielen Anstiegen. Immerhin war die Temperatur angenehm zum laufen.
Danach war ich aber auch froh, dass ich nicht nochmal Laufen musste.
Nach dem letzten Lauf. Fertig, aber glücklich.

Jo, genau das richtige nach dem Laufen: Zucker, Mehl und Fett in Kreisform. Auch als Donut bekannt.

Zieleinlauf in Nashville bei bedecktem Himmel

Lea und ich warten mit den anderen auf die Ankunft unserer 6 Läufer aus Van Nr. 2

Sehr coole Idee: alle unsere Medaillen ergeben zusammen eine grosse Medaille

Abendessen mit dem gesamten Team nach fast 30 Stunden

Die ganze Veranstaltung war sehr gut organisiert. Viele Helfer bei den Übergabestellen. Für die längeren Pausen wurden immer Schulen hergerichtet und die Turnhallen zu Schlafplätzen umfunktioniert. Auch in den Schulen waren sehr viele Helfer unterwegs. Sei es nun, um das Chaos auf den Parkplätzen zu koordinieren oder aber um Essen und Getränke in der Schulkantine zu verkaufen.

Drei Dinge sind mir aufgefallen, als ich in Tennessee war:

  1. Hier läuft die Zeit langsamer! Im Vergleich zur Bay Area, wo sich alles schnell bewegt, ist in Tennessee alles ein paar Takte langsamer. Aber das war sehr entspannend, obwohl die Wartezeit in Restaurants manchmal schon als grenzwertig lang zu bezeichnen war.
  2. Die Menschen sind hier sehr freundlich. Jemand hat mir gesagt, dass das die Southern Hospitality ist. Aufgesetzt und hinter der Fassade sieht es anders aus. Ich hab mich dort aber sehr wohlgefühlt und die Interaktion mit den Menschen war ausgesprochen nett.
  3. Es mangelt hier nicht an Kirchen!!!

Nashville ist cool!

Wirklich? Ja, ich finde schon. Die Stadt hat ein paar schöne Ecken. Für Unterhaltung ist auf dem Broadway gesorgt. Bars und Restaurants mit Live Musik. Country Musik ist nicht jedermanns Sache, aber es passt alles zusammen hier. Die Menschen haben Spass und die Stimmung war überall toll. Es gibt noch ein Football und ein Eishockey Team. Beide Teams haben ihre Stadien in Laufweite vom Broadway. Rundherum um den Broadway gibt es eine ganze Menge Geschäfte zum Einkaufen (Cowboy Hut und Stiefel gefällig?). Des Weiteren sind noch eine Menge Museen vorhanden. Allen voran die Country Music Hall of Fame. Leider war die Hall of Fame am Sonntag geschlossen und wir sind ins Johnny Cash Museum gegangen. Sehr interessant und in einer Stunde gut zu schaffen.
Der hippste und teuerste Coffeeshop in Nashville
Noch eine kurze Anekdote zum oben abgebildeten Coffeeshop: ich wollte für mein Team Kaffee besorgen, da wir vor dem Restaurant auf unser Frühstück etwas länger warten mussten (Ansage was 30 Minuten). Ich bin also schnell um die Ecke gegangen, hab dort ein paar Kaffee geordert und wollte dann schnell wieder zurück sein, damit die anderen ihren Kaffee trinken konnten solange sie in der Schlange draussen warten mussten. Nach 20 Minuten bekam ich eine Nachricht von meinem Team. Die Frage nach dem Kaffee musste ich verneinen und meine Bestellung hab ich per SMS übermittelt. Leider hatte ich nach 20 Minuten immer noch keinen Kaffee in der Hand. Kurz darauf hab ich den Kaffee bekommen und bin schnell wieder zurück zum Frühstückslokal. Schmunzelnde Gesichter bei meiner Ankunft. Der Kaffee war gut und teuer (Cappucino $5,50, Ice Cafe Latte $7,50) und hat ewig gedauert. Wie ich eingangs schon mal erwähnte: alles läuft hier langsamer als anderswo. Lektion gelernt.


Und zurück in die Bay Area

Die Kolumne in der New York Times heißt  "36 Stunden in xxx" (xxx=nimm irgendeine Stadt auf der Welt). Leider hatte ich weniger als 36 Stunden in Nashville. Ich hab ein bisschen was gesehen von der Stadt. Aber es gibt noch soviel andere Dinge zu entdecken, die ich mir für einen zukünftigen Besuch gemerkt habe. Also, bis bald mal wieder in Nashville. Dann mit etwas mehr Zeit.


Thursday, October 29, 2015

Install ownCloud on Synology NAS DS413

Here is a list of steps required to install ownCloud on a Synology NAS. I have a DS413 and I was able to install ownCloud on it. I don't know about the other Synology models out there. Let me know, if you succeeded to install ownCloud on any other model.

ownCloud is not part of the official Synology packet repository. You need to add the community repository to install packets from there.


  1. Log into the Synology admin site
  2. Open Package Center and open the Settings. Under Package Sources, add http://packages.synocommunity.com/ as a source (see screenshot). Click Ok to confirm the new repository.
  3. In Package Center, refresh the list of available packets by pressing the Refresh button at the top of the window
  4. Now search for MariaDB and install it. This is required to install Owncloud. Otherwise, the installation of ownCloud will abort with an error. MariaDB is a fork of MySQL and is one of two databases recommended by ownCloud. The other one is PostgreSQL.
  5. Next enable Web Station in the Control Panel. ownCloud is a webapp and needs the http server to properly work.
  6. Before we continue with the ownCloud installation, you need to create a new shared folder. The installation of ownCloud failed in the beginning, because this folder is required, but could not be created.
  7. Open the Control Panel and open Shared Folder. Create a new shared folder and give it the name ownCloud (this is the default during the ownCloud installation).
  8. Check off Hide this shared folder in "My Network Places". Nobody should modify any content in this directory. This belongs to the ownCloud installation!
  9. Change the permissions of the newly created shared folder. In order to grant ownCloud read/write permissions, select http from the Local Groups (in the Dropdown list on the left hand side above the table) and check the box in the Read/Write column. Press the OK button when done.
  10. Now search for ownCloud and install it.
  11. During the installation of ownCloud, you will be asked to enter the password for the root user. Leave this field empty. By default there root password is not set (this is not secure at all, but for demo purposes, this should be alright)
  12. After ownCloud was installed properly, click on the URL in the ownCloud overview page in the Package Center. In my case it's http://192.168.1.22/owncloud.
  13. Now you will be greeted with ownCloud's login page. Type in your admin password and log into your ownCloud installation. The administration is part of another blog post.

Summary

This is a list of steps to install ownCloud on a Synology NAS DS413. The steps cover the installation of dependencies required to run ownCloud. The administration of ownCloud is not part of this post.
I hope this will help anyone to successfully install ownCloud. Let me know if you have any questions or other constructive feedback.

Monday, October 12, 2015

What I've learnt today


Here is a list of things I have learnt today. Things to remember for myself and to reflect on.
  1. AppCode has a simple, yet very useful CocoaPods integration. Easily create a podfile and fill in your dependencies. AppCode will provide you with a button to install your dependencies. Bonus: if you remove a dependency from your podfile, AppCode will give the uninstall button. Keeps your project directory neat and tidy. You can do this on the command line too, but it fits perfectly into the IDE.
  2. Swift playground in XCode 7.0.1 on El Capitan 10.11 sucks! I had so many crashes in the playground, that I had to restart XCode several times to get it back working.
  3. Swift and Objective-C seem to have a "Love and Hate" relationship? Why, you might ask? I tried to use some library that was written in Objective-C with my Swift project. It took a good amount of work to navigate around those little compile errors and find alternative ways to use the library anyways. But it was painful and not fun at all. What I did? I created a custom XML deserializer for Alamofire with Ono.

Tuesday, September 1, 2015

1st Electron-Shell User Group Meetup


I went to the 1st Bay Area Electron-Shell User Group Meetup last Tuesday, 8/25/2016. The meetup was hosted by (WagonHQ) in San Francisco’s Mission district. It started at 6pm and was scheduled to last until 9pm. The nice folks at WagonHQ provided some food and drinks for all attendees.
The Agenda for this meetup is available (here).
There was a good crowd of interested engineers (between 40 and 60 people). Some of them were already using electron-shell in one or the other project.

The Talks

There were 4 tech talks for this event:
  • The History of Electron (Kevin Sawicki - Engineer at GitHub)
  • Integrating with Native Code (Paul Betts - Engineer at Slack)
  • Electron, React, and Haskell. Oh my! (Mike Craig - CTO at Wagon)
  • Making a web app feel native (Ben Gotow - Engineer at Nylas)
The talks covered different parts of app development and the specialities of building a cross platform desktop app with web technolgy. A lot of questions around styling, using node modules, write your own node modules, call C# APIs to integrate with Windows, call Objective-C to integrate better with OSX and app packaging (I might have missed something).
I’m looking forward to attend the next meetup. I think that some attendees might have tried electron-shell for their own projects and have some eperiences to share.

Tuesday, June 9, 2015

Simple date math in bash script


To catch up with my blog, I needed to extract data from a twitter feed. Usually I update the blog on a weekly basis. Since I didn’t find the time recently, I fell behind.
I was looking for a quick solution to download all the feed data at once. A bash script should be good enough.
The script that I use to extract the data from the twitter feed, expects a date argument in the form mm/dd/yyyy. The script will extract all data for the range [date - 7days, date]

Create the series of dates

I need to create a series of dates for several weeks. Given a start date, I’m going to produce new dates with a 7 day interval. The starting date is included in the series. Here is what I ended up with:
#!/usr/bin/env bash

set -e

# startdate in the form mm/dd/yyyy
startDate=$1
weeks=$2

for ((i=0;i<${weeks};i++)); do
    offsetDays=$((${i}*7))
    newDate=`date -j -v+${offsetDays}d -f "%m/%d/%Y" ${startDate} "+%m/%d/%Y"`

    startDateFilename=`echo ${newDate} | sed "s/\//-/g"`

    echo ${startDateFilename}
    # download the twitter data and redirect all output to that file
    exec &> weeklyTwitterData-${startDateFilename}.txt
    # call the script to extract the data from twitter stream
    coffee src/WeeklyStats.coffee -n ${startDate}
done

Since I didn’t want to do all the calendar math myself, I rely on the magic of the date utility. The line defining newDate is where the magic happens. Parsing a date ${startDate} in a given format %m/%d/%Y, adding $offsetDays to the parsed date and print out the new date in the format %m/%d/%Y.
That’s it.

Wednesday, May 13, 2015

Setup iTerm2, zsh, oh-my-zsh and powerline fonts on OSX

After waiting for a long time, I finally updated my Mac to OSX 10.10. Right after the installation, the usual tweaking process begins to make you feel at home. These are my notes to make the shell look good.
I wanted z-shell, oh-my-zsh and these modified powerline fonts to make the command prompt look cool.
If you want to follow these steps, it's recommended to have homebrew installed to install zsh-shell.

Ready, set, go!

Open your terminal and prepare to type.

iTerm2

The easiest way it to install iTerm2 with homebrew. Run this command:
brew install iTerm2

oh-my-zsh

Run this command curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

powerline

Powerline is a project that provides tools to customize the status line and command prompt of several applications. To achieve this, they use special glyphs that are available through patched fonts. These are the powerline fonts. Download the font from here and install it by double clicking. This will open the Font Book application and install the font for you.

Configuration

Now it's time to put everything together.
  1. Open iTerm2
  2. Go to Preferences -> Profiles -> Default -> General and type /bin/zsh into the text field next to Command (this will use zsh instead of your default shell)
  3. Go to Preferences -> Profiles -> Default -> Text and change the Regular Font and the Non-ASCII Font to 11pt Inconsolata-dz for Powerline
  4. open ~/.zshrc with your favorite text editor and change ZSH_THEME to agnoster
That's it. Make sure to start/restart iTerm to see all the changes.

Resources

oh-my-zsh Powerline change osx shell

Wednesday, May 6, 2015

Electron mystery on OSX solved

Do I look like an idiot? I don't know. But I felt like one for the last 2 days.


2 days ago I started to look into on a great project idea, to replace the Brackets Shell with Electron. Great idea! I wanted to contribute and fix issues that crossed my way. But, I followed the given instruction to clone the repo and setup all dependencies. After everything was download and in the right place, I ran npm start to bring up Brackets in it's new electron shell. But that first attempt failed with this error:
> Brackets@1.3.0-0 start ~/develop/fun/OSS/brackets-electron
> electron .

~/develop/fun/OSS/brackets-electron/app/shell-config.js:13
r CONFIG_PATH = path.resolve(utils.convertWindowsPathToUnixPath(app.getPath("u
                                                                    ^
TypeError: app.getPath is not a function
    at Object.<anonymous> (~/develop/fun/OSS/brackets-electron/app/shell-config.js:13:71)
    at Module._compile (module.js:418:26)
    at Object.Module._extensions..js (module.js:436:10)

I was wondering, if there was something important missing in the setup instruction, I simply made a mistake or my system config was tricking me. After checking with the guys who started that effort, I was left with this weird error.

I started to research and looked for others having the same issue, but I couldn't find anything. Okay, it has to be my machine setup. Back at home, I started to setup everything on another machine to see if it works there. The result was the same! The error showed up on a different Macs, with a different OSX versions.

I went back to our slack channel and carefully mentioned, that I'm still not able to get it running yet. Someone replied, that I can install Electron globally and try it again. But this turned out to be a red herring. Nothing has changed and it was really frustrating, since nobody else seemed to have these issues on OSX. I promised them to help, but I could even review and test pull requests.

I did some more research and came across this great blogpost from Thorstenhans. He provided a boilerplate project for an app that uses Electron. I was so happy. I followed his instructions to create a clean app. Everything went fine and I was excited because it's using es6. Unfortunately, the result with Electron was the same.

I left a comment for the blogpost asking, if he has encountered this issue before. Nothing worked for me as expected. So, it must be my machine I concluded. But two machines at the same time?

I mentioned my inability to launch Electron on OSX, briefly in the slack channel for electron-brackets. I felt like an idiot at this point. Somebody who distracts everybody with some nonsense. Nobody had an idea what might help to resolve this misery to help me getting started.

Since the electron-brackets version on Linux seemed to work fine, I decided to pull my Linux VM out of the drawer and give it a try. I cloned the repo, installed everything and typed npm start at the console. Guess what? It worked! I was happy. That is awesome and I'm finally able to help.

But I wasn't happy that my day-to-day machine didn't play well with me. I had a conversation with Thorsten Hans (look at the comments here). He solved another mystery for himself along the way, but I didn't make any progress.

Long story short, I started to get rid of my nodejs installation, install nvm from scratch and hoped to resolve the issue. No luck. But then I inspected the environment variables for anything nodejs related and I found NODE_PATH. It seemed somehow messed up. This post recommended to undef NODE_PATH to solve another issue. But it helped me too. npm start is finally working and the biggest mystery, that let me look like an idiot was resolved.

Thanks

To Thorstenhans for the back and forth to help me resolve the issue. Thanks to Andrew MacKenzie to mention often enough, that the Linux version is doing a good job for him.

Friday, January 2, 2015

Something I Learnt About sed

Note: I’m writing this down to remind myself for the next time I’m using sed and any kind of regex.

I was working on some very simple task: replace a string in a file with a different string.
All of this should happen on our build machine during the product build. Nothing too fancy. But then I got bitten by different versions of sed available on the build machines.
We build our product on OSX, Windows and Linux and I had to realize, that the regex I used, didn’t work with every sed version on the build machines.

My Regex Confusion

To make it clear: I’m not a regex guru. I use it for simple things. When it get’s complex, I usually consult some tools like regex101.com to get it right.
I started with this simple regex to replace the number after the - (the number of commits). The buildnumber looks like 1.0.0-12345.
Here is the command I started with
`cat build.prop | sed "s/(brackets_build_version=\d+.\d+.\d+-)(\d+)/\1${NEW_COMMITS}/" > build.prop.new`.
The result:
`sed: 1: "s/(brackets_build_versi ...": \1 not defined in the RE`
Okay, that doesn’t help that much. After some research I have found the solution: -E needs to be added to the command.
Okay, that error went away, but the replace didn’t work either. Hm, now I had to debug the Regex and find the issue.
After several rounds of experimentation, I started to read the documentation for re_format. That explained a lot: there are modern RE and obsolete RE (they are sometimes referred to as Basic Regular Expression (BRE) and Extended Regular Expression (ERE)), that mainly exist for backward compatibility. They are not as powerful as the modern RE and lack some features.
The last working version looked like:
`cat build.prop | sed -E "s/(brackets_build_version=[[:digit:]]+.[[:digit:]]+.[[:digit:]]+)-([[:digit:]]+)/\1-${COMMITS}/"`
This worked! Heureka.
But wait, why do I have to used [[:digit:]] instead of the much shorter \d+? I don’t know and probably I will never find out. 

Deploy on Build Machines

Happy, that I finally found a solution that worked on OSX. I totally forgot about the other OSses. Once I made the changes and started the build, it failed on Linux and Windows.
WTH? What was I missing? Why doesn’t it even work on Linux? Quickly started my Linux VM and gave it try. The solution was simple: I had to call sed with -r in order to make it work.

Conclusion or What I have Learnt

sed behaves differently on different OS versions. This is probably no exciting news, but I thought I keep this as a reminder for myself.
Using bash or some derivative of it like cygwin or gitbash on Windows does make a difference for some tools. Especially sed comes in two variants: BSD and GNU.
OSX uses BSD and I guess linux and cygwin come with GNU. They might have different command line switched for the same option. So be careful and testing is always required.
Another difference is the Regex engine tha can be used. sed supports basic regular expressions (BRE’s) and extended (ERE or modern) regular expressions
As I mentioned bofore, enabling the extended regular expressions you need to call sed -E on OSX and sed -r on Linux and cygwin.