Atom editor and C++

With recent update of the Atom editor from GitHub, developing C++ application just started to be more pleasant. Enhancing the editor with packages which use clang tools enables features for easy and quick program writing, good for creating proof of concept applications.

Installation

On homepage for Atom, atom.io, there are precompiled packages to download as well as the source code. I use Linux Mint, which is based on Ubuntu and uses apt package manager, so below instructions add an apt source for easy updates.

Add atom ppa repository

sudo add-apt-repository ppa:webupd8team/atom

Update apt package db and install atom

sudo apt update && sudo apt install atom

Enhancing Atom with packages

Installing packages is very easy in Atom. For C++ development I use packages which use clang and clang tools, those need to be installed separately, check apt source for clang.

List of packages

autocomplete-clang
autocomplete-cmake
autocomplete-python
autocomplete-xml
hightlight-line
highlight-selected
language-cmake
language-cpp14
linter-clang
switch-header-source
terminal-plus

The autocomplete packages are very helpful when using STL components. Linter helps quickly discover mistakes, potential bugs when typing.

I use CMake to generate the appropriate build files, so that I can just type ‘make’ and rebuild the application. Autocomplete for cmake helps a lot when adding new instructions, which sometimes are long.

Snippets

For quicker program writing, I like to use snippets. I added two for now to help me quickly setup a new program folder. One with main function and one with CMake instructions.

Adding new snippets is easy. Edit -> Snippets…

'.source.cmake':
    'Minimum CMake File':
        'prefix': 'cmake'
        'body': '''
            cmake_minimum_required(VERSION 2.8.12)
            project(main)
            set(CMAKE_CXX_STANDARD 11)
            file(GLOB SRC *.cpp)
            add_executable(main ${SRC})
        '''

'.source.cpp':
    'Minimal C++ program':
        'prefix': 'cmin'
        'body': '''
            #include <iostream>

            using namespace std;

            int main(int argc, char *argv[])
            {
                $1

                return 0;
            }

        '''

To use above snippets simply type ‘cmin’ in a C++ file for the minimal C++ program and ‘cmake’ in CMakeLists.txt for minimal CMake instructions set needed to compile the project.

Check remaining transfer limit

For two month I have been using a Broadband network connection at home. It’s an LTE connection, it’s fast and reliable. In my flat the network signal is strong.

I use Linux Mint on my laptop, so naturally I wanted to use a modem, which is working under Linux. I have a Huawei E3276 USB modem, which is working just fine.

The Internet service would be great, however my ISP does impose a transfer limit. I’ve got a contract for 15 GB of downloaded data per month. It looks like not much, but it’s enough for my usage. I work in IT, so I have enough computer and Internet access during my work. At home I just read articles and blog posts, some Youtube movies or even a bigger download.

When the transfer goes off, my connection speed is limited to 512 Kbit/s. Fortunately the connection isn’t cut off completely or I don’t have to pay additionally for bytes downloaded above limit.

To quickly check how much transfer is remaining in current month I wrote a Python script. The scripts in order to work needs vnstat Linux command line tool.

$ ./transferLimit.py 
Downloaded:	11661.48 MiB
Limit:		   11500 MiB
Remaining:	 -161.48 MiB

The script is on my BitBucket: TransferLimitCheck

New LinkedIn profile

I recently wanted to change my default LinkedIn profile from Polish to English and it turned out that such feature does not exists. Even LinkedIn’s help center stated that at this moment there is no such posibility. One can create new, different profiles in other languages, but they are only secondary.

The thing is that the default profile is determined at registration, when I chose Poland it automatically set my default language to Polish.

I work in IT and in an international company, so I wanted to be seen internationally in English.

There is a solution to this. I created a new LinkedIn account with my other e-mail. At registration I chose Ireland, which caused to set my profile to be English. The area in which we reside can be changed later. Then I simply send a request to LinkedIn’s support to merge my old account to my new account. Unfortunately all my work experience was lost, but my connections were preserved, which was the desired outcome. I didn’t want to find all the people again.

After I received from the support that my accounts were merged, I filled my work experience data.

Tomasz Jakubowski in LinkedIn

Lerning Qt

When a software product is developed, not only the product is the outcome, but sometimes many tools, which support the development process. I work as an embedded software developer. In my work many times I faced situations, that I do the same operation or set of operations repeatedly. When there is opportunity, I try to automate. Of course, if there is time to automate, because sometimes it’s not so obvious what or how to automate. Many times I create small command line tools, which usage is known only to me. When working with other developers it’s better to share these tools, but not always command line is the best. When developing helper tools, it’s better to have a GUI. A developer just selects what he or she wants and does not have to think about what command and following option should be typed.

My weapon of choice is Qt library. Why Qt? Qt is portable, is very rich when it comes to various components, if the developed tool will be free, the library is also free. The library provides a layer of abstraction, it abstracts the underlying operating system’s functions and hardware. Building Qt application is very easy with Qt Creator, Qt’s IDE with very strong C++ awareness and a graphical UI designer, the GUI can be quick created and the logic, which will drive the GUI’s operations is written in C++.

