Showing posts from January, 2015

Star trail

Star trail pictures are created by merging multiple images together into one image.
The principle behind creating star trail pictures is very simple, but can also be very complex. We are not getting into the complex one in this post, which makes guesses and predictions to feel the gaps between stars, to keep the background static, etc...
In this post we're taking a look at the simplest way of creating star trails, which is by keeping the most intensive pixel colors from a list of images.
Each pixel has a RGB value, which can range from black (0,0,0) to white (255,255,255). The first column is for red, the second column is for green and the last one is for blue, and hence the RGB acronym.
The intensity of a pixel color can be calculated with the following formula: sum(RGB)/3.
But there are some other formulas for calculating the brightness of a pixel, which also work for creating star trails:
HSL Lightness: 0.5*max(RGB)+0.5*min(RGB)Relative luminance: 0.2126*R+0.7152*G+0.0722*BLuma

Perl code analyzer

In this post we're going to take a look at code analysis. It's an old problem and a very hard one. The task is to determine the code quality and how good was the programmer that wrote that code (his knowledge about the language features).

One solution would be to try to simplify the code so much that it will look like it was written by a newbie. For example, if there are special quotes which enclose the strings, simplify them to just one type of quotes, or put/remove parentheses even where they are unnecessary, transform hexadecimal and binary literals into decimal numbers, etc...

We're going to implement such a program in Perl which will analyze other Perl programs, but we're going to cheat here. Perl already has a deparser which simplifies the things for us. All we need, is a clever solution to compare those transformations. But we want this solution to be fast and reliable.

Here is the main picture of the algorithm:
Read codeDeparse codeTokenize the original and depa…