Category Archives: Uncategorized

ffmpeg -i input.flac -ab 320k -map_metadata 0 -id3v2_version 3 output.mp3

How to see git/mercurial branch on your command line

Add this to your `~/.bashrc` file:

function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

function hg_dirty() {
hg status --no-color 2> /dev/null \
| awk '$1 == "?" { unknown = 1 }
$1 != "?" { changed = 1 }
if (changed) printf "!"
else if (unknown) printf "?"

function hg_branch() {
hg branch 2> /dev/null | awk '{ printf " (" $1 ")" }'
hg bookmarks -a 2> /dev/null | awk '/\*/ { printf " (" $2 ")"}'



PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$YELLOW\$(hg_branch)$NO_COLOR\$ "

Google Code Jam 2016. Problem D – Fractals.

Google Code Jam 2016 – solution to problem D: Fractiles.

This is problem to get 10 points for free.
Small part is very easy.

Problem text.

Problem 4 - Fractals.
If S = K this means that we can use K positions to test if there is gold.
We will use all of them.

Let’s assume there is gold in 1st position of original sequence.
Then 1st position of final sequence will be gold too – this is very easy to understand.

So we choose 1.

If there is no gold at 1st position – it means that first K numbers in final sequence are the same as in original.
So small solution which wirks for all inputs:

1 2 3 4 … K

To solve large input next idea becomes a solution:

Let’s imagine some start sequence and end sequence which has complexity C=2.
How we can clean 1 tile and check if 2 origina tiles contain gold or not?

Here is image which explains which tile we need to check to verify tiles 1 and 2 in original sequence.

Tiles - Complexity = 2

This easily becomes feasible idea for solution Рfor complexity C Рeach additional level allows us to check +1 original tile by cleaning corresponding tile in corresponding position.

Minimum number of tiles which are required is floor(K / C)


Oracle hierarchical queries

Discovered for myself Oracle hierarchical queries power.

Let’s assume you have a table with structure (basically storing graph representation in 1 table, parent is referencing to id in same table):

create table nodes(
    id number not null,
    parent number,
    type varchar2(10) not null);


Let’s imagine we want to count how many children each parent in this structure has (any node can be both parent and child):

select parent, count(id)
from nodes
    start with id = 1
    connect by prior id = parent
group by parent;

Here you can use start with syntax to indicate id which you are asking to start search from.

In this case it will start with specific id = 1, that for each children matched by id = parent it will repeat same operation – looking for the children – therefore full tree will be walked through.

Connect by syntax allows to indicate condition which is used to find matched across whole hierarchy: on the left side of equation (id) you need to indicate parent reference. On the right side (parent) – you need to indicate child reference you are matching with parent.

You can play with SQL provided example here:!4/04b91/12

MTV Exit has finished.

Just came back from 2-days MTV Exit hackathon where we tried to solve issues related to slavery problem in the world.

Very impressive people and community and unbelievable passion of people from organizations which trying to challenge this hot topic.

We we doing riskmap application – site to solve to issues in one shot:

1. Problem of insufficient level of information in society about real statistics, cases and real risk for each of us.

2. Problem of too many resources on too many sites which are not related to my specific questions regarding work migration to another country.

Have a look at our site, let me know your opinion.

BTW. We took second place in the competition and are planning to finish this project to the end.