Image shrink bash script

•May 26, 2009 • Leave a Comment

Today I just want to upload a little bash script I often use for shrinking my pictures to reduce their size. This is useful for sending by mail or uploading to facebook.

GUIs are very cumbersome if you want to convert a lot of files, but ImageMagick is a great commandline tool for processing pictures. ImageMagick can do a lot, but here I only use the ‘resize’ function of ImageMagick’s ‘convert’ tool.

How to use? Just enter your folder with jpg images and call ‘/path/to/makesmall.sh’. You can also put it into /usr/local/bin to avoid entering the full path.

You can download it from Pastebin or just copy/paste it from here. This link will stay valid for one year.

This post is not for Linux Gurus, but maybe it’s useful for some newbies ;-)

 1 #!/bin/bash
 2 # Description: Little script to shrink all images in the current folder.
 3 #  That’s convenient if you want to send them by mail or want to upload it to facebook.
 4 # Author: Gerhard Gappmeier
 5 # License: GPL – GNU General Public License
 6
 7 if [ -e small ]; then
 8   echo "folder ’small’ exists"
 9 else
10   echo "creating folder ’small’"
11   mkdir small
12 fi
13
14 for file in *.{jpg,JPG}; do
15   if [ -e "$file" ]; then
16     if [ -e "small/$file" ]; then
17       echo "Skipping ‘$file‘, because ’small/$file‘ already exists."
18     else
19       echo "Converting ‘$file‘…"
20       convert -resize 1024 "$file" "small/$file"
21     fi
22   fi
23 done

Beeing free

•April 23, 2009 • 1 Comment

It’s always so funny.
A Windows user sees that I’m using Linux and then he’s asking:
WinUser: “What Linux are you using?”
I: “Gentoo.”
WinUser: “What version?”
I: “Gentoo.”
WinUser: “No, what version.”
I: “Yes, Gentoo.”
WinUser: “???”

Then I start to explain that I don’t need to wait for years for a new Linux like with Windows. Gentoo is upgraded continuously, each program individually and you never have to reinstall it.
Hard to believe for somebody who knows only Windows and has never seen the power of free software. “Free” means the user can do what ever he wants, not just “no costs”. Freedom, no limitations. Why should I made myself dependent from software vendors, where I have to accept their conditions, their prices, their update cycles, their guarantee that the software is secure and that there is no built-in spy software, …
Linux is free and it’s open, I can do with it what I want, use it for what I want, can change it like I want. There is no limitation like: if you use MS Exchange you MUST also use MS Outlook, if you use Media Player, you MUST also use a MS video codec, if you write a document with MS Word all users you want to send it MUST also have Word, if you make Website with MS Frontpage you MUST also use MS Internet Explorer, …
Hey! There are open standards!!!
MS has no interest in being open, implementing standards, being useful or being stable.
They are just interested in making money.
But not with me, I’m free!

RC HeliSim

•April 6, 2009 • Leave a Comment

Hi all Linux users.

I’m currently developing an RC helicopter simulator. The focus is realistic flight behavior, but when everything works I also want to work more on the OpenGL rendering to give it a better look.
Why am I doing that? Because I can and because it’s fun ;-) (ok, a little bit nerdy, I know). But I was interested in learning to fly a helicopter for a long time, and I’m also interested in the helicopter physics. So before I crash an expensive helicopter I better write a simulator where I can learn both: Learn to fly and learn the physics.
I also was searching for some free simulators, but there was not very much available. One is FMS (Flying Model Simulator) which is nice but not very realistic. Another big disadvantage is, it’s a Windows program and it’s closed source, so nobody can improve or port it to Linux. Another one is Helix, a JAVA program that’s looks very realistic according to the videos on the website, but I could not manage to get it working. That’s due to the nature of JAVA. On Linux accessing the joystick device did not work, on Windows I got a damn JAVA exception, and on Max OS X the required JVM is not available. JAVA really sucks!!! And it’s damn slow anyway. (Sorry JAVA fans, I don’t like JAVA, but that’s only my personal opinion)
I like to have everything under control – also when to acquire or release memory – and that’s why I’m developing my simulator in C++ using a nice Qt GUI (Qt rocks ;-) ) and OpenGL for 3d rendering. This gives you all advantages of powerful OOP using C++ combined with powerful and easy to use Qt classes (that’s rapid application development my friends), and the big bonus is: everything is portable. The only OS dependent code is accessing the joystick device which I encapsulate via an abstract interface. So it’s easy possible to develop specialized subclasses for Windows, or other OSes. But for now I’ll concentrate on Linux of course.
Reading this may be a little bit dry, so here comes a first screenshot:

