Thursday, October 18, 2012

Netbeans 7.3 crashes on fedora 17

After installing the new netbeans 7.3 i noticed that it often (almost always) crashes while starting up. Sometimes it doesn't even show a splash screen.
I figured out that this is because of the openJDK. After installing and setting up Oracles JDK everything worked fine.
Download the latest JDK from oracle. And install the package it using rpm.
rpm -Uvh jdk-*
Then install it with the alternatives command
## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_07/jre/bin/java 20000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_07/jre/bin/javaws 20000
 
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_07/jre/lib/i386/libnpjp2.so 20000
 
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_07/jre/lib/amd64/libnpjp2.so 20000
 
## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_07/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_07/bin/jar 20000
Now you can set up Oracles JDK as your default java runtime using this command.
alternatives --config java
Try to start Netbeans, it should start without crashing or freezing.

Find all backup files (ending with ~) in your home directory

Every Linux users who edits text files using some "traditional" editors like vi, emacs, kate or gedit will find some backup files which end with ~ in his directory. These files are not really needed anymore and can be deleted. I personally like to look at these files before i delete them. This is a simple script to find these files and show their size.

for i in $(find ~ -name '*~'); do echo ${i}; stat -c %s ${i}; done
If you don't need this files anymore you can delete them with this command
find ~ -name '*~' | xargs rm

Wednesday, October 3, 2012

Fork bomb

This is nothing useful though i think it's interesting. As i saw it, it reminded me of one of my first batch files: The infinite loop of starting new command prompts. But this one is much more elegant.

:() { : | :& };:

The code declares a function called : which calls itself two times using a pipe. At the end you call : again. This leads to an exponential spawn of new processes. It won't finish unless there your system can't spawn more processes and this only happens if you run out of resources. That could force you to restart your computer. As i said nothing useful...

Monday, August 27, 2012

Trigo Calc released

TrigoCalc is a tool which uses trigonometry formulas to find the missing numbers in a triangle. TrigoCalc doesn't just provide the results it also shows the computations in a human readable format. Therefore it's specially useful for students.

There is an offline version, which requires jre 7 but there is also an online version that just requires a browser. The online version also runs on smart phones.
View the TrigoCalc website.

Thursday, July 26, 2012

Django syncdb can't create super user

I was just setting up a new webpage using the django framework. But as i used the syncdb command (which creates the database and also adds a superuser) i received this error:
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username    
return getpass.getuser().decode(locale.getdefaultlocale()[1])

The site was working normal but i couldn't add any content without a super user account.

manage.py createsuperuser --username=joe --email=joe@example.com
Didn't help a lot since i received the same error. So i used the shell to create a user manually:

$ python manage.py shell
>>> from django.contrib.auth.models import User
>>> users = User.objects.all()
>>> users
[]

No users here, so let's create a new superuser.
>>> u = User.objects.create_user('benny', 'benny@bgaechter.ch', 'bennypw')
>>> u.is_staff  =  True
>>> u.is_superuser = True
>>> u.save()
Now you should be able to login. Note: You should not use the "set_password" function to change a users password. There is a special command for that:

manage.py changepassword username

Tuesday, July 3, 2012

Netbeans: JVM creation failed

Netbeans seems to have a problem if your 64 bit system has more than 4 GB RAM. Obviously it can't address the memory and quits with "JVM creation failed".

The solution is very easy. Just go to the netbeans.conf file. On Linux this is typically in the /etc directory. On Windows you have a folder called etc in your application folder (should be in C:\Program Files (x86)\Netbeans ). Open it with your preferred editor and add -J-Xmx512m to netbeans_default_options (at line 6). It should now look like this:


netbeans_default_options=".... -JDsun.zip.disableMemoryMapping=true -J-Xmx512m"

Save and close the file and Netbeans should start again.

Thursday, April 5, 2012

KDE Shut down, Log out and Restart not working

As I switched to KDE a few days ago, the Shut down didn't work. I found out that this is because of some strange interaction between the sound system and the log out mechanism. However to avoid this bug just disable the log out sound in your system settings.
Go to System settings ->Notifications ->Select KDE Workspace in the Event Source drop down menu and disable the logout sound.