Ward Bekker

A solutions engineer based in Amsterdam

about me

images

Hi there! I am a solutions engineer with 17+ years experience in software development. Let’s talk about big data, hadoop, software engineering, Erlang, Running and more over a nice cup of coffee. More about me

Erlang ‘One Weird Trick’ Goodiebag

I’ve asked the Erlang twittersphere what they think every Erlang developer should know about. The result is this Erlang random goodiebag. I would love to hear your ‘One weird trick’ in the comments!

written in Erlang Read on →

5 Great TODO Apps for Mac

There are plenty of great TODO apps out there. If you want stop procrastinating and become super productive, you probably should be using one of these desktop Mac apps.

The following list is my selection of 5 great TODO apps, designed for your Mac desktop.

written in apps, productivity, todo Read on →

5 Great Writing Apps for Mac

There are plenty of great writing apps out there. If you want to focus on writing, you probably should be using one of these desktop Mac apps.

The following list is my selection of 5 great writing apps, designed for your Mac desktop that sync nicely with their iOS counterparts.

written in apps, productivity, writing Read on →

My 5 Tips for New Runners

Yours truly started running just over 7 months ago with the goal to get into shape. I dropped 17 KG since and now really enjoy running. I even finished my first 10 miles race! (1:21:05). Here are 5 things that I learned in the process;

written in running Read on →

Erlang/OTP 17.0 on OSX Mavericks With WX and a Working Observer

Update April 15 – 2014: Erlang/OTP 17.0 with a working WX library is now also available through Homebrew: brew install wxmac erlang. HT @dhc_

This post is an update of HOWTO: “Erlang R17-RC2 on OSX Mavericks with WX and a working Observer”.

The best Erlang yet

Today’s Erlang/OTP 17.0 release is ‘the best Erlang yet’ and contains two significant language changes: Maps and Named arguments in funs.

Erlang uses wxWidgets, a cross platform GUI library for it’s GUI tools. This build dependency was hard to get working pre-17, especially for 64-bit Erlang. However, 17.0 brings double rainbows and care bears for everyone that reads this HOWTO. So Enjoy!

nonode@nohost

Set correct Xcode path for compilation

As far as I know you need have Xcode install to compile Erlang from source. You can download Xcode via the Mac App Store

If you have multiple versions of Xcode installed (beta’s for example), make sure the Command Line Tools are installed and are pointing to the correct Xcode version.

Initiating an install of the Xcode Command Line Tools:

1
$ xcode-select —install

And verify that the CL-tools point to the correct Xcode install

1
$ xcode-select -s /Applications/Xcode.app/Contents/Developer

Install wxWidgets

wxWidgets is a Cross Platform GUI library that’s used by Erlang for applications like Observer.

Execute this line and get some coffee, walk the dog, take out the trash and/or play with your kids. Compilation takes a while.

1
2
3
4
5
6
$ curl -O http://optimate.dl.sourceforge.net/project/wxwindows/3.0.0/wxWidgets-3.0.0.tar.bz2
$ tar xvjf wxWidgets-3.0.0.tar.bz2
$ cd wxWidgets-3.0.0.tar.bz2
$ ./configure —with-cocoa —prefix=/usr/local
$ make && sudo make install
$ export PATH=/usr/local/bin:$PATH

Check that you got the correct wx-config

1
$ which wx-config

Install kerl

Kerl is a utility that helps you build and manage multiple instances of Erlang/OTP.

Create ~/.kerlrc. I use $ vim ~/.kerlrc.

Add these lines:

1
KERL_CONFIGURE_OPTIONS="—disable-debug —without-javac —enable-shared-zlib —enable-dynamic-ssl-lib —enable-hipe —enable-smp-support —enable-threads —enable-kernel-poll —with-wx"

Build & Install Erlang with kerl

1
2
$ kerl update releases
$ kerl build 17.0 17.0

For a 32-bit Erlang prefix kerl build with CPPFLAGS:

1
$ CPPFLAGS="-arch i386" kerl build 17.0 17.0

Install:

1
$ kerl install 17.0 ~/erlang_17_0

Activate:

1
$ . ~/erlang_17_0/activate

And bliss out on your new wx-enabled Erlang:

1
$ erl -s observer start

written in Erlang

Your First Erlang Program (in Style).

Always wanted to learn Erlang? Let’s create your first Erlang “Hello World” program in style!

In this HOWTO I’ll show you how to setup a bleeding edge Erlang development VPS and how to run you first Erlang program.

Main ingredient: Cores

Erlang’s main strength is it’s concurrency support. It likes cores, so for our ‘Hello World’ program we obviously need cores. Lot’s! Not 4, not 8, 20!

Create an account on Digital Ocean if you don’t have one yet (love them) and we’re going to boot up their biggest instance. It’s a steal at less than 1 dollar per hour. Just make sure you destroy it when done.

64GB and 20 cores will make our Hello World so snappy!

Fullscreen%2029/03/14%2021:36

  • Pick a datacenter location near you.
  • Select the latest version of Ubuntu: 13.10 x64.
  • Create the Droplet.
  • And ssh to your Droplet with the credentials received from Digital Ocean: ssh root@your_ip_address.

Bleeding Edge Erlang

We’re going to compile Erlang from it’s github repository master branch, At the time of writing it’s a few commits after R17 release candidate 2 which comes with a Hipe LLVM backend, maps and named funs. If that doesn’t make any sense, no worries, just remember it’s the fastest Erlang yet. And fast is good.

Install the required Ubuntu packages:

1
$ apt-get install tmux build-essential emacs24 git-core libncurses5-dev libssl-dev autconf htop