Helisim Screenshot

Helisim Screenshot

I also made a screencast to demonstrate the actual state in action.
It’s a little bit jerky, but that’s due to recording not due to the simulator ;-)
You can download it here: helisim.avi

Some more technical details for the interested reader:

  • Programming Language: C++/Qt
  • 3D Rendering: OpenGL
  • 3D Sound effects: OpenAL
  • Physics Engine: My own including correct aerodynamics according to the BEMT (Blade Element Momentum Theory) (Currently implemented is only BET without Momentum, still working on that.)
  • License: Will be GPL (should it be GPLv3?)

Here is a sample gnuplot picture which shows the lifting forces calculated by my physic engine.

Lifting force

Lifting force

And I have already a lot of ideas for the future:

  • The software should be very modular allowing not only the fly, but also use it as a developer platform: Adding or extending the physics engine, replacing the joystick input module with own implementations. Not only for portability but also for developing autonomous flight robots.
  • Improving the rendering with shadows and reflections: Cg may help
  • Also replacing the rendering with a 3D engine like Ogre might be possible (but I actually have no clue about ogre)
  • Making a game like mode with predefined gates to pass.
  • For the game mode a ghost would be nice which shows either the ideal flight line or the last recorded one.

I hope you like my idea and more input is welcome. Also I’m searching for a good name at the moment. HeliSim is not that creative name and may already exist ;-) So please send me your ideas: Lin, Tux, Heli, Sim, … are some good keywords as a starting point.

Qt Linguist Screencast

•November 24, 2008 • Leave a Comment

I made a little screencast to demonstrate how simple it is to translate C++ GUIs with Qt Linguist.

The movie was recorded with qt-recordmydesktop (a frontend to recordmydesktop) which uses the free theora video codec. The linux video players mplayer, xine, … support this codec out of the box. On Windows you should install VLC player from http://www.videolan.org/vlc to view it.

Download Linguist Screencast

ELF Lib Viewer

•August 13, 2008 • Leave a Comment

Normally on linux I just use ldd to list all direct and indirect dependencies of an executable.
objdump -X | grep NEEDED does also a good job in listing all direct dependencies.

On Windows there is a nice tool called Dependency Viewer which lists the dependencies in a tree view, to better see direct and inderect dependencies.

I googled a little bit and found a nice Qt based tool called ELFLibViewer which does the same job for ELF binaries on linux.

Howto renew a DHCP lease

•August 13, 2008 • Leave a Comment

A feature that most Windows users are missing on linux is ipconfig /renew to renew the DHCP lease.

There is a similar command ifconfig on linux that is used to configure the network interfaces. It has no renew option because ifconfig has nothing to do with DHCP.

There are different DHCP client implementations available. I’m using udhcpc (Micro DHCP Client) in conjunction with ifplug daemon which starts automatically the DHCP client software when a cable is plugged in and stops it when it’s unplugged. So renewing can be done by unplugging and plugging again.

But there is also a much simpler possibility. Udhcpc can be forced to renew the lease by receiving the SIGUSR1 signal. This can be done by kill -SIGUSR1 <PID>. To automate the process you can use this script.

