21 października 2013

Removing all empty directories from SVN tree

Application development is really complex process. Many thousands lines of code are placed in different files. Every bunch of files is gathered inside of some directory. Sometimes code needs some little modifications or biger refactoring. There are some reasons why some classes are moved to totally different packages. Empty directories should be removed from project tree but sometimes it doesn't happen. When we're using Git it's not the problem. Git SCM doesn't understand what is an empty directory and removes it when all files from it are moved to different location. The case is somewhat different for SVN. All empty directories are stored in repository. They exists and are versioned. Looking for empty directories manually can be really painfull. Fortunatelly there's some simple way to deal with this kind of issue. Just one command executed in BASH terminal can remove all unnecessary directories
find . -name .svn -type d | while read ss; do dir=$(dirname "$ss"); test $(ls -a "$dir" | wc -l) == 3 && echo "svn rm \"$dir\""; done
How it works? The
find . -name .svn -type d
searches for directories named .svn. All results of searching are passed through the pipe to the shell and checks what shows the
ls -a "$dir"
command. If call to ls returns only ".", ".." and ".svn" then directory is deleted.

17 sierpnia 2013

CheckBoxTableCell in JavaFX

After a few hours with documentation and digging through the Internet resources I finally found a solution for creating a table containing column with CheckBox components. It's pretty simple if you know a few things:

  • first of all, there's javafx.scene.control.cell.CheckBoxTableCell component which can render what you want 
  • second, when you're using javafx.scene.control.cell.CheckBoxTableCell don't forget to define cellValueFactory and use myBooleanValueProperty method instead of getMyBooleanValue.
  • and the last, if you want to implement own solution like this

public void updateItem(Boolean item, boolean empty) {
    super.updateItem(item, empty);
    if (!isEmpty()) {
the view will render CheckBoxes for empty rows - you have to implement removing CheckBox.

The simple code which uses CheckBoxTableCell can looks like this

<?import javafx.scene.control.cell.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.GridPane?>
<?import pl.kmi.controls.CheckBoxCellFactory?>
<GridPane fx:controller="pl.kmi.CustomCheckBoxTable"
          xmlns:fx="http://javafx.com/fxml" alignment="center">

    <TableView fx:id="customTable" GridPane.columnIndex="0" GridPane.rowIndex="0">
            <TableColumn fx:id="payedColumn" prefWidth="100">
                    <PropertyValueFactory property="checked"/>
and the Java
public class CheckBoxCellFactory2 implements Callback, TableCell> {
    public TableCell call(TableColumn stTableColumn) {
        CheckBoxTableCell checkBoxCell = new CheckBoxTableCell();
        return checkBoxCell;
public class TableRowModel {

    /* Some other fields... */
    private BooleanProperty checked;

    public CostTableRowModel(BooleanProperty checked) {
        this.payed = checked;

    public BooleanProperty payedProperty() {
        return payed;
    /* Other getters and/or setters */

31 grudnia 2012

Scala interpreter after Fedora 17 update

Monday, 10:45 AM. I'm at work. Building module and running performance tests. Something goes wrong. There's an error in Scala code. Have to check it quickly with interpreter. Updated Fedora 17. Typing "scala" in opened terminal window.
/usr/bin/scala: error: JVM_LIBDIR /usr/lib/jvm-exports/java does not exist or is not a directory
I checked mentioned directory and it doesn't exist. Next step:
whereis scala
scala: /bin/scala /usr/bin/scala /usr/share/scala /usr/share/man/man1/scala.1.gz
Checking Scala interpreter launcher
sudo vim /bin/scala
Gotcha! Line 50.
export JAVA_HOME=/usr/lib/jvm/java/
Changing it to
export JAVA_HOME=/usr/java/default/
Now, just save and it's done.
Welcome to Scala version 2.9.2-unknown-unknown (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.

Yes, it glows!

11 grudnia 2012

Triple search string in search engine for Chrome

During the evening reading I've received a phone
-Something is wrong with my browser. When I type something in search bar, it redirects me to the search page with results for word repeated three times! First thought: "yeah, right". When I saw it with my own eyes, I started to wonder what's wrong with the browser. What was wrong? Chrome -> Settings -> Search engines management -> Google (default). The entry that I saw looked like this
The valid one is showned below

10 grudnia 2011

Ubuntu 64-bit - adb: No such file or directory

Recently I came across an interesting case related to installation of the Android SDK. Very simple process ended without any errors, but after first try of launching tool the Eclipse ADT plugin had thrown an error with message which says that adb could not be found. The first attempt to investigate - try to run adb from the command line. Unfortunatelly it's not working - "./adb: No such file or directory". Next step. I'm a little bit closer to the cernel of darkness:
file ./adb 
./adb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped
. File really exists and can be accessed in a normal way. Last try and everything is clear. 64-bit Linux has some problems with running 32-bit application. Instalation of ia32-libs solves the problem and I can back to work.