Blog

Fixing permission of files created from Docker

Docker requires root escalation in order to execute an image, that crates some problem with files creation. Let’s say that we share a volume from host to docker and we create a file structure from inside docker.

This can be illustrated by an code snippet

docker run --rm -w $(pwd) -v $(pwd):$(pwd) debian \
    bash -c "mkdir test && touch test/example"
# Running on host
ls -la test

 total 8
 drwxr-xr-x.  2 root   root   4096 Jan 22 22:50 .
 drwxrwxr-x. 12 trzeci trzeci 4096 Jan 22 22:50 ..
 -rw-r--r--.  1 root   root      0 Jan 22 22:50 example
# Running on host
rm -fr test
 rm: cannot remove 'test/example': Permission denied

Why this is even an issue? I’ve found this problem mostly annoying on local setup, as I need to use sudo for simple hause-keeping tasks. Another case when it’s very problematic is to use docker on Jenkins – as this prevents to remove workspace after a job is done.

 
20 Kudos
Don't
move!

Do you know #ifdef?

This time I would like to focus on some aspect that every C/C++ programmer is familiar with. That is preprocessor conditions. Before being crucified because of using #ifdef and C++ in the same sentence. I would like to confess, that this is still something frequently used.

What is #ifdef?

#ifdef is a preprocessor condition, that includes containing code whether condition predicate solves to ‘true’. It might be useful to make sure some code will be never compiled.

For the instance let’s see a code

void HandleResponse(const CHTTPResponse& resp) {
#ifdef WITH_CONTENT_VALIDATOR
if (!Validate(resp.content(CHTTPResponse::Text))) {
    ForwardCorruptedResponse(resp);
}
#endif
// ...
}

So far so good, let’s just compile our project with: g++ -DWITH_CONTENT_VALIDATOR=1 and see if everything works. It does. Sweet! No tests are required now, so let’s disable them by setting -DWITH_CONTENT_VALIDATOR=0 and check. Wait! My tests are still executed!

 
4 Kudos
Don't
move!

My first NPM package

Intro

This page describes my journey of creating and publishing an NPM package and reflections about this process.

I have chosen TypeScript as a development language for the chunked-call library. Basically it’s a 3 function library with ~70 lines of code, it’s nothing special at all. My ambition was to publish something in a right way and I was positively surprised about the process and what enforced me to make it right. Please note that this page is not a guide about pushing stuff to NPM registry or how to create an NPM package project in your language of choice. For those it’s always better to see an official documentation for either NPM or for your tool/language.

Some information here might be trivial for you if you develop on daily basis in JS/TS, to me as C++ developer they weren’t.

 

1
Kudos
Don't
move!


Thank you Adobe (Macromedia) for Flash

Google trends, Apple, Google Chrome and plenty of developers put a cross on Flash. In my opinion without Flash the current web tech stack might look different.

Credentials

I wrote my first line of code in ActionScript 2.0 it was 13 years ago and it was streamlined with the style of web. Big boom of flash animations, letters flying around and flash menus. In addition I’m putting myself as the worst person on the World in terms of color matching. At the moment of doing it I didn’t know that I become a programmer, I liked PC though.

A couple of years later I was doing more and more programming, some in Pascal, some in C. Neither of them attracted me for more time (before college) so that I was experimenting in Flash, and I enjoy a lot the simplicity of putting a movement to MovieClips, Timeline manipulation or doing mouse actions. During college, I’ve switched focus to C++98, Verilog and SystemC. Probably by accident I started to work in game industry at GameFactory, where I co-developed around 7 titles in Flash and 2 in Unity 4, then at King I’ve started to work as an AS3/C++ Engine developer. All of it doesn’t make me guru neither of language nor of the best practices. I achieved level where I felt comfortable with API and tech and I could utilize well that Flash offers,

Bright sides of Flash

API

I didn’t notice this aspect before, but after working as an engine developer I understood how hard is to provide clean API what is future-proof. As a noob I was able to deduce what some API call will do. For 8 year of working with Flash Player I don’t remember any problem with breaking changes. API was flexible enough to add new functionality, it was smartly designed around passing an extra configuration objects like LoaderContext. For the instance, when they added an asynchronous image decoding, it wasn’t done by an extra argument for function call, it was an extra property of context. KISS in practice.

ActionScript 3.0

I love in place XML:  var xml:XML = <foo><bar/></foo>;

I love Dictionary with weak keys, and Object where you can put other objects as a key.

I love typed Vectors, (And hate a little bit for weak performance even with fixed size, and conversion between them).

I love for each..in loop.

And I was so surprised that JavaScript has none of them. In such a way ECMAScript 4 (ES4) from ActionScript 3.0 is far more developer friendly than ES5 is. In someway ES6 tries the best by adding classes. But there is plenty of other missing features like: final classes, private, public, protected, internal accessors. Explicit inline (This is more compiler feature than language), strong typed (thankfully we have TypeScript), well designed Event System with nice propagation (It’s more like a library feature rather tan language), no confusion with undefined, no confusion with this, and static variables / functions.

 

211
Kudos
Don't
move!


Dell XPS 15 9550 was the most problematic device for me