1 #!/bin/sh
2 
3 # get pid of udhcpc
4 PID=`pidof udhcpc`
5 # renew dhcp lease
6 /bin/kill -SIGUSR1 $PID

Using Wacom Intuos3 Tablet with Gentoo Linux

•August 11, 2008 • 4 Comments

I’m now the proud owner of a new Intuos3 Tablet to use with GIMP for drawing and photo editing. This is really a great piece of hardware but like so often they don’t officially support linux but there is the linux wacom project that offers a Linux/X11 driver.

I configured my X Server according to this howto:

http://gentoo-wiki.com/HOWTO_Wacom_Tablet

which is pretty straight forward, the only exception is expresskeys.

So here is what I did to get it running.

  1. Configuring the kernel
    Activate the wacom driver in the kernel:

    Device Drivers --->
        Input device support --->
             Event interface
            [*] Tablets --->
                  Wacom Intuos/Graphire tablet support (USB)
  2. Installing linuxwacom driver for Xorg
    You need the new package linux-wacom-0.8.0_p3-r1, the default version that is actual in portage at this time linux-wacom-0.7.8_p3 doesn’t work. So you need to unmask the newer package before emerging.
  3. echo "x11-drivers/linuxwacom ~x86" >> /etc/portage/package.keywords
    Install the X11 driver.
    emerge -av linuxwacom
  4. Xorg Configuration
    Xorg needs to be compiled with wacom support. So add wacom to the INPUT_DEVICES section in your make.conf and re-emerge xorg-server.
    Example:
  5. /etc/make.conf
    INPUT_DEVICES="keyboard mouse wacom"
    installing:
    emerge -pv xorg-server (check dependencies)
    emerge xorg-server (do the install if everything is fine)

    It is recommended to don’t use SendCoreEvents for the pad. The important thing in xorg.conf is that I don’t use SendCoreEvents for all wacom devices, not just for the pad. Otherwise they didn’t work for me.

    Section "ServerLayout"
      Identifier "X.org Configured"
      Screen 0 "Screen0" 0 0
      InputDevice "Keyboard0" "CoreKeyboard"
      InputDevice "Touchpad" "CorePointer"
      InputDevice "PS2Mouse" "SendCoreEvents"
      InputDevice "cursor"
      InputDevice "stylus"
      InputDevice "eraser"
      InputDevice "pad"
    EndSection
    
    Section "InputDevice"
      Driver "wacom"
      Identifier "cursor"
      Option "Device" "/dev/input/wacom"
      Option "Type" "cursor"
      Option "USB" "on"
      Option "Vendor" "WACOM"
      Option "Mode" "Relative"
    EndSection
    
    Section "InputDevice"
      Driver "wacom"
      Identifier "stylus"
      Option "Device" "/dev/input/wacom"
      Option "Type" "stylus"
      Option "USB" "on"
      Option "Vendor" "WACOM"
      Option "tilt" "on" # add this if your tablet supports tilt
      Option "Threshold" "5" # the official linuxwacom howto advises this line
      Option "Mode" "Absolute"
    EndSection
    
    Section "InputDevice"
      Driver "wacom"
      Identifier "eraser"
      Option "Device" "/dev/input/wacom"
      Option "Type" "eraser"
      Option "USB" "on"
      Option "Vendor" "WACOM"
      Option "tilt" "on" # add this if your tablet supports tilt
      Option "Threshold" "5" # the official linuxwacom howto advises this line
      Option "Mode" "Absolute"
    EndSection
    
    Section "InputDevice"
      Driver "wacom"
      Identifier "pad"
      Option "Device" "/dev/input/wacom"
      Option "Type" "pad"
      Option "USB" "on"
      Option "Vendor" "WACOM"
      #Option "ButtonsOnly" "on"
    EndSection
  6. Make the pad working
  7. It is recommended to install expresskeys to get the pad keys working. I could not get it working but have found another simple solution.

    Regarding expresskeys: I tried expresskeys-0.4.2 but this version could not detect the wacom tablet although xidump -l shows it. So from the Xorg side it works. I found out that the a line in get_device.c must be changed to support the actual wacom driver version.

    Original:
    467 if (xdevice_list[i].use == IsXExtensionDevice)
    Changed:
    467 if (xdevice_list[i].use == IsXExtensionDevice ||
    468 xdevice_list[i].use == IsXExtensionPointer) {

    With this line the tablet gets detected but still does not work for me, I just get another error.

    Solution: You can map the tablet pad also to simple key strokes without expresskeys, this way I can use it in GIMP without any problems. Just use xsetwacom to configure your pad. I use the following script to setup the pad for GIMP.

    #!/bin/bash
    
    # set scrolling with ring
    xsetwacom set pad striplup "key core pgup"
    xsetwacom set pad stripldn "key core pgdn"
    
    # set zoom with ring
    xsetwacom set pad striprup "core key -"
    xsetwacom set pad striprdn "core key +"
    
    # Button  to Ctrl Z (undo)
    xsetwacom set pad Button3 "core key ctrl z"
    # Button FN2 to Ctrl Y (redo)
    xsetwacom set pad Button4 "core key ctrl y"
    # Button for pencil
    xsetwacom set pad Button5 "core key n"
    # Button for brush
    xsetwacom set pad Button6 "core key p"
    # Button for ink
    xsetwacom set pad Button7 "core key k"
    # Button for eraser
    xsetwacom set pad Button8 "core key shift e"
  8. Configuring GIMP
    You can configure GIMP using the menu File->Preferences, then choose the section “Input Devices” and click the button “Configure Extended Input Devices…”.
    In this dialog you can activate the stylus, cursor and eraser device by setting Mode to “Screen”, but don’t activate the pad device. This just works using keyboard shortcuts and don’t need any further configuration.
    Now the tablet should work with GIMP including pressure sensitivity, tilt sensitivity and the pad keys.
    I hope this blog could help you. Have fun with your new tablet ;-)

