Author Archives: commx

Apple iPhone 6S Battery Issues

When I bought my first Apple product back in 2001, I was thrilled to have something that looks great, has great capabilities and yet does a good job. It was an iPhone 4S, for which I paid around 630 € back then. However, that phone was not working well with recent iOS versions, since it’s hardware specs are somehow outdated (well, everything older than two weeks is out-dated nowadays).

So I decided to get an iPhone 6S. The presentation of the latest iPhone in Apple’s September Event looked promising. More processor power, more GPU power, 3D Touch and so on. A well designed device with current technology. Three days ago my phone was delivered. After unboxing, I charged it until the Battery was full and then started setting it up. I did not recover any existing backup.

The next day I encountered an issue with the device. While not fully set up (a lot of Apps I use were not even installed), the battery drained pretty quickly, while the phone was on Standby for 95% of the time. A full battery lasted for about 12 hours. Later that day I contacted Apple Support and told them that the battery was draining for no reason. They remotely tested the device via their diagnosis tools and told me that everything is fine. They recommended me to reset the settings. I did that. I even did a factory reset – without success. Again I contacted Apple’s support and the result was the same: The device is fine, all I can do is bring it in for service. Unfortunately the next free time slot in my local Apple Retail Store is in more than a week. So I might go and get it checked there to find out what’s wrong with it.

For me, it’s an hardware issue. With no apps installed, Bluetooth, location services and many background services turned off, the phone is not meant to consume a lot of energy at all. My OnePlus One lasts at least one and a half day with average use and a fully charged Battery. That’s what I expect. I know that Apple reduced the battery capacity for the 6S compared to it’s predecessor, but it shouldn’t be that dramatic.

Text Editor Comparison

Editors are the most important tool for software developers. A great editor can speed up the development of your project and make life easier in many aspects. There are many editors out there – some with the minimalism of vi or nano, other are graphical editors like Textedit, Notepad(++) and so on. The difference between an editor and a word processor like Microsoft Word/LibreOffice Writer is simple: Plain text editors just store the text as-is, without any formatting. Word processors may store the contents in binary format to preserve formatting. That way, word processors are not suitable to write code and configuration files.

Editors nowadays offer much more features than just text manipulation: Syntax highlighting, intelligent search/replace functionality, version control integration and many more. Below is a list of editors I think that are worth to be mentioned.

1. Sublime Text 2 & 3

Released in 2011, became one of the most popular editors out there. Sublime Text is by far the fastest editor out there, starts in no time and offers a lot of themes and extensions. It’s written in C++ with a Python backend. Available for Windows, Mac and Linux. A license can be obtained for $70. License: Commercial.

2. TextMate 2

The user interface seems to be inspired by Sublime Text 2/3. It’s written in Objective-C and available for Mac only. Still in beta (as of Feb 2015) and free of charge. Allows extension using Bundles. TextMate 2 is open source. Free.

  3. Atom

Atom is a editor from GitHub, written in HTML, LESS and JavaScript. It runs on Chrome’s rendering engine and renders the UI using web technologies. While it takes a few moments to start up, it runs very quick when launched. It can be extended using themes and plugins. Available for Windows, Mac and Linux. Atom is licensed under a MIT-style license. Free.


All of the editors above offer a great look and feel and a wide range of features, even if they’re just text editors. While I usually spend most time using a full-blown IDE, these editors can be a great alternative, especially when it comes to speed and efficiency. Atom is currently one of my favourites, because it uses web technologies on the desktop which I think is a great step towards the future of apps on the desktop. The reason is simple: Since it’s not written in a compiled language, it’s possible to run it on any system that offers a interpreter for the code. That way, Atom may work natively on FreeBSD while Sublime Text may only work with Linux emulation there.

PyCharm on OS X Yosemite

When installing PyCharm on Yosemite, you’ll get an error about missing Java Runtime 1.6. In fact, Apple has removed the Java Runtime version 1.6 on Yosemite. Don’t worry – you can install Java 1.6 using Java for OX 2014-001 from Apple. I strongly recommend doing it that way. You could also download JDK 1.7 or 1.8, but in fact that would break the signatures for the app bundle and as a result, updates won’t work anymore. Read more about that in Jetbrain’s blog.

This may also apply to other IDEs based on IntelliJ, such as WebStorm etc.

Another side effect on using Java 1.6 for IntelliJ products is font hinting: While it works fine with 1.6, it looks horrible on 1.7 and 1.8. This has to do with some Apple-specific adjustments in their Java distributions. You may also find the UI having the pre-Yosemite UI elements (buttons for example). Maybe the latest Java JDK/JRE do not support the new UI elements yet. This applies to any Java versions to date (1.6 – 1.8u25).