I want to learn programming with Qt and C++, because I want to make standalone tools, which can be loaded on a USB memory. Qt applications can be deployed as normal, which use shared Qt libraries, installed separately in the OS or they can be deployed as standalone applications. Of course, the only thing is that a Qt application is compiled for a given target OS. If another target OS should be support, the application has to be rebuild for that OS.

Learning resources:

  • Book: C++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield
  • Book: Advanced Qt Programming, Creating Great Software with C++ and Qt 4 by Mark Summerfield
  • C++ Qt Programming video tutorials by VoidRealms
  • And of course examples from Qt Creator

First book is very simple, goes from basic, through intermediate to advanced topics. Second book explains on the topics more deeply. Exploring Qt Creator’s examples is very easy, on the welcoming screen is a tab with examples – Demos and Examples.

I was previously trying to tackle the topic of learning Qt using the first book, but I couldn’t get it how some things should be made in Qt Creator. I prefer some live example, so the video tutorials by VoidRealms are just great. He does all the examples in Qt Creator, so it is easier to get familiar with this IDE.

SGS2: Android updated to 4.1.2

I didn’t root my SGS2. I was waiting long for the Jelly Bean Android update for my SGS2 International. Today, finally, I plugged the phone to my computer and KIES informed me that there is a newer version of firmware for my phone. Of course, without waiting I installed it.

It took a little while to download the update data, but there was no problem with the installation. It went very smooth. Even my personal data and applications were on the device after installation.

So, for the first look at Jelly Bean I can tell: it is newer, better, much more beautiful. Look and feel was improved. I think that the device became more responsive for my interactions. The most awaited feature was the more rich notification area. I can now get rid of the power control widget, which took much space of my home screen. Also more configurable home screen and shortcuts on the lock screen are great features, which improve the usefulness of the device.

Android-Jelly-Bean-Logo

ODROID-U2: Google Play

My Odroid booted, the Android version is 4.0.4. Unfortunately, the Odroid image cannot contain Google Apps, just like other mods for phones or tablets. So there is no Google Play to download more applications. This isn’t a big problem, the GApps can be manually installed.

Thanks to Cyanogenmod team, there is a package with GApps. However, it cannot be installed like a standard apk, because it will crash.

Preconditions
Odroid has to be rooted. The USB debugging option in settings has to be turned on, because the GApps will be installed via adb.

When I connected my device and executed adb devices, I saw question marks instead of devices address and ‘no permissions’ message:

$ adb devices
List of devices attached 
????????????	no permissions

This indicates that there are no rules for my device in udev rules. At first I need to known what USB device is this, in particular the vendor and model values. To determine these options I run lsusb with my device still connected:

$ lsusb
Bus 002 Device 010: ID 18d1:0002 Google Inc. 
(...)

My device’s vendor id is 18d1 and model id is 0002. Now, this information needs to be added to udev rules configuration files.

I put this line into /etc/udev/rules.d/50-usb-serial.rules and restart udev:

SUBSYSTEMS=="usb",ATTRS{idVendor}=="18d1",ATTRS{idProduct}=="0002",MODE:="0666"

$ sudo service udev restart
udev stop/waiting
udev start/running, process 18099

$adb devices
List of devices attached 
BABABEEFBABABEEF	device

After this, the device is properly recognized.

Now, the GApps apk from Cyanogenmod wiki will be needed, the one for ICS (CM 9). Download it and unpack. Only the ‘system’ folder will be needed.

Installing GApps
Usb attached and device recognized, now we can install the GApps.

The system catalog on the device needs to be writable, so a ‘remount’ needs to be performed:

$ adb remount
remount succeeded

TO install GApps on the Odroid we need to push it with adb tool:

$ adb push ~/odroid/gapps-ics-20120317-signed/system /system

When all file were uploaded to the device, a reboot is needed:

$ adb reboot

Google Play login and first game
When the system booted, go to launcher and choose ‘Google Store’. Login with Google account and it’s done, now apps can be installed.

I installed a game to check how it will look like. The game is ‘Cordy 2’, it’s a platform game. Also I checked if the game pad works with the game. The pad works, however I need to remap the buttons.

game_set

game_screen

ODROID-U2: New HDMI cable

Finally I bought a new HDMI-HDMImicro cable. The new one is of a greater quality, it isn’t a super expensive cable from the most top shelf I could find, but it isn’t the cheapest either.

The damaged cable demotivated me a little, I couldn’t get myself to find it quicker. Also I wanted to read something about the HDMI and HDMI cables. I found out that Ethernet can be encapsulated through an HDMI cable. Instead of looking on an internet auction, I wanted to find a store at my city, so when it would be also damaged, I could give it back. I found store near my work and to my surprise, the store was specialized only in HDMI cables.

hdmi_cables