RegEx for replacing C++ single line comments with C Style comments

•July 18, 2008 • Leave a Comment

This is a very simple but usefull regular expression. Some compilers have problems with C++ comments like // comment. In ANSI C you writing comments like /* comment */. This can be a pain to replace manually.

But with regular expressions it’s easy. Vim example:

:%s#//\(.*\)#/*\1 */#

RegEx explained: Normally you are usig substitutions like s/pattern/replace/. The slash is the common delimiter, but you can also use the hash sign # so you don’t have to escape the slash characters in the pattern (e.g. s#pattern#replace#)

If you have to do this for multiple files you can of course also use find and sed for that job.

find . -name "*.h" -exec ./replace.sh {} \;

where replace.sh is a little shell script so that it is easier to write the sed expression.

replace.sh:

#!/bin/bash
cat $1 | sed -e ’s#//\(.*\)#/*\1 */#’ > $1.tmp
mv $1.tmp $1

Cygwin svn conflict with TSVNCache.exe

•July 18, 2008 • Leave a Comment

In my company we are developing portable software that runs on windows and linux (and could also run on other systems). I have written build scripts on linux that do an automatic checkout, compiles that software, generates API documentation and creates an installer.

The windows shell is not very powerfull and it’s nearly impossible to do the same things like with the bash. Aside from this I don’t want to maintain to different scripts which do actually the same for windows and linux.

Yesterday I modified the linux build scripts to run also on windows using cygwin. Cygwin is a great unix emulation for windows where my bash scripts work mostly out of the box. So I can use all the great tools like sed, grep, awk, … that normally are missing on windows.

The problem is, cygwin brings its own unix like svn.exe with it and this seems not to play good with my Windows TortoiseSVN version.

I tried to check out sources like

svn co https://someurl /cygdrive/e/mypath

but nothing apeared there. I found out using google that there is a problem when using it together with TSVNCache.exe. So I changed this to use a native windows commandline version of svn.exe.

