Changing default Look’n’Feel for Netbeans (and the GUI builder)

Netbeans’ GUI builder is great. It’s one of the essential features that made me drop eclipse.

But designing accurate GUIs can be a pain in the arse. Especially, when you use the GUI builder with a certain preview Look and Feel (e.g. GTK+) but you application later runs with a completely different L’n’F (e.g. Nimbus). It’s almost certain, that your design will look rather ugly. Unless you want to design your GUI manually (which isn’t a bad idea, btw.), you have to make sure, your design preview and application match.

While changing the L’n’F in your application is quite simple, changing Netbeans’ L’n’F (and therefore the GUI builder’s L’n’F ) is rather tricky. The easiest way is probaly the --laf flag:

$ netbeans --laf Nimbus

If you want to start Netbeans in Nimbus-mode per default, just add --laf Nimbus to netbeans_default_options in ~/.netbeans/6.5/etc/netbeans.conf.

If the file doesn’t yet exists

mkdir -p ~/.netbeans/6.5/etc/ 
echo netbeans_default_options=\"--laf Nimbus\" >> ~/.netbeans/6.5/etc/netbeans.conf

Making Windows use CUPS printer

      No Comments on Making Windows use CUPS printer

This is as straightforward as setting up a network printer from Windows.

Go to Start → Settings → Printers and Faxes. Click on Add a printer. Tell the wizard that you wish to add a network printer. Specify that you want to Connect to a printer on the Internet or on a home or office network. Specify the URL of your printer:

Where in printer-name you should replace the name of your printer. Complete the installation of your printer by specifying the driver to be used. You should now be able to print from your Windows.

Don’t forget to adjust your /etc/cups/cupsd.conf to allow remote printing or use system-config-printer an click on Server → Settings → Settings → Publish shared printers[…] → Allow printing from the Internet


Installing phpMyAdmin on CentOS [Update]

      No Comments on Installing phpMyAdmin on CentOS [Update]

Because CentOS doesn’t pull all dependencies correctly, here is my little memory hook for installing phpmyadmin (and mysql, of course)

rpm -Uvh
yum install php phpmyadmin php-mcrypt php-mbstring mysql-server

After installing the packages, edit /etc/httpd/conf.d/phpmyadmin.conf and add the IP of your admin workstation to the line that begins with Allow from.

For using phpmyadmin with cookie auth, you have to set a blowfish secret in /usr/share/phpmyadmin/

$cfg['blowfish_secret'] = 'Secret_Password';

Update: Added php-mbstring

Resetting MySQL root password

      No Comments on Resetting MySQL root password

It shouldn’t happen, but it does: I forgot my MySQL root password. Resetting is rather simple. Stop the running mysqld instance and restart it in safe mode:

# mysqld_safe --skip-grant-tables &

You can now log in as root without a password:

# mysql --user=root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> update mysql.user set Password=PASSWORD('your_new_root_password') where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> quit;
# pkill mysqld

Don’t forget restart the mysql server and clear ~/.mysql_history afterwards!

Adjusting your fanspeed with trinity (lm_sensors, pwmconfig and fancontrol)

Modern CPU throttling technology like Intel’s SpeedStep or AMD’s Cool’n’Quiet are quite fancy. They not only reduce the CPU frequency and the core voltage, the mainboard also detects an idling, cool CPU and therefore reduces the fanspeed.
But what if the fanspeed is still to high while the CPU is doing nothing? Or maybe the fan doesn’t spin fast enough while your CPU is burning in a very small case.

Continue reading

Mounting xen images

      1 Comment on Mounting xen images

Mounting images that contain only one partition is rather easy. But how to mount image with multiple partitions? kpartx is the solution!

You can list all partitions within the image with

# fdisk -l /vm/dhcpd.img 
Disk /vm/dhcpd.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

        Device Boot      Start         End      Blocks   Id  System
/vm/dhcpd.img1   *           1         127     1020096   83  Linux

kpartx can be used to create maps from the block devices

kpartx -a /path/to/xen/image.img

And those maps can be mounted as usual

mount -o rw /dev/mapper/loop0p1 /mnt/

scp from stdin

      9 Comments on scp from stdin

Unfortunately, there is no way to pipe data directly to scp simply because scp can’t read from stdin. But you can abuse ssh to achieve the same result

tar cz a/dir | ssh "cat >outfile.tar.gz"

You can even do some funny things like

tar c /data/ | lzma -c -z |\
gpg --batch --force-mdc -ac -o - --passphrase-fd 3 -c 3< /etc/gpgpassphrase |\
ssh "cat >/data/backup.tar.lzma.gpg"

Java Generics and Comparables

      No Comments on Java Generics and Comparables

When designing a generic class which needs a parameter that is comparable you will probably end up with something like this:

public interface Page<K extends Comparable<K>>
public class LocalPage<K extends Comparable<K>> implements Page<K>

Unfortunately, using Comparable isn’t as “easy”. The Page interface described above can’t be instantiated for a type like java.sql.Time, which is not Comparable to itself, but to a supertype (i.e., java.sql.Time implements Comparable<java.util.Date>).
David Hall suggests: “If you’re going to declare types that implement Comparable, you probably need to be in the habit of writing the declaration as:”

public interface Page<K extends Comparable<? super K>>
public class LocalPage<K extends Comparable<? super K>> implements Page<K>