chmod (distinguish between files and directories)

I hate having execute bit set on files not supposed to be executable. But I have always found it a lot easier to set it to keep directories browseable when chmod’ing a directory recursive. Now I thrown a little bash line together to easily only chmod files or directories.

This only chmod’s files:

debian:~# find -type f  | xargs -i chmod 640 {}

This only chmod’s directories:

debian:~#find -name '*' -type d  | xargs -i chmod 750 {}

The -name ‘*’ makes sure that it is only sub directories is processed (and not the current directory).

Show progress of dd

Here is a perl code example which shows progress of dd made by my friend Thor Dreier:

sdd if=/boot.img.gz of=/dev/sda -pg bs=1M 2>&1 | perl -e 'print $i++." MB\n" while(read(STDIN,$c,3));' is undergoing a face lift

I have been playing with different layouts of for and I think I have settled with the current top which you can see on the main page.

This design will eventually find its way to my blog also.

This have been made with Inkscape and GIMP. I’m working on a easy way to add files (mostly SVG and XCF files) to for download. Right now it’s only on the drawing board.

Convert txt-list to HTML-list

The following PHP code converts a txt list to at html list. Look at example below. Nothing new in this… alot of Wiki pages can do that, I just thought it was cool. After using alot of time to figure out how (new to regular expressions) it makes you wanna show it to the world:

 * This function isn't supposed to be called directly
 * But through encodeList()

function encodeListElements($text) {
    return preg_replace("/^\s?(([\*|\-]) (.*?))\n/m", "
<li>\\3</li>", $text);

function encodeList($text) {
    return preg_replace("/\n((\s?(([\*|\-]) (.*?))\n)+)/sie", "'
<ul>' . encodeListElements('$1') .'</ul>'", $text);

Note: Your browser might split up the code lines, so make a double check.



* Milk
* Water
* Coca Cola


<li>Coca Cola</li>

Response to Art of computernaming

After reading Random thought: Art of computer naming and Random thought: Art of computer naming, part 2 I wrote Lars Wirzenius to tell him about the names I use at work if he ever was to make a part 3 :)

(All this happend a while back while my server was down - 29 April)

For those of you who just can’t wait for a part 3 I use fable animals and I have put a list together here.

Fable animals

  • Unicorn
  • Hydra
  • Pegasus
  • Griffin
  • Cyclop
  • Minutaur
  • Mermaid
  • Pixie
  • Gnome
  • etc.