Fire up Tmux:

1
$ tmux

Install Kerl, a tool which makes building and switching Erlang versions easy.

Let’s add some good configuration options for our Erlang installation

1
$ emacs .kerlrc

And add

1
KERL_CONFIGURE_OPTIONS="—disable-debug —without-javac —enable-shared-zlib —enable-dynamic-ssl-lib —enable-hipe —enable-smp-support —enable-threads —enable-kernel-poll"

And because we can, we forge our Erlang installation on 20 cores. Muahahaha.

To see those cores sweat for you on compilation, create another tmux window CTRL-b c and run htop.

Fullscreen%2029/03/14%2021:52

Besides the eye candy, compilation finishes under 5 minutes on a 20 core Digital Ocean Droplet. Whoop!

To start compilation of Erlang:

1
$ export MAKEFLAGS=-j20 && ./kerl build git git://github.com/erlang/otp.git master erlang_llvm

After compilation we need to install the build and activate it:

1
2
$ kerl install erlang_llvm erlang_llvm
$ . ~/erlang_llvm/activate

Great! We are now ready for our Pièce de résistance.

Just say: Hello!

Real Erlang hacker use Emacs, so let’s setup Emacs for Erlang development.

Fetch a good base config for Emacs:

Start up Emacs emacs. It will complain that it can’t find projmake-mode. Let’s fix that:

1
[ESC]-x package-install [Enter] projmake-mode

Exit emacs:

1
[CTRL]-x [CTRL]-c

Start up Emacs again emacs. Great! We can finally start writing our “Hello World” program. Oh, not, wait. First, we create a projmake file. The file is needed by Projmake-mode, a Flymake inspired mode that compiles your program on every save and shows build errors and warnings inline. Really useful!

1
[CRTL]-x f projmake [Enter]

Add these line and save the file

1
2
3
(projmake
 :name  "Hello"
 :shell "erlc +native hello.erl")

Ok, now we can really start writing our “Hello World” program and put those 20 cores and 64GB RAM to good use.

1
[CTRL]-x f hello.erl [Enter]

And type or paste:

1
2
3
4
5
module(hello).
export([just_say/0]).

just_say() –>
    io_format("hello~n", []).

And save with [CTRL]-x [CTRL]-s.

Whoops. We made an error as projmake-mode shows:

Fullscreen%2029/03/14%2021:24

Replace io_format with io:format and save again. That fixes our error!.

Let’s run our program. Fire up the Erlang shell with:

1
[ESC]x erlangshell

Load the hello module with:

1
1> m(hello). [Enter]

And run you first Erlang function….

1
2> hello:just_say(). [Enter]

Bliss!

Congratulations. You now have a powerful Erlang development environment in your hands.

Check out A beginners guide to Erlang to continue your Erlang binge.

written in Erlang

Selenium Webdriver for Erlang Quick Start

Selenium is the industry standard for automated testing of web applications. Together with Webdriver, a ‘remote control’ API for all major browsers, it enables you to create robust integration test for the browser.

The great people of QuviQ, creators of the unique Quickcheck test framework, created an Erlang Webdriver client implementation (Github repository).

It’s trivial to get started with the following steps:

Step 1: Add webdrv to the rebar.config of your project

Open rebar.config in your favorite editor, and make sure webdrv is listed as dependency. I use a fork of the original repository that support rebar:

1
2
3
{deps, [
    {webdrv, "", {git, "https://github.com/ehedenst/webdrv.git", {branch, "master"}}},
       ]}.

Step 2: Get and compile webdrv

Go to the root of your Erlang project and execute:

1
$ rebar get-deps compile

Step 3: Get & start the Google chromedriver

For this quick start we will be using the Google Chromedriver. Get the right package for your environment here. I’m now on a Mac, so:

1
2
3
$ curl -O http://chromedriver.storage.googleapis.com/2.9/chromedriver_mac32.zip
$ unzip chromedriver_mac32.zip
$ ./chromedriver

The last line starts up the Chromedriver server and if all went well, you should get the following output:

1
Starting ChromeDriver (v2.9.248307) on port 9515

Important! This server needs to be running during test execution.

Step 4: Your first Erlang webdrvr test!

Save the following module in src/random_org_test.erl. In this test we open a page, fill in a form, submit the form, and check if an expected piece of text is indeed present in the response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module(random_org_test).

compile(export_all).

include_lib("webdrv/include/webdrv.hrl").

define(CHROMEDRIVER, "http://localhost:9515/").

test() –>
    {ok, _Pid} = webdrv_session:start_session(test, ?CHROMEDRIVER,  webdrv_cap:default_chrome(), 10000),
    webdrv_session:set_url(test, "http://www.random.org/integers/"),
    {ok, Emin} = webdrv_session:find_element(test, "name", "min"),
    webdrv_session:clear_element(test, Emin),
    webdrv_session:send_value(test, Emin, "5"),
    {ok, Emax} = webdrv_session:find_element(test, "name", "max"),
    webdrv_session:clear_element(test, Emax),
    webdrv_session:send_value(test, Emax, "15"),
    webdrv_session:submit(test, Emax),
    {ok, PageSource} = webdrv_session:get_page_source(test),
    string:str(PageSource, "Here are your random numbers") > 0,
    webdrv_session:stop_session(test).

Step 5: Run the test

Run your test by opening up the Erlang shell..

1
$ erl -pa ebin deps/*/ebin

..and execute the test function

1
1> random_org_test:test().

You should see the Chrome browser opening in the background, quickly flashing some pages, closing, and on the Erlang shell the anticlamatic output ok.

Further information

written in Erlang