The important thing is now that you can’t use unix style paths. You have to use Windows paths like E:\mypath. Of course Cygwin has a solution for converting this paths which is called ‘cygpath’. This tool can convert paths from unix to dos and vice versa.

Now the code looks like that:


1 URL_BASE=YourURL
2 SOURCE_DIR=`pwd`/src
3 if [ "$OS" == "Windows_NT" ]; then
4 SVN=`cygpath $PROGRAMFILES`/Subversion/bin/svn.exe
5 else
6 SVN=svn
7 fi
8 … Snip …
9 # This does the checkout for all modules
10 checkout() {
11 if [ "$OS" == "Windows_NT" ]; then
12 for folder in $folders; do
13 $SVN co $URL_BASE/$folder `cygpath -w $SOURCE_DIR/$folder` || { echo error, cancel operation“; exit 1; }
14 done
15 else
16 for folder in $folders; do
17 $SVN co $URL_BASE/$folder $SOURCE_DIR/$folder || { echo error, cancel operation“; exit 1; }
18 done
19 fi
20 }
21 … Snip …
22

How ext3grep can save you hours of work

•July 18, 2008 • 5 Comments

Linux files systems work great. Especially ext3 is a mature file system and very robust. With journaling turned the filesystems stays consistent also on an unexpected power loss or system crash (wich normally never happens on linux :-) ) and you don’t need long disk checks to repair the file system in such a case. There is almost no disk fragmentation and a lot of more cool features … But the best linux feature is: if you remove a file or directory it’s gone :-) It’s not moved to trash, its not marked as deleted, there are no annoying messageboxes, it just does what you say. I love that!
But from time to time also experienced users make mistakes and you delete something wrong. As Murphy’s law says: “if anything can go wrong it will” and so you will not have a copy of the deleted files and the backup will be outdated. So what to do now?
I want to explain the procedure by using the problem I had as example.

How the trouble came up for me

As usual I was working on my Gentoo Linux laptop. I just wanted to add a new folder with sources to my subversion repository. I wanted to add first the folder, then some files within the folder…

  1. Adding a folder to svn is simple, sometimes too simple…
    svn add uaconsoleclientsample

    Now I saw that this command added all files recursively, not just the folder. That means a lot of temporary files where added too.
    The good thing with svn is, everthing you change is just done on your local working copy and not on the server. So it’s not a problem until you commit your changes. So lets remove the wrong files again before committing the changes.

  2. Removing the files…
        svn remove uaconsoleclientsample
        svn: Use --force to override this restriction
        svn: 'uaconsoleclientsample' has local modifications

    Ok, remove didn’t work, use –force.

    svn --force remove uaconsoleclientsample

    Bad idea!!! The “svn remove” command not only removes files from scheduled add operations like I assumed. It removes it also from your local working copy.

    So now my uncommited files were lost. This was the time where ext3grep came into play.

Recover lost files with ext3grep

