Heroku and django-bower
Heroku, a cloud solution for various application engines, supports django out of the box. It does a pretty good job of providing you with a deployment process which at one hand is relatively simple, and on the other hand allows them to control their resources.
In particular, Heroku handles the static files for you by running
collectstatic
command. However, if you happen to use
bower
,
yarn
,
django-pipeline
or some other additional manager for static files that needs to be executed prior to running the collection, Heroku won’t do anything about it.
How to change shell prompt in Midnight Commander
Bash allows users to do very advanced things when defining shell prompt, including colours and propagation of information into xterm title. Unfortunately, when you want to use mc (Midnight Commander) in conjunction with bash prompts, you may find, that not all advanced escape sequences are handled by mc properly. To overcome this issue you can have a special prompt just for mc. To achieve that, consider the following shell snippet:
Faster CSV parsing in Python with pandas
Recently I had to write a Python script which needed to parse large gzip-ed CSV files. First I reached for the standard
csv
module, which is quite straightforward to use. Unfortunately, it proved to be too slow. In fact, I gave up waiting for it to parse even a single file containing about 30 million rows! And my whole data set had more than 300 million rows altogether.
After googling a bit I realised that my old good friend pandas has a built in csv parser -
String interpolation in Python 3.6
String interpolation is a useful feature in many programming languages which helps the developers to generate formatted messages easier. An example from C# 6 could read like:
var msg = $"Value of parameter {nameof(val)} is {val}";
Scala, Ruby and some other languages have similar features. Until recently Python was not one of them. However, the recently released version 3.6 introduced, at last, string interpolation. It can be used as demonstrated:
msg = f"From {start} to {finish} with some step={stepValue}"
More details can be found in PEP 498 . PyCharm IDE already supports this feature in its latest version.
Cmake FindMySQL script
Cmake is a great build tool. It takes care of generating build system files, targeting, among others, Unix makefile, MS Visual Studio, ninja, XCode etc. There are various extra modules available for Cmake. One in particular allows the discovery of MySQL development files, such as headers and libraries. It can be found here . Unfortunately, it has a few issues: it doesn’t work for Windows, and it has a bug towards the end. Other alternatives I found on the web were even worse. So here is an updated copy, which seems to be working much better, while supporting Windows, Linux and Mac out of the box:
High system load with Ubuntu 15.10 and 16.04 in AWS
I have recently upgraded my Amazon cloud t2.micro instance from Ubuntu 15.04 to 15.10. And soon I noticed a very strange high load on the machine - constantly above 2.0, and without doing much. The apparent culprit seemed kswapd0 process. I tried various simple steps to reduce the load, but nothing seemed to work, mainly because, as I already mentioned, no heavy activity was supposed to be happening.
After some Internet searching I came up with this bug report: kswapd0 100% CPU usage . Luckily, there is a suggested workaround from one of the contributors, although there is no permanent fix yet:
Muting conversation threads in Google's new Inbox
I wrote earlier regarding the new product from Google - the Google Inbox. GI is still work in progress, so some features present in the familiar GMail are absent or broken. I counted the “mute” functionality among them, because there was no obvious menu for it. Mute allows you to ignore conversations, which you don’t particularly care about. This can be very useful when you are subscribed to various mailing lists. Sometimes discussions take on their own lives and/or degenerate into something unrelated to you personal interests. So, instead of suffering the incessant stream of boring emails, you could “mute” the conversation and never see it again.
Creating Drupal theme based on boostrap and material design from Google
For quite some time I wanted to have a Drupal theme that would allow me to have a bootstrap based theme together with the look and feel as dictated by the Material Design principles from Google. Mainly because I like the way these two look and because I myself have very limited abilities in creating pretty user interfaces.
That said, I didn’t want to spend any time writing the necessary code in the required technologies, namely PHP, CSS/LESS and JavaScript. Luckily, this is no longer necessary. Thanks to considerable effort put in by the nice people of the World Wide Web, all the necessary ingredients are already there and all you need to do is to combine them.
clog - add colours to your log life (and files)
Developers often have to look at log files. This is sometimes boring, sometimes tedious, but it’s a fact of life. It would really help if some special lines, such as errors, warnings etc. could stand out. One way to do it is to use the clog utility.
To make clog usage more streamlined from a terminal, you can define this bash function:
# pipe a log file through clog to get colours
function logless
{
if [ -z "$1" ]; then
echo "No file given, exiting" 1>&2
else
cat $1 | clog | less -R
fi
}
Don’t forget, you need to configure clog so that it is able to recognize the format of your log files, since there is no way it can know it in advance. If you happen to be using glog (Google log) library in its default configuration, try adding these settings to your .clogrc file:
TeamCity and publishing NUGet packages to private repositories
Recently I had to figure out how to publish a NUGet package to a private password-protected repository as part of a TeamCity CI build process. NUGet, for those who are not aware, is a tool for managing .NET software in a convenient manner. It is similar in its purpose to Maven, the Java packaging framework. The implementation details are, of course, quite different.
TeamCity (version 9 in my case) provides support for handling NUGet packages, including fetching dependencies (relevant to the build process), as well as packaging and actual publishing out of the box. However, it is impossible to publish artefacts to those private repositories, which require username/password authentication.