Sunday, December 27, 2015

An opinion on TDD

TDD (Test Driven Development) seems to be used a lot in technical and management circles, together with "CI", "scrum" and other agile-ish buzzwords. Since I've got an internet connection and the ability to throw my opinion into the wild, I think I'll do just that.



Saturday, December 26, 2015

Reusing std::thread objects

Sometimes it's useful to reuse a std::thread object - from a resource and design point of view. This would seem trivial, but since the std::thread was designed as a single use object, there are a few tricks to reusing it.



Sunday, December 13, 2015

Running a stand alone child process from a parent process

Sometimes it is necessary to start a process from within another process, whether it is for executing a command line utility or to create a peer process with which the parent process will need to communicate.



Detaching a process from the terminal

Sometimes it is useful to detach your application from the console terminal. It may be because you're building a daemon or simply because you don't want the application closing when the user ends his terminal session.



Sunday, November 8, 2015

C++: splitting strings

There are multiple ways of splitting or tokenizing strings in C++. I'll enumerate below four types that seem most used and/or useful.



Saturday, October 3, 2015

Uploading files with unknown size using the Google Drive API

The Drive API documentation is not very straight forward when it comes to uploading files when you don't know the size of the file. In this post I'll explain a way to do a chunked file upload when the file length is unknown.



Sunday, September 27, 2015

Sunday, September 6, 2015

Sending a custom video stream through WebRTC

WebRTC is used to create video call enabled p2p applications. By default it supports only local webcam and audio input to be sent to a peer. However, it might be useful to send a remote video stream to a peer - for example a RTSP stream from an IP camera.
In this post I'll focus on modifying the peerconnection_client example to send a remote RTSP stream to another peer.



Saturday, September 5, 2015

Building libjingle for Android

Libjingle is a C++ library used to create peer-to-peer connections for voice-chat applications. It is included in WebRTC and bundled inside the Chromium source repository.
There are a couple of web pages with instructions out there about how to build the library for Android, but none of them seem complete.
This is where this post comes in.



Friday, July 17, 2015

Tuesday, July 14, 2015

Building GStreamer-1.0-SDK for Android MIPS

GStreamer is a nice SDK with which you can create multimedia applications for a multitude of systems. My concern is primarily Android with RTSP and video playback.
The SDK is already available for Android for a couple of architectures (arm, armv7a and x86). No MIPS support though.
In this post I'll describe the steps needed to get a GStreamer-1.0 SDK for Android MIPS.



Tuesday, June 16, 2015

Integration with Amazon SNS for push notifications

Pseudocode for Android integration with Amazon SNS:
server call to register for push notifications with registration token and DeviceId
if DeviceId is already stored then
    call DeleteEndpoint
else
    call CreatePlatformEndpoint to create new ARN for this device 
    store new ARN, Token and DeviceId
endif
I know there are other algorithms for working with Amazon’s SNS (like this one) but this seems to be the simplest, and it also solves the problem with Amazon not disabling the ARNs when applications are re-installed.
This should work for iOS-SNS integration, but I haven't had the chance to test.

Wednesday, May 27, 2015

Using the BPG image format on Android

There's a new image format in town and it's called BPG (Better Portable Graphics). Well, it's not so new, as it's been introduced in 2014, but it's new enough that you can find little information about integration with different platforms.
For academic/experimental purposes I've made a small Android application to see the format in practice.



Sunday, May 10, 2015

SQL queries with optional WHERE parameters

There may be at some point a need to filter data based on some user input, which may or may not be available at application run-time. This is what we'll discuss in this post, in the context of SQL queries.



Sunday, April 26, 2015

Building JSONs using the POCO C++ library

POCO refers to a very handy set of libraries for C++. They are cleanly written, STL-like, easy to use and most importantly, free (Boost License). I've had a small encounter with these libraries, mainly the JSON module and I'll detail, in this article, on how to build a JSON and then how to parse a JSON object manually using POCO::JSON.



Monday, April 13, 2015

How to drop root permissions in C

Sometimes it is necessary to run an application with root permissions in order to do some elevated work like binding to ports lower than 1024 or writing to files in /var/log, etc.  After the elevated work is finished, it is good practice to drop the root privileges and continue with the execution path as a non-privileged user. The motivation is based on security reasons: if ever an attacker takes control over your application, it should not give him control over the whole system.



Saturday, April 11, 2015

Getting the stack trace programmatically in C

In some situations where applications run for a long period of time on remote systems, if the application crashes, there is little information about the crash: no core dump or valuable log available. In such cases it is useful to get and log the stack trace at the moment of the crash, thus having some more information in order to solve the problem.
Getting some information about the stack trace is possible using C, as we will see below.



Monday, February 16, 2015

Using boost.property_tree.ptree to store JSON data

A Property Tree in Boost is a data structure that can store information in a tree-like format. Each node having a key and a value. It can be used to store XML, INI, INFO and JSON formats. Maybe also other, but these are the most popular and they are supported by boost, with ready-to-use parsers.
The limitation for JSON handling, is that property trees do not support simple arrays, since all nodes are of key-value type.



Friday, February 13, 2015

Boost.Asio HTTPS client

The boost asio official documentation gives two examples of making HTTP requests and using SSL for a connection. However, none of these examples do a HTTPS GET request.
In other words, if you want to make a HTTP GET request over a secure connection, you need to combine the two examples.
The links to the examples are http client and ssl client.



Monday, February 9, 2015

How to generate a SHA1 hash in C++

Having been put in the position of generating password hashes (again), I thought I better write it down for posterity.
You can always write your own SHA1 implementation, but let's be serious, who wants that? Unless you're doing it for academic purposes, it makes no sense to reinvent the wheel when there are so many good implementations out there.

Among all the available libraries I chose to experiment with OpenSSL and boost.



Thursday, January 29, 2015

Creating TextView and ToggleButton list on Android

There are lots of tutorials out there on creating lists with multiple elements, but none seem to work out of the box, with listeners and all.
So this is my way of implementing a list where each row consists of a TextView and a ToggleButton.

The code was tested on Android Studio and is intended for SDK 4.4+ (because everything that is below 4.4 should disappear, in my opinion).



Sunday, January 25, 2015

Installing Android Studio on Ubuntu 14.04 LTS, Trusty Tahr 64 bit

Installing Android Studio on Ubuntu 14.04 64 bit can be quite tricky. Here's a list of issues I encountered while trying to get it up and running.

First get Android Studio from the official location here, and install it using the guidelines for your specific OS.