MongoFaker released

We are proud to release MongoFaker.

It is a small Scala Library which starts a MongoDB server in ~250ms.

All you have to do is supply some mongod executable inside your $PATH variable (on Debian/Ubuntu it is available automatically after installing mongodb), and you can start as easily as

import net.reactivecore._
val instance = MongoInstance.start(MongoConfiguration())
// MongoDB server up and running in a
// temporary test directory.

val port = instance.port
val address = instance.address

// Connect to port & address
// Test your code
instance.stop()

Hopefully it helps other developers saving some seconds on each integration test run.

CMake Presentation

Together with Manuel Herrmann I gave a short presentation of the CMake buildsystem at the Berlin C++ UserGroup on 21.01.2014.

The slides are online, you’ll find them here: CMake.pdf

The first sample project was this OpenGL project from Manuel.

The second sample was a small math library called smallcalc I wrote for µoscalc on iPad, demonstrating cross platform compilation to iOS and Android.

Thanks to Manuel.

Android: Bubble Chain Reaction

Bubble Chain Reaction is online. Its a small turn based game written in Scala for Android, demonstrating Scalas Matureness for Android Development. You can play it with 2-4 Players or against the computer. Two players have to place bubbles inside a field of 3×3 (or bigger). Once there are enough bubbles in a field, it explodes and the player will own all the neighbor bubbles. This may lead to chain reactions. The player owning the whole map will win the game.

There are no needed permissions and the app contains no Ads.

Have fun with it.

device-2013-09-12-180221device-2013-09-12-180348

Note: there is a similar game called Chain Reaction in the Play Store (this happens if you look for a nam just before you release ;-) ). The rules are similar, but my variant needs one more bubble to explode a field. The game idea howewer is somewhat older, I saw the Game running on a KC 85/4 in the 90s.

Scala 2.10/Android SBT up and running

Some notes after spending the whole day how to get fxxxxing Android+SBT+Scala+IntelliJ up and running.

  • Setup the Android SDK, set all necessary paths etc. Don’t forget to install the all relevant API Versions (See Android Doc)
  • Setup IntelliJ for Android Development (See Stackoverflow)
  • The documentation of fxthomas seems to be the most accurate: http://fxthomas.github.io/android-plugin.
  • Versin 0.7 of the SBT-Plugin just released; grab it https://github.com/jberkel/android-plugin It’s necessary to compile it and to deploy to local repository
  • If you need Intellij-Support, you’ll need fxthomas’ idea plugin fork as the current version is broken for Android. Get it here https://github.com/fxthomas/sbt-idea. You have to compile it and it needs the dependency to android-plugin above. If it doesn’t find 0.7-SNAPSHOT, rename the dependency in sbt-idea to 0.7 (the name just changed)
  • Now you can start with your Android Project, I recommend this template https://github.com/fxthomas/android-scratch.
  • Add the idea plugin you compiled above to to project/plugins.sbt
    addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.0-SNAPSHOT")
  • Try out android build and running
    emulator-start [emulatorname]
    start

End of Life for Schneeflocke Service

In the next days I will shutdown the main schneeflocke service. The need for secure Friend-2-Friend-P2P-Applications is decreasing, as servers/webspace get cheaper and cheaper and its now perfectly possible to share big files encrypted via DropBox and co. Less than 10 people are constantly using the sflx.net Service. Thank you for your support and see you on the next project.

The Sourcecode of the Schneeflocke will still be available at GitHub. If you have your own Jabber server you can always use the Schneeflocke client with it.

In the end I am still happy with the project as it taught me a lot

  • Asynchronous Networking in C++: The code contains a simple HTTP Client, a XMPP client, XMPP/BOSH, a new P2P-JSON-Protocol, simple NAT-Traversal Routines etc.
  • Multi Platform Development The code compiled to Win32, Linux and Mac (never released due to some bugs).
  • NoDB, function language Software Architecture: To get everything together there was a Scala Lift Based Web-Application to enable users to register, a MongoDB-based User database and a ejabberd-based Jabber Service for bootstrapping P2P Application. I won’t open source the server stack as it is just to weird.
  • Agile Software Management Schneeflocke used continuous Integration for 2 Platforms (Linux, Win32) and was build (mostly) test-driven. Parts of the code are automatically generated in order to speed up network protocol development and to avoid any DRY violations.

Thank you all and let’s look forward to the next big thing!

Teaching CMake’s Eclipse Plugin C++11

Using CMake you usually enable C++11 using a compiler flag like:

#CPP0x
set(CMAKE_CXX_FLAGS "-std=c++11")

This works well but seems not to be compatible with the Eclipse CDT4 Plugin. All include paths and predefined macros will be set to C++-03, thus Eclipse will miss new features like std::shared_ptr.

The problem is, that the Eclipse Include Paths and predefined Macros are set by a compiler call directly. This happens inside /usr/local/share/cmake-2.8/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake.

...
execute_process(COMMAND ${_compilerExecutable} ${_arg1} -v -E -x ${_lang} -dD dummy
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
  ERROR_VARIABLE _gccOutput
  OUTPUT_VARIABLE _gccStdout )
...

How can this be avoided? The simplest solution (as long as C++11 is not the default) seems to either patch CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake or wrap the compiler inside a Shellscript:

#!/bin/bash
# Place this in $HOME/bin/g++11 and make it executable
/usr/bin/g++ -std=c++11 "$@"

Now you can rerun CMake with the new “Compiler” and voila, Eclipse recognizes the new C++11 types.

cmake ../your_source_dir -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_COMPILER=g++11

Ubuntu on Macbook Air, rEFIt Problems

Just finished ~20h to get Ubuntu 12.10 running on a 2011 MacBook Air. The problem was that rEFIt does not work if your main partition is encrypted using FileVault2 (OSX’ Disk Encryption).

The solution: Install rEFIt in the hidden main system partition like documented here. Install Ubuntu 12.10 (64bit) with boot manager on EFI boot partition.

What I also tried:

  • Installing rEFIt on another HFS+ Partition, no luck doesn’t show up when booting and Alt pressed
  • Ubuntu 12.04 Mac – AMD64 with boot grub partition as documented in the Wiki, no luck doesn’t show up

Update: The bootloader seems to be removed after a couple of reboots :/

small platform library

You’ll find a new C++-Library called pcore on GitHub. It consinsts of some generic multiplatform code snippets shared by multiple projects from me and has no special dependencies (except boost headers). The code is copied from the almost abandoned Schneeflocke Project and some other private code bases. In the moment you’ll find:

  • An easy Byte Array wrapper
  • Some math primitives
  • A very simple Logger
  • Some functional programming helpers like ABind and MemFun (it’s like boost::bind for people like short readable stacktraces)

As I became a Dad (yipiee) I am a bit busy so it’s better not to promise any more features :)

smallcalc library released

Smallcalc Library is released :) Check it out on Github. This time it’s Apache Licensed, do with it whatever you want.

Its the library which empowers µoscalc on iPad. An update for µoscalc is currently for review at Apple.