I knew every new file could overwrite the data of my deleted files. So quickly unmount the partition. (The great thing, linux users have multiple partitions. We can unmount /home and continue to work as root)

  1. Unmounting /home
    • Close my X Session
    • Alt-F1 -> log in as root
    • /etc/init.d/xdm stop
    • umount /home Cannot umount, files still in access
    • lsof | grep home -> artsd is still accessing home
    • killall artsd
    • umount /home Succeeded.
  2. OK, done. Nothing can delete any more data now. Now relax, breath through and go to another Desktop PC, start the browser and ask google for a solution. -> ext3grep Ok, lets try this out. Login into laptop from the desktop, that’s more comfortable, just copy paste URLs to the shell etc. ssh -l root laptop

  3. Installing ext3grep…
    wget http://ext3grep.googlecode.com/files/ext3grep-0.7.0.tar.gz
    tar -xvzf ext3grep-0.7.0.tar.gz
    cd ext3grep
    ./configure
    make
    cd src
    ./ext3grep --help

    Done, ext3grep is built and working

  4. Lets search for my deleted folder:My laptop has an LUKS encrypted hard disk, and I devided this encrypted partition using LVM. For that reason my home partition is not a physical one like /dev/hda, but /dev/mapper/vg-home. Replace that with your partition you are using.
  5. lt_gergap src # ./ext3grep /dev/mapper/vg-home --search uaconsoleclientsample
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Blocks containing "uaconsoleclientsample": 240017 242352 242355 242356 (allocated) 242357
    (allocated) 242358 (allocated) 242359 255079 (allocated) 336393 336518 336526 395434 395435
    395457 (allocated) 737282 (allocated) 984250 1346129 1868670 (allocated) 1869273 (allocated)
    1950436 3915933 3915935 4069411 4087953 4216611 4292193 4292196 4292275 4530219 4538370
    4538371 4538372 4538376 4538378 4538382 4538385 4543743 4543750 4543752 4544514 4544517
    4544528 4544539 4550683 4550707 4655509 4655533 4670417 4670423 4689385 4689746 4785120
    5046823 6525842 (allocated) 7370457 7805912

    Wow, there are a lot of blocks. Why are some allocated? Lets check them all.

    lt_gergap src # ./ext3grep /dev/mapper/vg-home --ls --block 240017
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Group: 7
    Block 240017 is Unallocated.

    Hmm, seems not to be a directory, at least it contains nothing. Try the next one …

    This operation takes some time and there are a lot of blocks. I’m lazy and before I do something twice I write a little script to automate this procedure.


    1 #!/bin/sh

    2

    3 blocks=255079 336393 336518 336526 395434 395435 395457 737282 984250 1346129 1868670 1869273 1950436 3915933 3915935 4069411 4087953 4216611 4292193 4292196 4292275 4530219 4538370 4538371 4538372 4538376 4538378 4538382 4538385 4543743 4543750 4543752 4544514 4544517 4544528 4544539 4550683 4550707 4655509 4655533 4670417 4670423 4689385 4689746 4785120 5046823 6525842 7370457 7805912

    4

    5 for block in $blocks; do

    6 ./ext3grep /dev/mapper/vg-home –ls –block $block | tee -a output.txt

    7 done

    This script does the same procedure for each block in the list, shows the output on console and writes it to the file output.txt using tee. This way you can recheck the result later also in vim.

    Analyzing the file output.txt I have seen only one interesting block:

    ...
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Group: 57
    
    Block 1869273 is a directory. The block is Allocated
    
              .-- File type in dir_entry (r=regular file, d=directory, l=symlink)
              |          .-- D: Deleted ; R: Reallocated
    Indx Next |  Inode   | Deletion time                        Mode        File name
    ==========+==========+----------------data-from-inode------+-----------+=========
       0    1 d  657336                                         drwxr-xr-x  .
       1    2 d  657111                                         drwxr-xr-x  ..
       2    3 d  657337                                         drwxr-xr-x  .svn
       3    4 d  657345                                         drwxr-xr-x  qtestclient
       4    5 d  657354                                         drwxr-xr-x  uaserverc
       5    6 d  657444                                         drwxr-xr-x  performanceclient
       6    7 d  657534                                         drwxr-xr-x  uademoserver
       7    8 d  657687                                         drwxr-xr-x  comdaproxy
       8    9 d  657696                                         drwxr-xr-x  examples_bin
       9   10 d  657903                                         drwxr-xr-x  uaconsoleclient
      10   11 d  672247                                         drwxr-xr-x  uaconsoleclientcpp
      11   12 d  672766                                         drwxr-xr-x  demoserver
      12   13 d  672784                                         drwxr-xr-x  uaserver
      13   14 d  657946                                         drwxr-xr-x  ascserver
      14   15 d  672981                                         drwxr-xr-x  server_ads
      15   16 d  657947                                         drwxr-xr-x  uaexpert
      16   18 d  657949                                         drwxr-xr-x  uasimpleclient
      17   18 d  675465  D 1215690762 Thu Jul 10 13:52:42 2008  drwxr-xr-x  bin
      18  end d  656495                                         drwxr-xr-x  uaconsoleclientsample
    ...

    Yes, there it is. Let’s check the contents of this folder.

    lt_gergap src # ./ext3grep /dev/mapper/vg-home --ls --inode 656495
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Inode is Allocated
    Loading vg-home.ext3grep.stage2.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
    WARNING: Rejecting a dir_entry (block 5714387) because it contains legal but unlikely characters.
    Use --ls --block 5714387 to examine this possible directory block.
    If it looks like a directory to you, and '24'
    looks like a filename that might belong in that directory, then add
    --accept='24' as commandline parameter AND remove both stage* files!
    ........................................................................................................................................................................................... done
    The first block of the directory is 1348508.
    Inode 656495 is directory "kde4/work/opcua/applications/uaconsoleclientsample".
    Directory block 1348508:
    .-- File type in dir_entry (r=regular file, d=directory, l=symlink)
    |          .-- D: Deleted ; R: Reallocated
    Indx Next |  Inode   | Deletion time                        Mode        File name
    ==========+==========+----------------data-from-inode------+-----------+=========
    0    1 d  656495                                         drwxr-xr-x  .
    1   11 d  657336                                         drwxr-xr-x  ..
    2    4 r 2328216  D 1215690762 Thu Jul 10 13:52:42 2008  rrw-r--r--  Makefile
    3    4 r 2263308  D 1215690762 Thu Jul 10 13:52:42 2008  rrw-r--r--  main.cpp
    4    5 r 2328213  D 1215690762 Thu Jul 10 13:52:42 2008  rrw-r--r--  qdevelop-settings.db
    5   11 r 2328221  D 1215690762 Thu Jul 10 13:52:42 2008  rrw-r--r--  uaconsolesampleclient.pro
    6    7 r 2328215  D 1215690762 Thu Jul 10 13:52:42 2008  rrw-r--r--  main.o
    8    9 d  675466  D 1215690762 Thu Jul 10 13:52:42 2008  drwxr-xr-x  moc
    9   11 r 2262157  D 1215690762 Thu Jul 10 13:52:42 2008  rrwxr-xr-x  uaconsolesampleclient
    10   11 d  675465  D 1215690762 Thu Jul 10 13:52:42 2008  drwxr-xr-x  PKI
    11  end d  656701                                         drwxr-xr-x  .svn
    12  end r 2263307  D 1215690762 Thu Jul 10 13:52:42 2008  rr--r--r--  .main.cpp.swx

    Yes, everything is there. Now just restore the files you want using the right inode.

    lt_gergap src # ./ext3grep /dev/mapper/vg-home --restore-inode 2263308
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Restoring inode.2263308
    mv RESTORED_FILES/inode.2263308 /home/kde4/work/opcua/applications/uaconsoleclientsample/main.cpp
    lt_gergap src # ./ext3grep /dev/mapper/vg-home --restore-inode 2328221
    Running ext3grep version 0.7.0
    Number of groups: 240
    Minimum / maximum journal block: 1547 / 35890
    Loading journal descriptors... sorting... done
    Journal transaction 1202732 wraps around, some data blocks might have been lost of this transaction.
    Number of descriptors in journal: 30993; min / max sequence numbers: 1202700 / 1204860
    Restoring inode.2328221
    mv RESTORED_FILES/inode.2328221 /home/kde4/work/opcua/applications/uaconsoleclientsample/uaconsolesampleclient.pro</pre

That’s all. ext3grep did a great job for me. Thanks to the developers of that tool.

Use svn the correct way
Adding just a folder to svn would have been easy. Just use the -N option to work non recursive way.

svn add -N uaconsoleclientsample