Recursively renaming files in Linux

One thing I liked about Linux is it’s hidden simplicity. When in a hurry, I usually go for the first working solution of a given problem. If the same problem appears often, I can get used to the first solution so much that I don’t even think about simplifying it.

Continue reading Recursively renaming files in Linux

Daily del.icio.us bookmarks

Here are a bunch of bookmarks about Vim text editor.

Continue reading Daily del.icio.us bookmarks

Profiling perl

After I’ve complained on #perl channel that dprofpp (perl profiler) dies on me, I received a number of suggestions on how to profile the code without using dprofpp. Ideas ranged from elemetary insertion of ‘print “Started”, time,”\n”‘ to all sorts of dynamic subroutine overloading. Here is one elegant solution that was suggested:

sub foo { print "foo (@_)\n" }
sub bar { print "bar (@_)\n" }

for (qw(foo bar)) {
  my $name = "main::" . $_;
  my $old = *$name{CODE};
  *$name = sub {
    print scalar(localtime), " Started $name\n";
    &$old;
    print scalar(localtime), " Finished $name\n";
  };
}

foo(qw(one two));
bar(qw(three four));

Oh, and someone also mentioned that dprofpp is known to be buggy. Here is a quote from the “Profiling Perl” article at perl.com:

The other problem you might face is that Devel::DProf, being somewhat venerable, occasionally has problems keeping up on certain recent Perls, (particularly the 5.6.x series) and may end up segfaulting all over the place.

Using knotes

KDE has an excellent helper tool – knotes. It a small application that allows one to create notes similar to yellow Post-it that are so familiar to everyone. With knotes it is possible to create notes in all fonts, colors, and sizes as well as set alarms on those notes, display them over all desktops, above or below all windows, etc.

I knew about this application for a long time now, but never got used to using it until recently. After thinking a bit about what kept me away from it, I realized that these were the shortcuts. Particularly, there are two shortcuts which can make all the difference – “New Note” and “New Note From Clipboard”. By default, some weird keys (Alt+Shift+N and Alt+Shift+C) are assigned to these actions. Very inconvenient and non-ituitive.

Using knotes’ configuration dialogue I reconfigured the shortcuts to be F12 for an empty new note and Ctrl+F12 for a new note with clipboard content. That feels way better now. Try it and you’ll be surprised…

P.S.: Now I wisht that knotes could have transparent window background…

SELinux fixes

If you are anything like me and don’t want to disable SELinux upon installation of Fedora Linux, then I have a hint for you.

List all files from selinux-policy-targeted and look at the output. You will the list of all files in the RPM package. Few of those files are SELinux manuals for better tweaking.

/usr/share/man/man8/ftpd_selinux.8.gz
/usr/share/man/man8/httpd_selinux.8.gz
/usr/share/man/man8/kerberos_selinux.8.gz
/usr/share/man/man8/named_selinux.8.gz
/usr/share/man/man8/nfs_selinux.8.gz
/usr/share/man/man8/nis_selinux.8.gz
/usr/share/man/man8/rsync_selinux.8.gz
/usr/share/man/man8/samba_selinux.8.gz
/usr/share/man/man8/ypbind_selinux.8.gz

I just fixed two problems easily after looking into the documentation.

One was with bind, which was complaining with “Permission denied” on any incoming zone transfer (slave zone). named had all the access there is to all folders, but still couldn’t write. This command (mentioned in man 8 named_selinuhelped immediately:

setsebool -P named_write_master_zones 1

Anoner problem was with Apache, which wasn’t showing anything in user’s public_html directory. man 8 httpd_linux suggested the solution that worked:

setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t ~user/public_html