My favorite text editor is Geany. It is very minimalist HERE which supports a huge set of languages – shell, php, python, C … etc. It has automatic finishing and at the same time it is very agile. It lacks some other pleasant opportunity, but at the moment it is more than enough for me. I started an online course Python Programming на SoftUni – to refresh my knowledge and upgrade it because I have not adequately monitored what is happening with python 3. The lecturers of the course recommend PyCharm as an IDE for pyton programming, but I do not like it, of course I use Geany for the exercises.

During the lectures I felt painfully 2 lacks

  1. python autocomplete exhales from documentation of functions and methods
  2. no validation for pep8 standard

The good thing is that Geany is flexible enough to configure and can be easily supplemented by missing ones.. Sometimes add python documentation to our IDE:

  • we pull the following script somewhere in our PATH for example / usr / bin and don't forget to make it executable
  • edit the file ~ / .config / geany / filedefs / filetypes.python by adding the following line in the settings section context_action_cmd=pydocw %s. If there is only add the name of the binary from the previous step. We restart Geany if it is released.
  • We already have a context-action that will get you information about the function. I added a shortcut to make it more convenient as I do not understand any functionality. I like this approach a lot because I am very annoyed by the netbeans approach.

So far so good. Then I really want to have validation of the code I write – whether I write it according to generally accepted standards or I write some ugliness. Basically I found it again tutorials how things happen but it's a bit outdated – Geany has everything built into it, you just need to install the pep8 package. In Debian apt-get install pep8 works in the other distros you have to find out for yourself how the magic happens. In the Build menu, the second button (at least for me) is Lint after clicking it you will find how ugly code you have created 😀

Screenshot from 2016-01-11 20-42-21

Here's a general outline of how to make your Geany work better with Python while still being fast without making your CPU want to pull the bullet.

Certification in have daily tests that give on 1 an extra point after passing all the basic tests. They have to be done 100 such tests for maximum score 😐 . The tests themselves are completely trivial

  • Traceroute
  • Ping
  • Whois

The most unpleasant thing is that the tests themselves must be unique, ie you can't use one domain twice 🙂 Besides everything else, they are a bit annoying 🙄 – no challenge just slapping 5 commands in the cli and copy / paste of the result on their site.

As a lazy and administrator who likes to make his life easier, I quickly scratched an elementary bash that does the dirty work for me.


hr() {
  local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq'
  local cols=${COLUMNS:-$(tput cols)}
  while ((${#line} < cols)); do line+="$line"; done
  printf '%s%s%s\n' "$start" "${line:0:cols}" "$end"

if [ -z $1 ]
  echo "Append domain afert the script name!!!"

IP=$(dig $1 AAAA +short)

if [ -z ${IP} ]
  echo "$1 dont have valid IPv6 record"
  traceroute6 $1
  dig $1 AAAA
  dig -x ${IP}
  ping6 -c3 ${IP}
  whois ${IP}

As you can see, the script is insanely simple. You submit a domain and then validate it to see if there is an IPv6 record and if so, perform daily tests for it. The coolest part – function hr which prints a line across the entire width of the screen is taken from bash-hackers.

A shell script wants your job

Today while I was working I saw that one of the machines was lying very badly. I go into it watching a cron bump into a hell of a lot of zombie processes (roughly around 50-60). There was no way I could kill them all with killall so I had to make a little more competent solution to the problem – to draw an elementary bash a script to find and kill processes. 50-PIDs are not easy to write by hand :D. I scratched the script for a minute and it is very simple, but it still deserves attention 🙂

At its base is the conveyor

ps ax | grep -v grep | grep process_name | awk '{print $1}')

Here we get a sheet with all the PIDs of the process that we have to kill by excluding grep from this list. Now that we have the list, things become easy, everything turns into one for. Here is the end result


PR=$(ps ax | grep -v grep | grep process_name | awk '{print $1}')

for PID in $PR
echo "$PID will be killed"
kill -9 $PID

Can be “tuning” as the name is taken as an argument after the name of the script and thus is called as executable binary. However, it is not a very good practice to have such frequent cases 😀 But it never prevents us from being protected from any

Enhanced by Zemanta

Today I played to optimize a slow one SQL request of the type

SELECT * FROM 'table' WHERE `field` LIKE '%word%'

Where is the problematic moment here – last part ‘% word%’ and in even greater specificity the sign % before the word, for which we do. Wildcard symbol % ,before any value, directly turns our request directly into slow, because in this way our query stops using field indexes. Solutions as always, but they are not always clear 😆 In general MySQL have a solution to this problem with fulltext search field indexing. How to change the field is much written in the documentation, but I will quickly describe how the above query changes, because we will come to a little drama at the end. Follow by applying the fulltext to the box above, the request must change in type:

SELECT * FROM `table` WHERE MATCH (field) AGAINST ('word')

Thus, the structure is obvious and there is no need for unnecessary discussion. The above application will take effect, if the word, for which you are requesting is at least 4 characters, the default is this value, if you want to modify it you must specify the value, which you want in my.cnf in the part [mysqld] with the declaration ft_min_word_len= 3 or 2, 1 not a good choice obviously 😉 . After changing the value and restarting the mysql server you need to repair your tables, so that the new indexing can take effect. So far, everything is clear: I make the changes, restart, I rebuild the indexes and make the request and it returns to me 0 line 😀 I check with


I see that values, which I have set have come into force, I rebuild the indexes again – the same result. 🙄 Unpleasant, very unpleasant. From here, a big swearing and digging for the key to the shed began 😀 Which turned out to be quite, quite interesting. Generally, when I started reading the documentation for I don't know which way and I came to an interesting passage

Such a technique works best with large collections (in fact, it was carefully tuned this way). For very small tables, word distribution does not adequately reflect their semantic value, and this model may sometimes produce bizarre results. For example, although the word “MySQL” is present in every row of the articles table shown earlier, a search for the word produces no results

BEAM 😳 I give my plate was small – it was a test after all. Our query in a large table with over 2 000 000 order and there things fell asleep. Well, the problem is already clear. To make the decision clear, I will mention briefly, that full text search supports 3 advanced modes BOOLEAN , EXPRESSIONS and NATURAL LANGUAGE as the latter works by default. You can check the documentation for the different modes, I will explain with 2-3 words for BOOLEAN because it contains the key. It supports AND logical operators, OR , NOT and so on and you can do various spells with the searched phrases, to have one, to have no other and so on. It also supports the symbol *, which is the equivalent of the wildcard symbol % 😉 It is useful, when the search word is below the length of ft_min_word_len or for small plates ;). At least for me on a table with about 100 the order does a perfect job. It remains only to see the completed request:

SELECT * FROM `table` WHERE MATCH (field)

Here comes the moment whether indexing with the wildcard symbol works for us – the answer is I don't know. Basically I think, that yes, because nothing else is said in the documentation, but the documentation obviously doesn't say or show many things 😀

Enhanced by Zemanta

For one project that I lead in gitweb it annoyed me, that there is no coloring of the code in the tree. Лесен начин как да оцветите синтаксиса в tree частта на gitweb е като инсталирате пакета highlight и добавите следния ред в /etc/gitweb.conf или където ви се намира конфигурационния файл на gitweb

$feature{‘highlight’}{‘default’} = [1];

For the Debian package it is in the package system for other distributions I have not checked.

ps There is an alternative option by making changes to the gitweb files, but it seemed pointless to me as there is a simple option 🙂