- We want to run some process in the background and continue script execution. Then at some point we want to stop and wait for this process to finish. We also want to capture the exit code of this process. Once we have PID of the process we put in background,… [Read More]
How to find fonts that render glyph for given unicode character.
I want to find all fonts that support Polish accented characters (ąćęłńóśżź). [Read More]Limit process CPU use with cgroups version 1 and cgroup tools
The results with cfs_quota_us=50000 are below. The top utility shows about 50% CPU usage. [Read More]Enforce memory limit in systemd service
Create new service with MemoryHigh and MemoryMax directives. [Read More]Enforce process limit in systemd service
Simplest possible service that runs /root/process.sh script: [Read More]How to list all TCP/IP connections ordered by IP and count
How to list TCP/IP connections per remote IP, ordered by count: [Read More]Troubleshooting HTTPS with openssl
Display certificate information: [Read More]ranger file manager cheatsheet
Cheatsheet for ranger - a console file manager with VI key bindings, based on heroheman. [Read More]URL-dependent load balancing with HAProxy
We have a typical web application that is deployed behind a load balancer with several web servers behind. The web servers are nearly identical - running the same OS, code, packages. But they do differ in one way - some have a quick access to the external asset’s repository. Other… [Read More]systemd PrivateTmp with Apache on Ubuntu 17.04
Apache service on Ubuntu 17.04 is configured by systemd with PrivateTmp=true option. You can see it in: [Read More]How to detect user’s home directory from PHP on Linux & Windows
I needed to locate current user’s home directory, to find and parse a config file like ~/config.ini. The current user is a user that is currently running a PHP CLI script. I have found a neat solution in drush, ready to copy & paste into your function: [Read More]Redirect output of a script from the inside of it
Normally, when you want to redirect (standard) output of a script to a file, you run it with a redirection, like: [Read More]Include additional local files from .zshrc
I try to keep the same .zshrc dotfile on all the machines I use. I store the “master” copy in SVN, so any improvements I make can easily go to other computers. However, some parts of zshrc configuration only make sense for particular machine. To keep one common master copy but… [Read More]Extract the content from the documents and make it searchable with solr 4
solr can be easily extended to handle binary files and extract the information from them. Apache Tika library is used for the file analysis. [Read More]Limit bandwidth for a service
To test a performance of multiple parallel file downloads, I had to make sure that a download takes significant amount of time. I could use huge files but that’s not very helpful if you work on a local, 1Gb LAN. So I’ve decided to limit download speeds from my Apache… [Read More]Monitoring of Tomcat with VisualVM and VisualGC
Sometimes it can be useful to monitor performance of Java Virtual Machine (VM) on remote host. To do so, a very nice tool – VisualVM – can be used. It can be run on local host and get information from jstatd running on a remote host. In addition, VisualVM comes… [Read More]git server with apache authentication on Ubuntu Debian
This guide will describe how to serve git repository on HTTP port using Apache. This should work on any recent Ubuntu or Debian release, I’ve tested it on Ubuntu Server 11.10. I’m setting it up on my local server 192.168.1.20 under git/agilesparkle, so my repository will be available at http://192.168.1.20/git/agilesparkle.… [Read More]Change the location of zim notebooks
Zim is a desktop wiki I highly recommend. Recently I’ve switched to another desktop and after copying my whole home directory, zim default notebooks did not open anymore. This was because I’ve changed my username, which has caused a change in the location of my zim notebooks. This can be… [Read More]Install soapUI on Ubuntu 11.10
This post describes how to install soapUI on Ubuntu 11.10 and solve potential issues with installation. [Read More]Show full path to the current file in vim
I find this one very useful, when you press just CTRL-G in vim you will get some basic file information: [Read More]xargs, find and escaping pipe and semicolon
I wanted to iterate over set of directories and calculate total number of files inside each of them (recursively). xargs & find would do it just fine but you can not easily escape pipe inside xargs command. Here is the solution: [Read More]Send email from command line without x-mailer tag
I usually set my postfix to relay via gmail SMTP to allow me for reliable external email delivery from my gmail address, with the convenience of the command-line. To send an email using mail utility I can simply use: [Read More]ext2 ext3 partition block group error
Here is the error from dmesg I’ve got when trying to mount external HDD: [Read More]Recursively find the latest updated file
Here is the command: [Read More]Automatically equalize brightness of several images
I have a collection of 160 photos that I would like to montage into a movie. Each photo was done on a different day and the brightness of each photo varies. This will definitely not look good on the photo, so I’ve decided to “normalize” the brightness across the images.… [Read More]How to find the widest image
Recently I had to locate the widest image in the set of photos in a directory. Here is how you can easily do it with identify command, from ImageMagick suit: [Read More]Resize images in bulk to the same width or height, same aspect
mogrify is the tool you are looking for – it comes with the great imagemagick package and it’s designed especially to be used for bulk operations. To resize all images in current directory to 600 pixels wide (width): [Read More]Bulk rename photos to date
I have a collection of related photos stored on my PC. The filenames were “ugly” – standard file names coming from the photo camera. I would like to rename them into a file containing the date when the photo was shoot, e.g. 2011.07.21.jpg. There is an excellent commandline tool to… [Read More]Recursively find total size of selected files-directories
Sometimes simply checking the size of the whole directory is not enough, and you need more information, e.g. the whole directory has 3GB – but how much of it are those .avi files inside? The most flexible way for matching the files (or directories) is by using find command, so… [Read More]Get next auto_increment value in MySQL
I was recently working on some MySQL 5.5 performance testing. I had to generate a lot of SQL queries I would then use for my testing. To make my tests repeatable I needed to hardcode the values for IDs. That is, I couldn’t simply use: [Read More]Master slave replication in MySQL 5.5
I’d like to share a quick guide on how to set up master/slave replication for the MySQL 5.5 server. The procedure below should be used for development/testing only. If you want to create a production-ready setup, you should follow instructions from MySQL official documentation or use MySQL server packaged by… [Read More]utf-8 with perl odbc, freetds, and ms sql server
to make perl properly handle utf-8 strings inserted and retrieved from ms sql database, freetds config must be used (the configuration with only odbc.ini is possible to make perl connect to a database, but i could not find any way to make it work with utf) [Read More]Quit less without cleaning the screen
Normally when you quit less, your screen will be redrawn and you will be back with the content you could see on your screen before using less. Sometimes though it’s very handy to see the file with less, scroll down to the fragment of your interest and have that fragment… [Read More]scubed howto
0. http://cube.dyndns.org/~rsnel/scubed/ (scubed_http) 1. svn checkout http://cube.dyndns.org/svn/scubed/trunk scubed; # get scubed 2. make, su, make install, scubed -V 3. there’s a README file, in the scubed/ directory and on the web-site. basically all is written there (scubed_readme) 4. it will be a file used, for demonstration purpose. but a real life target is a… [Read More]cached plan must not change result type
An interesting error that may happen in PostgreSQL when using prepared statements is: [Read More]Parallel downloads with wget
How to download a list of URLs using more than one process (say wget) at the time? First, create a file with URLs – one URL per line. Let’s call the file url.txt. Then we need to create N wget processes, each downloading one URL at the time. Thanks to xargs… [Read More]Upgrade all packages but one
To upgrade nearly all packages with apt-get but “hold” some of them at the current version, you can use dpkg. Let’s say I would like to upgrade my Debian or Ubuntu system with apt-get and here is what I’m getting: [Read More]How to block HTTP requests for specific method
I needed to set my Apache Web Server to ignore/block all the HEAD requests but respond to GET requests normally. It is very simple with the mod_rewrite, for instance this can be added to .htaccess: RewriteEngine On RewriteCond %{REQUEST_METHOD} HEAD RewriteRule ^.*$ - [F] Second line: [Read More]Dynamic MMap ran out of room
Increase the maximum allocated memory in your /etc/apt/apt.conf. Add this line if it does not exist (also create /etc/apt/apt.conf if necessary): [Read More]Convert and extract ISO, DAA and BIN image formats in Linux
One way to do it (I think it’s the only way for DAA proprietary file format) is to use Linux version of PowerISO. [Read More]Howto mount ISO image in linux
Log in as root [Read More]fast reboot with kexec
(bios) stage and that bootloader stage when we have a nice lilo/grub prompt. [Read More]ipp2p and connlimit kernel patches for 2.6.17
1) download a recent patch-o-matic [Read More]usb mass storage howto
enable following options in the kernel: [Read More]KDE keyboard shortcuts