Bjoern Weidlich

I make computers do things in San Francisco

Read this first

Over-engineer your own file-backup solution

Until yesterday all my digital life was backed up on a physical drive using Time Machine. Occasionally I would feel guilty about that TimeMachine reminder that I haven’t backed-up in a while and would rummage through my desk for the external hd that I would occasionally use to backup my main laptop.

Lame.

I could have just decided to pay a service like backblaze but nah, I want to be in control of this data so I decided I was going to roll my own solution.

There are 3 main folders I care about, everything else is in a remote git repo. I want an encrypted/private s3 bucket, one IAM user should be able to put and get files from the bucket, and every 20 days I would like all the files moved to long-term storage in Glacier.

I had just started using Terraform in a limited fashion so I wanted to use this as an opportunity to tinker with it.

First up I created an empty git repo in...

Continue reading →


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 https://www.offensive-security.com/kali-linux-arm-images.

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 →


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 →