After research I’ve found that not only me is struggling with this device, and after having experience with two 9550 i7 4k I suspect that this device was released in hurry without proper QA and probably because of that Dell has introduced a successor 9560 what as far as I know didn’t inherit problems of predecessor.

I decided to have one due some reasons:

  • I prefer Linux / Windows system rather than macOS
  • I had good experience with Dell before
  • I tried to have something powerful and light (I still use Asus K95N what is questionably mobile)
  • I wished to have 4K
  • Battery life

After having this deice almost 1 year, I wouldn’t buy 4k display, Windows and Linux have problems with supporting HIDPI and LowDPI displays at the same time (link).

#1 Problem of brand new device

In many cases I have to double verify if the problem it’s not me. I mean I have highly customized system, like custom shell, own entries in system PATH, some tools what I use day by day.

Subtle flickering of screen

This issue was present when display was dimmed, it was pretty annoying at night, so that a comfortable work wasn’t possible. Fortunately this issue has been fixed with some of the recent BIOS update.

Random freeze

So when I started to see that PC randomly freezes I did reinstall, then I did Linux installation, then I started to search on the Internet if somebody has the same problem. Apparently yes, many of people. In most cases people were pointing on SSD Samsung drivers, nVidia GPU or WiFi card. Unfortunately symptoms weren’t exactly how they described. Most typical example for me was watching YouTube video, then any IO stopped to work but video was playing nice, when the video went out of buffer it stopped to play.

Misaligned hole for Jack

The problem was that, when I plugged it headset (any jack device) the right channel wasn’t playing. I had to use a file to expand a hole, so that any pressure was applied on jack and I started to play a sound correctly on both channels.

 

After having all of above you can imagine my frustration, fortunately when I asked Dell on FB what to do, they helped me. So my warranty repair included:

  • Changing Motherboard
  • Changing SSD
  • Changing WiFI

 

11
Kudos
Don't
move!


Use CMake and Make, when sh.exe is in PATH on Windows

Problem

In order to be trapped by this problem your project / environment has to meet following conditions:

  1. You need to use Windows.
  2. Your project uses make as a base build system.
  3. You have available sh.exe as a system command.
  4. [Optional] You use CMake for a project generation.

Conditions 1 and 2 are pretty easy to fulfill, for the instance you try to compile Emscripten or Android based project. Condition 3 might look pretty odd. Why sh.exe on Windows? To me it was a natural ripple effect of having Git installed with Linux like tools in system PATH. I just love to use ‘ls’ instead of ‘dir’ in command line.

 

32
Kudos
Don't
move!


Blog was moved to trzeci.eu domain.

The blog has been moved back from asria.pl host to trzeci.eu host. Nevertheless, the old alias will be still active as a 301 redirection (until DNS and CNAME will propagate).

 

7
Kudos
Don't
move!


Configure graphic and sound for WSL (Creators Update) for Ubuntu 16.04

Information

This is an update for https://trzeci.eu/configure-graphic-and-sound-on-wsl/

New version of WSL brings lots of fixes and updates: https://blogs.msdn.microsoft.com/commandline/2017/04/11/windows-10-creators-update-whats-new-in-bashwsl-windows-console/.
Unfortunately it’s still impossible to play a sound out of the shelf. The major problem is connected to the lack of direct support for audio devices. The solution is to use PulseAudio, what creates a server on Windows host, and this server plays a sound what is passed from Linux.

The problem with this solution is that it’s not supported:

Thanks to @therealkenk we can pull modified library for Ubuntu 16.04, like it was possible for 14.04: https://github.com/Microsoft/BashOnWindows/issues/486#issuecomment-299682364

Demo

In the following part I will present Base setup, what’s needed to do required steps manually, further you can find “Installation script” what does everything automatically, please choose wisely.

 

63
Kudos
Don't
move!


Windows 10 Creators Update and support of Hi-DPI and Low-DPI displays

This is an extension to my previous post about this problem: https://trzeci.eu/windows-10-support-of-hi-dpi-and-low-dpi-displays/

I’m right after install an update to Windows 10 Creators Update / 1703 and problem with scaling of some most applications has been solved by introduction new compatibility mode.

From the user perspective: It’s needed to set System (Enhanced) mode for DPI Scaling Behavior:

 

My low DPI Screen looks like below:

 

References

 

Update

After testing this for a couple of days I fount some glitches with Enhancement mode.

 

Windows Explorer

On LowDPI screen: moving location “segment” somewhere in order to link it.

View post on imgur.com

On HighDPI screen: Welcome window after installing Creators Update:

 

Other software what has some issues with enhancement mode.

VS Code

This soft works nicely without compatibility mode, but when I started to use ConEmu with Enhancement mode, it passes execution context to every application what is created from the console. Hence when I type code in my console it inherits settings.Then it looks like that:
HighDPI screen

This case applies on other applications, when improved compatibility mode is enabled.

 

 

3
Kudos
Don't
move!


Configure graphic and sound on WSL

This is more like a notebook entry, rather than full tutorial.

References:

In this post I will describe how to install WSL on Windows 10, configure X11 to run any Linux application in GUI mode, and fix missing sound problem.

 

237
Kudos
Don't
move!