Bjoern Weidlich

I make computers do things in San Francisco

Read this first

Setup Kali Linux on Raspberry Pi

Here is how you setup Kali Linux on a Raspberry Pi

Format your SD card to FAT32(exFAT) using Disk Utility then download the image for you pi model

openssl sha1 kali-2.1.2-rpi2.img.xz 

Compare it with the sha1 next to the version you downloaded

To uncompress the downloaded xz file you will need to unxz it. (If you don’t have the utility then download it with brew install xz).

unxz kali-2.1.2-rpi2.img.xz

Find the name of your sd card disk using diskutil list. For me it’s /dev/disk2.

sudo dd if=kali-2.1.2-rpi2.img of=/dev/disk2 bs=512k 

This will take some time… If you get dd: /dev/disk2: Resource busy you will need to unmount your partition (not eject the disk!). Open Disk Utility and right-click on the partition, not the disk, and select unmount. Then re-run your dd command. Once the command completes, eject your disk

Continue reading →

Modern Java web app in 5min

Ruby on Rails has made it incredibly easy for beginners to setup full-featured web apps within hours. Initially a lot of the nitty-gritty is hidden behind generators. Generators utilities that help you generate new models, controllers, etc. They generate files and edit existing ones to make things easy for you. The team over at JHipster have now accomplished that for Java. Check it out. Another development in the Java world has made this “generator” approach much easier. JHipster leverages Spring Boot‘s extensive configuration options and exposes them to the user through its CLI. For example, switching an embedded jetty based project to embedded tomcat requires a one line change in a Spring configuration file.

I’m currently working on my own application stack and have gone back and forth between using Dropwizard or Spring Boot but I’m finally sold on Spring Boot after spending some time

Continue reading →

How my mom made me a better programmer

My mother is a very organized and tidy woman. Growing up in post war eastern Germany my grandparents had little money and made ends meet with manual labor in post war factories producing things like pots, pans, nails, screws, etc. Efficiency and organization was necessary to provide for 2 children.

Certain chores were done on certain days and at certain times. That’s just how it was. Chores weren’t as easy as taking out the trash. You wanted hot water? You better get the coals and light the boiler. Oh, you forgot to do that this morning, then you better go now, in the dark. Things couldn’t be done as last minute as today. We can now decide to take a shower at any time of the day or order food on our smart phone and have it arrive within 15min. Back then you had to create workflows that would eliminate burdens later when you really needed to do something unplanned.

Growing up, a lot of

Continue reading →

Spring Pitfalls

I enjoy working with Spring. It’s been very obvious from the first time I’ve with Spring that it’s extremely well thought out and solves problems in a very academy/computersciency way. Building your code around dependency injection makes it inherently more testable and forces you to really think about your interfaces and abstract classes. I have many things I love about the Spring ecosystem but in this post I want to discuss some of the pitfalls of overusing the flexibility that comes with the framework and offer some of my personal best practices. Please disagree with me on twitter @bweidlich! I would love to hear your take.

Monolithic Spring Contexts

Don’t do it. Think about the lifecycle of your context. Do you want to be able to refresh it, destroy it, alter it? It’s bad practice to bundle dynamic and static components in the same context.
Static components are your sessions

Continue reading →

Using Hazelcast and RxJava to build agnostic clients

I am currently refactoring a suite of services that are all Hazelcast cache instances and part of a cache cluster. One of my first steps was to look at client-service communication endpoints and see whether I can’t decouple clients and services some more to allow for a more flexible Client-Service framework built on top of Hazelcast Queues and Topics but more of that in next week’s post. For now lets look at the current clients and services. They all assume that communication happens synchronously. That lead to the first refactoring on the road to true Hazelcast client-service messaging bliss.

Clients should be agnostic of service implementation

Clients should not care whether the service call is made asynchronously or synchronously. Maybe we use synchronous REST calls in one place but asynchronous cache queue-based communication somewhere. As the framework developer I don’t want to

Continue reading →

Wrap a REST API with Retrofit

Building a type-safe wrapper around a REST API is a pain. You need to deal with separate HTTP calls, dynamic construction of query strings, casting to your data types, handling exceptions etc. Luckily the smart folks at Square released a tool called Retrofit to help you cope with those problems. Retrofit asks you to provide an interface to the REST API in the form of a Java interface along with some annotations. It takes care of all the HTTP calls, query string construction, and exception handling, and leaves you with some basic POJO creation. We will take a look at how to wrap the St. Louis Fed’s REST API to retrieve macro economic data. The first thing you do is create POJOS for each of the objects you would like to pass to your application.

Source code: Freddie

Create a simple POJO you want to populate with data

public class Series
    private String id;
    private String

Continue reading →