OnePlus One Pre-order

On October 28, 2014 OnePlus offered a public pre-order for their phone model “One”. People usually need an invite to be able to buy that phone. With the pre-order campaign, everyone were able to buy a phone within a one-hour period. However, their servers were totally overloaded and a lot of people were not able to place an order – even if they had prepared their order prior to the one-time time frame where the orders could be actually sent.

I also filled the order that day and pressed the submit button on 4:00 p.m. (CET). And my browser got a time-out. It was almost impossible to log in. Either the login was not available (HTTP 404), or there were OpenID login issues. After 40 minutes of trying, I was finally able to login. But not able to place the order. In the meanwhile, OnePlus announced that they are going to extend the pre-order time frame to three hours. I tried again and finally I was able to submit my order after 90 minutes.

On November 1st, I received an e-mail from OnePlus stating that my payment has failed:

Hello ., 

Your authorized payment for your OnePlus One pre-order has unfortunately failed! 

No worries though – just make sure you have a valid payment method set up in your PayPal account with sufficient balance. Also, please make sure your shipping information is correct in your order. We’ll try to complete the payment authorization once again in a few days.

I verified that my PayPal account is fine (appropriate payment sources have been set up correctly etc). No changes have been seen since then.

On November 12, 2014 I received an e-mail from OnePlus regarding my order: It was cancelled. The reason for that is the same as for the previous e-mail: The payment has unfortunately failed. When asking PayPal, they say it’s on OnePlus side and vice versa.

However, one good thing has been left: OnePlus promised to spend an invite because of the failed payment within two business days. The invite can be used to order a phone instantly. So let’s wait for another two days…

Update Nov 13, 2014: Today i have received an invite from OnePlus and was finally able to place my order again. Believe it or not: It worked instantly. Let’s hope that this is fixed for the next pre-order on Nov 17.

About the OnePlus One

Being around for some months already, the One is a smartphone by chinese company OnePlus. It consist of brillant hardware specs and an unbeatable price: For only € 299.00 you’ll get a phone that is almost as good as the iPhone 6 Plus, but for a much lower price. The One runs CyanogenMod, a Android derivate and will receive an update to the latest Android 5.0 (“Lollipop”) platform soon.

A second pre-order run will take place on November 17, 2014 on 5:00 p.m (CET). People have the ability to buy the phone within a one-hour period. If you plan to buy it, please make sure that you have PayPal account and it’s set up correctly to avoid issues like I had on the first pre-order.

python-rrdtool now available on PyPI

python-rrdtool is now available on PyPI. This simplifies the installation of the rrdtool bindings for Python when using pip or easy_install.

To install, you can simply use the following command:

# pip install rrdtool

python-rrdtool is a Python binding for rrdtool. It’s based on the original Python rrdtool binding distributed with the source code of rrdtool. This bindings work with Python 2.6+ and 3.3+.

YDNS: How to add a custom domain

We recently added support for custom domains to YDNS. That feature allows you to have YDNS manage your DNS records for your own domains. That makes YDNS not only offering free dynamic DNS services but also DNS services in total, since we added support for a few more record types as well.

I see many people adding domains the wrong way. Our system currently does not test whether a domain exists or not; it will frequently check its nameserver records for correctness. If they are not configured correctly, YDNS will disable those domains for further use (this will also happen if you have successfully validated your domains in the first place, but changed its configuration afterwards).

To correctly add your domain to YDNS, follow these steps:

Login to your Domain registrar’s Control Panel. It shall offer a section where you can change the nameservers which are responsible for your domain. If you cannot find this, you cannot add your domain to YDNS. In case you successfully found the appropriate section, replace your domain’s name servers with these two (and of course delete the previous one if they still exist after that):

After you’ve one that, you can add your domain in YDNS by navigating to the Domains page and use the “Add Domain” link on the right side on the top of the page. You may enter your domain name appropriately (e.g. “”) there. Our system will accept invalid domain names as well, but they’re deleted automatically after two weeks if they cannot be validated during that time frame.
Once your domain configuration is synchronized through the internet, our system will automatically flag your domain as being active and you can start using it.
If you have difficulties using this, please write to

yDNS receives some updates

Today I spent another update to yDNS: The support for multiple records per host. Before the update happened, only one record per host was allowed due to implementation restrictions. Now you can add an arbitrary number of records to each of your hosts. I also added support for three additional record types: CNAME, MX and TXT. The update resource for API calls has been updated as well: It now supports two new parameters:

  • content (alias for ip, can hold any content value for the record, not just IP adddresses)
  • record_id (if specified, the specific host is updated directly instead of guessing which record has to be updated)

