Python: How to shift values in a list

To shift values in a list (replace the value at the first place of the list to its last place and vice versa), you need to rearrange the list with two slices.

The shift for the list:


and backward:

If a cyclic shift is necessary, repeat this command the required number of times in “for” cycle.

How to find out the Linux Debian version

To check the version of the Linux Debian installed on the server, type the following command:

The operation system response:

Python: how to save a dictionary with objects to JSON

Each object’s class to be stored in JSON in a convenient for viewing way must have the __repr__ function, which returns the text representation of the object.

The dictionary with objects:

Saving the dictionary to JSON:


Python: how to enclose a tuple in a tuple

Tuples in python can be nested.

If simply add one tuple to another through the concatenation operation “+”, python will merge the values of the tuples:

In order an added tuple to become nested, put a comma “,” after an added tuple:


Python: How to find the polygon center coordinates

Obtaining the “centroid” – convex polygon central point coordinates, from polygons points (vertices) coordinates:

The input function parameter is a tuple with coordinates of the polygon points. The function returns a tuple with the centroid coordinates:


How to start working with Git and GitHub

Version control systems for today are almost mandatory for any project. One of the most popular version control systems is Git. Consider working with Git in conjunction with GitHub – the largest hosting server for the deployment of IT-projects of joint development. GitHub allows publishing open source projects for free.

In this article, we start to work with Git and GitHub on the Windows operating system.

What we need, in order to start our work with Git:

  1. Download the Git distribution for windows:
  2. Install Git on the user’s computer
    1. All installing options can be set “by default”

The for loop counter in Python does not have a local scope

One of the for loops features in Python is that the iterated variable (counter) does not belong to the local scope of the loop.

For example, after executing the following code:

The “a” variable declared before the for loop will change its value if the variable with the same name “a”  declared as the loop counter.

It is necessary to remember about this feature, in order to avoid writing to the previously declared variable the values of the iterator of the for loop.

How to check code execution time in PHP

To check how match time code execution takes you need to frame checking code with following instructions:

This example result:

Executed for: 8.9997079372406 sek.

How to create symbolic links in Total Commander

Symbolic links in Windows (starts from Vista) can be created using mklink command.

Let’s make a button in Total Commander to create a symbolic link from the selected file:

  1. In a convenient location, for example in Total Commander plug-ins directory c:\TotalCommander\Plugins\ create a batch file mklink.cmd with the following content:

This command creates a symbolic link to the file transferred from the first input parameter and places it in a location from the second input parameter.

  1. Create a button in Total Commander panel by dragging this file to this panel.
  2. Right click on this button and select “Edit …”
    1. In the “Settings” field specify:

Save changes.

%P – path to the file under the cursor in active panel

%N – the name of the file under the cursor in active panel

%T – path to the location, open in a second (non-active) panel

As a result by pressing created button a symbolic link to the file under the cursor in the active Total Commander tab will be created in a location of the inactive tab with the same file name.

Python – multiline comment in PyCharm

Python language has no internal multiline comment syntax (like \* … *\ in other languages). There are two ways to solve this:

  1. Use multiline string literal syntax: ′′′

Disadvantage of this way is that such comment remains constant string and processed in finished code.

  1. If the PyCharm IDE is used to write Python code – select multiple code rows to comment and press keyshot Ctrl + / to comment all of them.

To remove comments from multiple commented strings select them and press Ctrl + / again.

Sending parameters to external javascript file *.js

Setting input parameters in *.html file:


Getting parameters in external javascript file *.js