Old cable on the left, new on the right. Then new one feels a little better in quality then the older one. Even the gold color on the connectors is more intense.

I connected the new cable and it does not matter at which angle it is connected, the image is always crystal clear.

screen1_odroid

screen2_odroid

ODROID-U2

Recently in excitement about OUYA game console, an Android based gaming console, I bought ODROID-U2. This little piece of hardware is driven by an Exynoss 4412 chip, which can be also found in Samsung Galaxy SIII. It’s specs are similar to Tegra 3 platform. I want to play a little on Android, I already have Galaxy SII phone, on which I can play games from Google Play. I wanted a game console, which I could connect to my TV and control with a game pad. I also decided, that if I want to buy such thing, then it should enable me to install other operating system, so I can develop something on it.

from_website_odroid_u2

The company, which made ODROID-U2, is placed in Korea, so I had to wait for the package two weeks. It was my first package from such distant country. I was a little worried, because this is a little computer and that at the customs office they could hold it and say ‘No, this shit is dangerous, it has a droid icon on the box’. Finally, after two weeks and some phone calls with FedEx, it arrived.

All the stuff, which I ordered came in a small box. I bought the ODROID-U2, a power supply, a wi-fi adapter and eMMC memory module with Android preinstalled. I also bought a cheap USB game pad and a HDMI to HDMI micro cable.

whole_set

After quick unboxing, I connected everything and got horrified. The output on my TV was like from an old TV, which had a very weak signal. I was kind of disappointed. At first I thought, that the ODROID board or HDMI micro is damaged. I was looking at it with a magnifying glass for over an hour. I tried to connect it one more time and this time I moved the HDMI cable, I wanted to check if the image gets better when the connector is pressed, maybe it got loose or was not properly soldered. Moving the cable produced the right result – the image was now crystal clear. Then I realized, then the ODROID hardware is fine, but the cable could be damaged. It is very cheap one, cheapest I could get. I didn’t had any other HDMI micro supporting device, so I has to find another device. It was weekend, so I had to wait until Monday.

The screenshots are done with S2, so I could capture what I saw on the monitor. Doing a screenshot on the device would produce a good image, without the noise.

damaged_image_from_hdmi

I checked the faulty cable with Sony XPeria Arc S mobile phone and to my relief, the video connection was interrupted when I moved this cable. To be sure that the cable was indeed damaged I checked with a Motorola phone, the results were the same.

So now I have to buy a new HDMI cable. This time I will buy a branded and spend a little more on it.

Nevertheless, when connected at right angle, the image was correct, so first impression is great.

correct_image_from_hdmi

New e-mail address

Recently I was looking at my e-mail address and I thought to myself that, when I want to give it to someone to contact me then he or she will get the ‘funny looking face’ saying ‘what is this? seriously?’. The second thing is that I always had problems with providing it via phone call, I mean spelling the e-mail. I know that it is quite simple, but I live in Poland and when I using ‘Q’ then every time people get confused.

So I decided to create a new one. Creating e-mail address on Google servers with my name and surname wasn’t successful, all the combinations are already reserved.
I already use one ‘variation’ of my name on BitBucket and as it turned out this e-mail address wasn’t taken.

So my new, official e-mail will be:

tomzas.jakubowski@gmail.com

I will still use the old one, bu this will replace it in all accounts which are important to me.

I also added this information to my contact page on this blog.

Why I like Ubuntu/Linux software repositories

At home I have Ubuntu 12.04 installed on my Toshiba and I use it most of the time. Rarely I reboot my computer to Windows 7 to play some games. At work I am using a workstation with Windows 7.

Some days ago I wanted to update my software on Windows 7 at work. I use some tools, which are available for free, for instance Freemind, a mind mapping tool. In Ubuntu I would type a proper apt-get command in the terminal, but not Windows. In Windows I have to update it manually. Even when an application does provide an update mechanism, it has to be invoked manually. There is no central place or database where you hi ‘check for update of my installed apps’ and hit accept and then the software gets updated.

Some year ago, when using Linux, yes, it was a pain the ass to use some software. Now, with Ubuntu and apt-get, that problem was solved. If an application is available free it will be probably in the software repository. So, we get another extra feature: search for software. No need to search the internet for download site. When an application isn’t in main repository it can be in another repository, which can be  added to the list of sources, which apt-get searches through.

Some packages can be downloaded via a website (deb packages) and when installed, they add it’s repository information to apt-get’s config files. Next time apt-get packages list is updated, this repository will be checked too. Google Chrome does that for example, once installed apt-get checks for new versions of the web browser along with other software.

Also the problem with dependencies. Yes, some years ago, when one had to install from source, there were mountains of problems. Now, many packages, even when one has to compile and install it from source, provide routines to generate deb or rpm packages. Or the software creator maintains his or hers own repository.

In Windows, there is no central repository, or I am not aware of such mechanism. When it comes to managing software installations, then with the built-in mechanism, Linux distros are way ahead of Windows.