Get Raw Response Of Retrofit 2 Request

  • Posted on: 10 February 2018
  • By: robin

A widely discoussed problem on StackOverflow is how one gets the raw string from the respone of a Retrofit 2 request. The Approache with intercepting or using the enqueue() function does not work really well. Once the Reponse is created for the first time the enqueue function will throw an error that it can not get the content since it was already consumed. 

So but one now ? Maybe you know that Retrofit is using okhttp3. The cool thing is we can send requests directly with an OkHttpClient instance. 

Jackson replace field with a Custom Serializer

  • Posted on: 12 September 2017
  • By: robin
private class CustomValueSerializer extends StdSerializer<WebTemplateResource> {
   private final String url;

   public CustomValueSerializer(String url) {
      super(WebTemplateResource.class);
      this.url = url;
   }

   @Override
   public void serialize(WebTemplateResource res, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException {

      jgen.writeStartObject();
      Field[] fields = res.getClass().getDeclaredFields();
      jgen.writeObjectField("htmlUrl", url);

      for (Field field : fields) {
         try {

NetCat on Android - Send files from your phone to your computer with NetCatdroid

  • Posted on: 21 February 2017
  • By: robin

Strangely, it is still fairly complicated to transfer data from the smartphone to the computer. There are cloud solutions and bluetooth but thats still complicated or slow. But my friend and ex-colleague and me just release a first version of NetCatdroid. NetCatdroid is a netcat client for Android which allows you to transfer multiple files to your computer via netcat. Especially Linux and Mac user will love it, because nc is preinstalled on most systems. 

HowTo: Get notifications for ssh login attempts

  • Posted on: 30 January 2017
  • By: robin

Recently one of my accounts was hijacked. I was hacked. For the first time in my life. The first thing I did was changing all passwords and keys. But still I felt not save enough. For external accounts I can not do much but for my remotely acceptable computer I could (e.g. Allow Only public-key auth). One thing I came up with is Android Notifications (or email, sms, etc.) when a ssh session is created.

Mass assembly line for Raspberry Pis

  • Posted on: 18 January 2017
  • By: robin

In early 2016, we created a indoor positioning prototype for tracking stuff in a retail market. The Devices, that we used for it, were - of course - Raspberry Pis. But we needed about 100 of them. Here you can see, how we assembled them recorded in time lapse. 

Round 1: Called the Raspberry Pi Challenge: Were each colleague was assembling a Raspberry Pi as fast as possible. We took the time and tried to beat each other. 

 

Most useful code snippets for Raspberry Pi

  • Posted on: 17 January 2017
  • By: robin

I am using Raspberry Pi's since the first generation and I use them a lot. Over the time I collected a few snippets that I find really useful and want to same them with you.

 

Turn off display programmatically

I've got a Magic Mirror and by default its screen would be always on. Thats not necessary. It should be on when I am looking at it. So I added a PIR Sensor for motion detection and let it trigger the following python lines:

Erste Schritte mit dem Alexa Skills Kit (Anleitung) - Echo & Dot

  • Posted on: 24 November 2016
  • By: robin
Neue Skills für amazon Alexa Echo Dot

Seit dem Film Space Odyssey (Odyssee im Weltraum) und dem HAL9000 sind wohl viele von uns begeistert von dem Gedanken eine Unterhaltung mit einem Computer zu führen, ihm Fragen zu stellen und Informationen zu bekommen. Genau diese Voice Services sind zur Zeit auf dem Vormarsch. Amazon's Alexa, Google Home, ivee oder Cubic. 

Dies öffnet eine ganz neue Welt für Entwickler. In diesem Tutorial möchte ich euch anhand eines einfachen Beispiels die Entwicklung eines neuen Skills für Alexa beibringen.

Pages