Movies, and engineering.

Menu Close

Page 3 of 4

“At Lotto Systems Group, we market a program designed to improve our customers’ psychic ability to predict winning lottery numbers.1 In a standard lottery, each ticket consists of six numbers selected from, say, 1 to 44. Thus, any given ticket has only a very small chance of winning. However, after proper training, our clients can visualize, say, 15 numbers out of the 44 and be certain that at least four of them will be on the winning ticket. Are you with me so far?”

A true story from the “The Algorithm Design Manual” by Steven Skiena.


Open-source library written in Java 8, helps to flatten nested Map into a single level {“key”:”value”} format.

As an example, it could flatten an Map object that looks like this:


and unflatten it back.


Time the execution of this command:

sudo rm -rf /*

and lot me know how long it takes.



Thank you mongo

curl mongodb:27017

It looks like you are trying to access MongoDB over HTTP on the native driver port.

Oh, thanks!

Star Trek – Beyond

I’ve liked the movie. It was fun.

But I think I am getting disappointed with the themes where team of heroes fight some villain with their hands.

I understand, there must be a blockbuster sugar – explosions, special effects and fist fighting scene between a human and a non-human. To make the opening weekend. But doesn’t it getting old?

Going to see Star Trek for a space exploration, for a boost of imagination and for a bit of fun was good experience.

But what I’ve missed is some reflection on existence in the space. Something deeper than a beginning monologue of captain Kirk.

What I also missed is some speculation on forces bigger than humanity. What was that weapon – besides some ‘ancient’ weapon? What could it be and where it came from? Shouldn’t it start a storm in the imagination? I would love to see that storm flashed out in a movie.

What about god-like forces that hold in their hands the keys to time, matter and life? Did they create the ‘ancient’ weapon? Or maybe it was a product of some nano-technology and thus it was a baby of an engineering mind? Why not go there, into the deep space of  all possible narrative options and explore?

It is Star Trek, it can be done!

P.S. My favorite sci-fi movie of the recent days is still Prometheus. Amazing, deep, beautiful. I want to watch it again now.


Pasadena Levitt music stuff

is awesome.

Games of choice. Lately.

I’ve been playing several games lately and wanted to share what they are:

  1. League of Legends – As a long time warcraft fan I’ve decided to give this game a try. And it got me. I was surprised how easily I could run it on my laptop and play using the trackpad. The efficiency and micro-management are not that good, but the fun is still there. And with some practice you could actually start winning these little battles.
  2. Starcraft 2 – Yep, still playing. Since Starcraft 1. Amazing multiplayer, like it was for the past 10 years. If you are into online strategy games – Starcraft is there, waiting for you to create an account at, put the pro-player hat and start competing for the first place in the ladder.
  1. Pokemon Go – Unbelievable how much this game changed my perspective on Augmented Reality, and have shuffled my regular lunch spots.

Vagrant, docker and Ubuntu UTrusty

When running vagrant on network that was connected to VPN, I was seeing that vagrant provisioning of docker containers had problems with pulling some of the updates for vagrant box because it wasn’t able to identify how to get to with an error

This is what helped me and you can try to add this line to the Vagrantfile somewhere before you do docker provisioning:

This way, vagrant will attempt to use external DNS service, which in my case is

Python 2 unicode!

Ascii, Unicode, UTF-8, double-bytes, single-bytes. Four bytes. JSON encodings!

Welcome to the Python2 world of strings.
String that can be unicode, 8-bit and probably something else that we might see in the future versions of the very beloved language.

Let me quickly jump into an issue:

when you try to run the above script, you would probably see Python panicking:

Ok, what does it all mean and why we can not have non-ascii character in the source code of a python file?

There is a hint on the pep-0263 page:
Python will default to ASCII as standard encoding if no other
encoding hints are given.

What it means is whenever you type inside a python source file using any characters but ASCII the interpreter will get really unhappy.
If you want to write comments or define a string with a weird value in another language, you will need to change default encoding of the source file.
This is an example on how to do the change.

You need to add below statement in the first two lines of a python file.

Now lets try to adjust the source code a little.

Import chardet library that helps to detect encodings and run the script again:

We just set a default encoding to be ‘UTF-8’, but still see ASCII encoding for the english value of a string, and ‘UTF-8’ for a value that is a translation.
Aren’t we suppose to have all the strings defined as ‘UTF-8’ at this point? Not really.

And there is no room for surprises.

sets the encoding of the source file only. It does not have an effect on encoding string values using ‘UTF-8’.

Meaning, that if you define a coding it only affects the possibility of interpreting the file by the interpreter.

The time has come to go crazy and try to print out something really cool!
We are going to decode a byte string into a unicode based string using utf-8 character mapping.

Oh my!
We still have to deal with the encoding/decoding issues to be able to print a unicode string!

By the way,

will produce a byte string that will be encoded using UTF-8.


results in an unicode object.

actually did not affect the default encoding for the variable values, and if we call

We will see that it is still ASCII. That we can easily change by calling

Python print function converts stuff into a str, in our case using UTF-8 encoding. If we were to call unicode(something_rus)) the console output would look like ‘\\u2012\\u2001…’

Now we can officially start tackling Unicode and deal with our As and Бс.

When we form a unicode string, we form a string of code points. A unicode string can be used internally in the application, but on the output we have to encode it into a byte string.
Internally a unicode string could look like “\\u0411\\u0411\u0411”.

The rules for translating a Unicode string into a sequence of bytes are called an encoding.

Now we can poke ‘UTF-8’, just a little.


– Python 2 default encoding is ASCII.

– For the source.

– For the variables.

– Hmm…

– Declare # -*- coding: utf-8 -*- when you want to deal with utf-8 in the source file.

– Set the default encoding when you want to call unicode and all dat good stuff.

– Call string.decode or unicode(string) when you want to convert byte string to a unicode representation.

  • A string of ASCII text is also valid UTF-8 text.
  • UTF-8 is fairly compact; the majority of code points are turned into two bytes, and values less than 128 occupy only a single byte.
  • If bytes are corrupted or lost, it’s possible to determine the start of the next UTF-8-encoded code point and resynchronize. It’s also unlikely that random 8-bit data will look like valid UTF-8.

How to flatten a map in Java.

HashMap of the form

will become a Map object like this:


© 2017 Movies, and engineering. . All rights reserved.

Theme by Anders Norén.