Shaping up KDE all the way

I think that by now everyone who touched KDE can pretty much figure out how to customize the appearence and shortcuts. Plenty of settings can be changed via kcontrol. Numerous themes can be downloaded from sites like www.kde-look.org. All of these are pretty trivial.

There is more to customizing KDE though. Much more. KDE has a very modular block-type design. This is great because you can easily use these blocks to build something that you need and that noone has created yet or at least not shared in a way easily locatable. I am talking about kdialog and kdcop.

Continue reading Shaping up KDE all the way

Critique of Where Perl 6 is Heading

There is an article at FreshMeat.net that talks about Perl 6 and the way the development is going. The author is mostly against this way. The article is followed by a number of comments both in favour and against of the points stated. There is also another discussion at PerlMonks if you are interested.

I do have my doubts about Perl 6 too, but I havent’ yet looked into it seriously. Perl 5 is way more than enough for me and I don’t see myself changing to anything any time soon. I’ll let you know if I’ll change my mind of course.

Dive into Python

Once in a while I need to write a couple of lines in Python. When that happens I histerically run around the web looking for some quick introduction or tutorial on the language. There are plenty of those, of course. But just to have something handy, I’ll put a link here to Dive Into Python. What is so different about this tutorial is that it is very practical. There are many examples of code and very little explanations and theoretical crap that everyone knows already or can guess from the code. Simply use table of contents and jump to the needed part, where example awaits for you. Great!

Secure programmer: Prevent race conditions

IBM developerWorks runs an excellent article about preventing race conditions – “Secure programmer: Prevent race conditions“. It is written in clean and simple language and explains nicely most common problems with races. It talks about lock files, alternatives to lock files, and doing lock files properly. It features good examples and solutions are described for several languages, including Perl.

This is surely a must read for anyone writing software in general and for multiuser or mutlitasking systems in particular.

Copying files to remote destinations. With bells and whistles.

If you ever had to copy a file from one machine to another over a network, chances are you know more than one way to do it by now. Especially if you were doing it on some Unix machine. If you are still struggling, here is a short list to get you started:

  • Send the file as attachment via email.
  • Copy it over the web using http/https or ftp/ftps protocols.
  • Use secure copy (scp) provided by many secure shell (ssh) implementations.

Copying a file from one place to another (even remote) is easy. It gets slightly more complex when you need something a bit more smart than just a copy operation. Here is a short list of requirements you might have to your copy process:

  • Secure (encrypted) transaction.
  • Transfer of only those parts of file which have changed since last copy.
  • Support for resuming the transfer if connection was broken, instead of resending the whole thing.
  • Limit the bandwidth consumed by the copy process.

If you ever had to satisfy any or all of these requirements in a single solution, you might have scratched your head more than once. Or, at least, spent some quality time on the web looking for the right tool. I know, because I did. In order to improve someone else’s chances of finding such a tool faster, I’ll describe it here.

The tools itself is called rsync. As far as I know, it comes with most Unix boxes and for sure with most Linux installations. rsync has a number of options and a very flexible functionality. Just by itself it can satisfy all of the requirements above, except for secure encrypted transaction. And the beauty of the rsync is that it can be easily integrated with other tools to satisfy even more requirements. In order to provide encrypted transfer it can be easily used with secure shell (ssh) implementation, such as OpenSSH.

Enough of theory, let’s go for an examlpe.

Here is one way of using rsync which satisfies all the requirements above.

rsync -e ssh --bwlimit=50 /path/to/local/file user@remote_host:/path/to/remote/dir

Now, let’s see how it works. rsync itself can transfer only the changed parts of the file. If there is no prior copy of the file at the remote host, than the whole thing will be transfered. rsync by itself supports resuming of transfer. So, if connection between your two machines went down for a while, you can just rerun the same rsync command and it will continue from where it stopped. rsync supports bandwidth limitations. In the example above, I used --bwlimit=50 which will result in rsync transferring at speeds of 50 KiloBytes (not bits) per second or less. The encryption part is done by secure shell and rsync is told to use it by -e ssh argument. As you could probably guessed, in the example above, /path/to/local/file should point to the file that you want to transfer. user should be a username to use when identifying at remote_host. If there is a need for password input, you will be prompted before the transfer. /path/to/remote/dir should obviously point to the directory at remote machine where the file must be stored.

Read the manual for rsync and ssh and you will discover a number of other useful options that will make your life easier. To close on a nice note, I’ll suggest you use two other parameters to rsync: -r which tells rsync to use recursive mode, in case you want to transfer a directory structure and not a single file; and --progress which tells rsync to show what it is doing in real-time.