Convert ASCII to Hex and vice versa in C and Excel VBA

In Downloading Binary Data, for example Boost C++ Library I already complained about some company policies regarding the transfer of binary data. If the openssl command is available on the receiving end, then things are pretty straightforard as the aforementioned link shows, in particular you then have Base64 encoding. If that is not the case but you have a C compiler, or at least Excel, then you can work around it.

C program ascii2hex.c converts from arbitrary data to hex, and vice versa. Excel VBA (Visual Basic for Applications) ascii2hex.xls converts from hex to arbitrary data.

To convert from arbitrary data to a hex representation

ascii2hex -h yourBinary outputInHex

Back from hex to ASCII:

ascii2hex -a inHex outputInBinary

Continue reading

No YouTube Videos on Google Chrome v50

After upgrading to Google Chrome version 50 I could hear sound in YouTube videos, but no images/video. At first I thought this was a matter just affecting me. Now I noticed that another machine which I upgraded to Google Chrome v50 also lost the ability to watch video in YouTube. This other machine had a different graphic setup, so the problem was not something related just to my graphic-card configuration. The same problem is true for Chromium. For some time I switched to Firefox, which does not suffer from this hitch.

Luckily I had yet another machine which still had a working Google Chrome v49 browser. I used the very handy fakepkg program written by Gordian Edenhofer to make an Arch package from this v49 installation, see also pacman/Tips and tricks and the bacman command. And voilà, I can now downgrade to a usable Google Chrome version, whenever there is a need:

pacman -U google-chrome-49.0.2623.112-1.pkg.tar.xz

I called

fakepkg google-chrome

which after two minutes generated google-chrome-49.0.2623.112-1.pkg.tar.xz. These two minutes are mostly due to compressing with xz.

Google Chrome is in AUR. I recommend to set


in /etc/makepkg.conf, so AUR packages are cached, very similar to the “normal” packages.


pacaur -Syu --ignore google-chrome

to ignore updates for Google Chrome, or use IgnorePkg=google-chrome in /etc/pacman.conf, see Skip package from being upgraded.

See also Google Chrome Became a Performance Hog.

Upgrading from OxygenOS 1.0.3 to 2.1.4 on the OnePlus One Smartphone

This short guide describes how to upgrade your OnePlus One Smartphone from OxygenOS version 1.0.3 to 2.1.4. In this case the initial version of your OS is of no relevant importance — you can also upgrade from version 1.0.0, but see Installing OxygenOS 1.0 on the OnePlus One Smartphone and Upgrading from OxygenOS 1.0.0 to 1.0.3 on the OnePlus One Smartphone.

Before start we need adb and fastboot. On ArchLinux these programs are in android-tools:

pacman -Syu android-tools

Copying the OS image to the phone takes almost three minutes.

adb devices

time adb push /sdcard/
4842 KB/s (767726302 bytes in 154.821s)

real    2m34.909s
user    0m0.007s
sys     0m0.683s

Upgrading from OS 1.0.3 to 2.1.4 is apparently not possible by using TWRP. OxygenOS 2.1.4 for the OnePlus One says
Continue reading

Performance Comparison C vs. Lua vs. LuaJIT vs. Java

Ico Doornekamp on 20-Dec-2011 asked why a C version of a Lua program ran more slowly than the Lua program. The mentioned discrepancy cannot be reproduced, neither on an AMD FX-8120, nor an Intel i5-4250U processor. Generally a C version program is expected to be faster than a Lua program.

Here is the Lua program called lua_perf.lua:

local N = 4000
local S = 1000

local t = {}

for i = 0, N do
        t[i] = {
                a = 0,
                b = 1,
                f = i * 0.25

for j = 0, S-1 do
        for i = 0, N-1 do
                t[i].a = t[i].a + t[i].b * t[i].f
                t[i].b = t[i].b - t[i].a * t[i].f
        print(string.format("%.6f", t[1].a))

It computes values for a circle.

Continue reading

Performance Comparison of mmap() versus read() versus fread()

I recently read in Computers are *fast*! by Julia Evans about a comparison between fread() and mmap() suggesting that both calls deliver roughly the same performance. Unfortunately the codes mentioned there and referenced in bytesum.c for fread() and bytesum_mmap.c for mmap() do not really compare the same thing. The first adds size_t, the second adds up uint8_t. My computer showed that these programs do behave differently and therefore give different performance.

I reprogrammed the comparison adding read() to fread() and mmap(). The code is in GitHub. Compile with

cc -Wall -O3 tbytesum1.c -o tbytesum1

For this program the results are as follows:

Continue reading