I have plans to add support for custom domains. But that’s not final yet. Everyone is invited to test the new features in yDNS and report issues/suggestions by creating an issue on the project’s Github site.

python-rrdtool 0.1.1 released

An update to python-rrdtool was released today. Version 0.1.1 adds support for Python 2.x and fixes some minor issues that came up when porting the original Python binding for Python 3.

You can find more information at the project page on Github.


The installation of the module is pretty easy. All you need is to have rrdtool installed (and its headers) and of course the header files for your Python version.

Assuming you want to install it via pip, use

# pip install

You can also install it from sources by downloading the source and run

# python install

About python-rrdtool

python-rrdtool is a Python binding for rrdtool. It works with both Python 2.x and 3.x and comes with an object-oriented interface as well.

AES encryption with Python

For a current project I had to encrypt arbitary data with AES. AES is a symmetric-key algorithm that is even used by the U.S. government. That cipher is approved to be used for top secret information at the National Secret Agency (NSA). It offers key sizes of 128, 192 and 256 bits.

To encrypt a message with AES, you’ll first have to install PyCrypto. Its considered as the “standard” cryptography library for Python and is widely used. The easiest way to install PyCrypto is using pip:

# pip install pycrypto

Encryption of a message

You first have to decide which key size you’d like to use. The higher the key size, the more secure is the encryption, but it takes more computing resources to encrypt your message. While this is almost irrelevant for small usage, it might have a big impact if you plan to encrypt large amount of data with AES. In the following example we’ll use AES-256 with a key size of 256 bits.

The encrypt function expects the message as parameter, which is a bytes object. If your message is a string, you can convert it to a bytes object by using ‘my string’.encode(‘utf-8’). The second parameter is optional: The key you’d like to use for encryption. It must be a bytes object as well; if no key is specified, a random one will be generated. The third and last parameter specifies the key size in bits.

Since we’re using the CBC mode for AES, the message must be a multiple of key size / 8 . If your message is of length 3 and the key size is 256 bits, it must be padded with 29 bytes (256 bits / 8 = 32 bytes – 3 bytes of the message length). The padding is performed by appending the integer representation of the number of bytes that have to be appended to the message. In case if the message is 3 bytes long, we’ll append 29 times the byte x1d (hexadecimal representation of 29) to the message to get the padded message.

If no key has been specified in the function arguments, a random one will be generated. The key must be of size key size / 8  (32 bytes for AES-256, 16 bytes for AES-128). If you have a key that is shorter or longer than this, you could hash your key using SHA to get the appropriate number of bytes you need.

Next, we need an initialization vector (IV). We’ll use a random IV here. The IV must be block_size  bytes long (which is always 16 bytes). Once we’ve got the IV, we can create an AES object with the key, mode and IV. That AES object must be created later again when you want to decipher the message.

In the last step, we’ll encrypt the padded message. The encrypt function above will return a tuple that contains two items:

  1. The ciphertext of the padded message. The IV has been prepended to the ciphertext as we need the IV to decipher the message again
  2. The key that was used to encrypt the message

Decryption of a previously encrypted message

To decrypt AES encrypted ciphertext, you need to know how it was encrypted (which AES mode was being used, the IV and of course the key). For messages that were encrypted using the above function, this is easy, since we know all these parameters. For AES ciphertext that was generated by other programs, its rather hard to find out how it was encrypted to get the original message from it – unless you know the encryption parameters.

Start decrypting the ciphertext by passing the ciphertext (from encrypt()’s first return parameter)  and the key that was used for encryption (from encrypt()’s second return parameter).

We first define the unpad lambda function: It will basically remove the padding bytes from the original message. The length of bytes to remove from end has been specified in the padding function when the message was encrypted.

The IV has to be extracted from the ciphertext, as its a required parameter for the AES object initialized when using the CBC mode. The IV is the first 16 bytes of the ciphertext. Now we can reconstruct the AES object that was used to encrypt the original message.

To get the original message (also called plaintext in the code above), we have to decrypt the ciphertext with the reconstructed AES object. Then, the message is un-padded to remove the bytes that have been appended when the message was encrypted. Finally, only use bytes after the IV to get the original message.

A complete example

The example will encrypt a message and validate whether the decrypted version of the encrypted message will match the original message.

Python 2.x

Please note that the code will only run on Python 3. To use it with Python 2, you’ll have to use other (un)padding functions to achieve that. Below is the full program example as from above that will use with Python 2.x.

 Useful links