sobota, 23. marec 2013

Ubuntu: How to change the location of various default directories


If you want to change the location of the Desktop, Documents, Download, ... directories:
vi ~/.config/user-dirs.dirs

nedelja, 24. februar 2013

Finding bad blocks on hard drive in Linux

Run:

  • sudo badblocks -v /dev/sda1 > bad.block
  • sudo fsck -t ext4 -l bad.block /dev/sda1
badblocks is part of the e2fsprogs package in Ubuntu. The first command will find all bad blocks that you may have on /dev/sda1 and the second one will try to move data found in bad blocks to another place. If it can't then the file may be corrupted and lost.

petek, 22. februar 2013

Pass all script arguments to another script

When you want to pass all the input arguments to another script or program you can do it like this:

  • in bash use "$@"
  • in bat use %*

From Kubuntu to Ubuntu

Steps:

  • sudo apt-get install ubuntu_desktop
  • change display manager to lightdm as described in Change Linux display manager
  • change lightdm greeter theme as described in Change lightdm greeter theme
  • set ubuntu boot splash screen:
    • sudo update-alternatives --set default.plymouth /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth
    • sudo update-alternatives --set text.plymouth /lib/plymouth/themes/ubuntu-text/ubuntu-text.plymouth

četrtek, 21. februar 2013

Change Linux display manager

You can have mulitple diplay manager installed at any time:

  • gdm
  • lightdm
  • kdm
You can switch between them:
  • if you have gdm running then use
sudo dpkg-reconfigure gdm

  • if you have kdm running then use
sudo dpkg-reconfigure kdm 

  • if you have lightdm running then use
sudo dpkg-reconfigure lightdm

Change lightdm greeter theme

Run
sudo vim /etc/lightdm/lightdm.conf
and change

greeter-session=unity-greeter
to
greeter-session=lightdm-gtk-greeter
or something. There are multiply *-greeter packages you can install and use

Disable scrollbar overlay in Ubuntu

In 12.04:
gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars false

In 12.10:

gsettings set com.canonical.desktop.interface scrollbar-mode normal

And to return to the default settings:
gsettings reset com.canonical.desktop.interface scrollbar-mode

All commands are run from console



Touchscreen calibration under Linux

If you have a touchscreen and want to caibrate it follow this steps:

  • sudo apt-get install xinput-calibrator
  • run it. You can run it from console or find it somewhere in your menu
  • after calibration you will get an output in your console and the line you should copy looks something like this:
    Option "Calibration" "77 3935 115 3984"
  • sudo vi /usr/share/X11/xorg.conf.d/10-evdev.conf and copy previous line in touchscreen section:
    Section "InputClass"        Identifier "evdev touchscreen catchall"
            MatchIsTouchscreen "on"        MatchDevicePath "/dev/input/event*"        Driver "evdev"        Option "Calibration" "77 3935 115 3984"EndSection
I've used xinput_calibrator on Ubuntu 10.11 and 12.04.

sreda, 13. februar 2013

torek, 1. januar 2013

2013

I wish a happy new year 2013 to all of you out there.

sreda, 14. november 2012

Running sudo command without password

What I found out is that running a command using sudo without entering password there are two options:

  • echo PASSWORD | sudo -S COMMAND
  • adding following lineto /etc/sudoers:
username ALL=(ALL) NOPASSWD: COMMAND
Please note that this has to be after all group definitions.
You can check what sudo priviliges you have using
sudo -l
For this case this gives:
(ALL) ALL
(ALL) NOPASSWD: COMMAND 
This means that all command require password except for the COMMAND. If we would put the username definitin before group definitions sudo -l would give:
(ALL) NOPASSWD: COMMAND
(ALL) ALL
This would still require password for all commands.

sreda, 7. november 2012

Find where code was changed in Mercurial

If you want to find out in which revisions a piece of code was changed then you can use a Mercurial command something like this:

hg grep --all PIECE_OF_CODE | awk 'BEGIN {FS=":"} {print $1" "$2}' | uniq
and you will get back a list of files with coresponding revisuin numbers:
repo/src/java/com/kovica/File1.java 30
repo/src/java/com/kovica/File1.java 10

torek, 6. november 2012

Remove empty lines from a file on Linux using command line

This one is especially useful when searching through Glassfish's log files.
There are many ways you can remove empty lines from a file:

  • awk 'NF' file
  • sed '/^$/d' file
  • grep "^$" -v file
  • grep . file
  • egrep "^[[:space:]]?$" -v file
  • perl -n -e 'print unless /^\s*$/' file
And I'm sure there are many more. :)

torek, 9. oktober 2012

Convert author in Mercurial repositiories

This is a summary of StackOverflow question http://stackoverflow.com/questions/12136895/change-the-author-in-mercurial-history


- cd repo1/.hg
- vi .hgrc and add
        [extensions]
        hgext.convert=
- cd $HOME
- vi authors.convert.list
        USER1 =USER2
- hg convert --authors $HOME/authors.convert.list repo1 repo1.NEW

Merge two mercurial repositories into one

This is a summary of a StackOverflow question http://stackoverflow.com/questions/12109203/merge-different-repositories-into-one


cd repo2
mkdir repo2
hg rename * repo2
hg commit -m "Move repo2 files into a subfolder"
cd repo1
hg pull -f path\to\repo2
hg merge
... and deal with merge conflicts if any ...
hg commit -m "Merge with repo2"

Glassfish: Run asadmin from Java program

When you execute asadmin on a secure enabled server you have to provide admin username and password. This can be a bit of a PITA if you are calling asadmin from a Java program.
You have two options:

  1. Create $HOME/.asadminpass:
    asadmin://admin@localhost:4848 BASE64_ENCODED_PASSWORD
  2. Or you can pass the file with the password with every asadmin command:
    1. Create glassfisg.password file:
      AS_ADMIN_PASSWORD=PLAIN_ADMIN_PASSWORD
    2. If you are on Linux it is a good idea to make the file readable only to your user:
      chmod 600 glassfish.password
    3. Execute asadmin command:
      $com.sun.aas.installRoot/bin/asadmin --user admin --passwordfile PATH_TO_PASSWORD_FILE list-applications
$HOME is a home directory of a user under which Glassfish is running.
$com.sun.aas.installRoot is the installation directory of Glassfish. It is only set on a Glassfish process.

OpenMQ: Create queues from Java program

When you execute imqcmd command from OpenMQ you have to provide username and password, which is a bit of a PITA if you are calling the imqcmd from Java programs.
This is the recipe you can use to get around this problem:

  1. Create a file calles imqCmd.password with following content:
    imq.imqcmd.password=ADMIN_OPENMQ_PASSWORD
  2. If you are on Linux it is a good idea to make the file readable only to your user:
    chmod 600 imqCmd.password
  3. Run the commands for queue creation:
    $com.sun.aas.imqBin/imqcmd create dst -n MyQueue -t q -o "maxNumMsgs=1000" -o "limitBehavior=FLOW_CONTROL" -o "maxNumMsgs=-1" -o "localDeliveryPreferred=false" -o "useDMQ=true" -o "validateXMLSchemaEnabled=false" -u admin -passfile PATH_TO_PASSWORD_FILE
  4. You can also delete the queue:
    $com.sun.aas.imqBin/imqcmd destroy dst -n MyQueue -t q -f -u admin -passfile PATH_TO_PASSWORD_FILE
com.sun.aas.imqBin is a System property that tells you where you can find imqcmd and other OpenMQ executables. It is only set on a Glassfish process.

Interesting Glassfish system properties


Properties:

  • com.sun.aas.imqBin: here you find executables from OpenMQ
  • com.sun.aas.agentRoot: here you find directory for nodes
  • com.sun.aas.productRoot: installation directory of Glassfish
  • com.sun.aas.configRoot: directory where Glassfish keeps config files
  • com.sun.aas.imqLib: library directory of OpenMQ
  • com.sun.aas.domainsRoot: directory of Glassfish domains
  • com.sun.aas.instanceRoot: directory of the current domain

ponedeljek, 24. september 2012

suspend/hibernate from command line

If you want to put your computer to hibernate from command line you have several options:
  1. echo disk | sudo tee /sys/power/state
  2. pm-hibernate
  3. pmi action hibernate #have to do sudo apt-get install powermanagement-interface before using it
If you want to put your computer to suspend from command line you have several options:
  1. echo mem | sudo tee /sys/power/state
  2. pm-suspend
  3. pmi action suspend #have to do sudo apt-get install powermanagement-interface before using it

nedelja, 23. september 2012

Toggle touchpad under Linux

If you want to toogle touchpad device under Linux, you have to do this:
sudo apt-get install unclutter

Put following lines into toggleTouchpad.sh:
          #!/bin/bash
deviceName="AlpsPS/2 ALPS DualPoint TouchPad"
isEnabled=`xinput --list-props "$deviceName" | grep -e "Device Enabled.*1$"`
if [ -n "$isEnabled" ]; then
    echo Disabling touchpad $deviceName
    xinput --set-prop "$deviceName" "Device Enabled" 0
    unclutter &
else
    echo Enabling touchpad $deviceName
    killall unclutter
    xinput --set-prop "$deviceName" "Device Enabled" 1
fi
 
Name of my touchpad device is AlpsPS/2 ALPS DualPoint TouchPad. You can find the list of all input devices issuing
xinput list
then you just have to guess what device it is :)
Then you can link this bash script to a keyboard shortcut and you are done.

There is also another way of doing this. Issu following command
synclient  TouchpadOff=1
If this command disables your touchpad then toogleTouchpad.sh might look like this:
#!/bin/bash

isEnabled=`synclient | grep -e ".*TouchpadOff.*0$"`

if [ -n "$isEnabled" ]; then
    echo Disabling device
    synclient TouchpadOff=1
    unclutter &
else
    echo Enabling device
    killall unclutter
    synclient TouchpadOff=0
fi
 

četrtek, 13. september 2012

Ubuntu 12.04.1 LTS and "Waiting for network configuration"

If you are running an Ubuntu 12.04.1 server and you see "Waiting for network configuration" message during boot and then another one "Waiting for 60 moreseconds for network configuration" then you have udev configured wrongly.

I got this error while cloning a VirtualBox VM and reinitializer MAC address for the network card. But if you have physical server, you probably changed network cards, ...

The solution is to check the file /etc/udev/rules.d/70-persistent-net.rules and see if you have more entries that you should have or the name of the subsystem is not the same as the network interface configured in /etc/network/interfaces or the MAC address is not right.

sreda, 5. september 2012

Theme change

I think it is time to change appearance of this blog. :)
What do you think?

sreda, 29. avgust 2012

JellyBean with multiple users

If you have a rooted Android phone running Jelly Bean, then you can have multiple users, just like on a regular Linux machine. :)
If you want to add a user then open terminal emulator and type:

  1. su
  2. pm create-user foo
Press and hold the power button and you'll be able to select your newly created user.
If you want to list all users on the system then open terminal emulator and tpe:
  1. su
  2. pm list-users
If you want to remove a user then open terminal emulator and type:
  1. su
  2. pm list-users and remember the number before user foo
  3. pm remove-user 1

pm list-users gives something like:
Users: 
                UserInfo{0:Primary:3}
                UserInfo{1:foo:3}

petek, 24. avgust 2012

Prevent user from running su

If you want to prevent user foo from running command su then do this:

  1. sudo grouadd nosu
  2. sudo usermod -a -G nosu foo
  3. sudo vi /etc/pam.d/su and uncomment
    auth required pam_wheel.so deny group=nosu

sobota, 18. avgust 2012

Required property "db.example.com" is unknown host. ERRORCODE=-4222, SQLSTATE=08001

If DB2 JCC driver throws mentioned error this means that it cannot resolve db.example.com. You should check your DNS settings.

sreda, 25. julij 2012

NetBeans 7.2

NetBeans 7.2 is out!
Go grab it while it's hot. :)
New&Noteworthy page can be found here.

I hope you'll enjoy it as much as I do!

ponedeljek, 23. julij 2012

com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException

If you get 
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.13.80] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream.  Error location: Reply.fill() - insufficient data (-1).  Message: Insufficient data.. ERRORCODE=-4499, SQLSTATE=08001

then this usually means you are using a connection pool to get connections to database and that connections in the connection pool are "stale".
What does stale mean?
You have connection pool started, connections created, but then database restarts. The connection you now get out of the connection pool are now stale and you have to restart the connection pool (close all connections and create new ones).


nedelja, 27. maj 2012

Sourcing .bashrc in non-interactive shell

This is a new post in a long, long time. A lot has happened since New Year. I'll post about that at a later date. :)

Now to using bash under Linux.
When you are running a bash session in a terminal you are inside of an interactive environment and you can edit .basrc and source it at any given time.
You source .bashrc like this:
source ~/.bashrc or . ~/.bashrc
Now, let's say you have a bash script that you want to run. You can run in in a terminal, but that is not the subject of this post. You can run it via a file manager, like Dolphin, thunar, ... or you can put a shortcut to it on your desktop.
If you want to source .bashrc in that script, it won't work, because running via file manager or desktop is running a bash script in an non-interactive environment. .bashrc notices that and does not do anything. In fact if you look at .bashrc you will find something like this:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
at the beginning of you .bashrc.
But there is a solution for this. Put PS1='$ ' in your script before sourcing .bashrc.
Examples:
- run a terminal
- edit .bashrc and put 
export TEST_TEXT='My test text' in your .bashrc
- make a new script test.sh:
#!/bin/bash
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
- make it executable
chmod +x test.sh
- run it and you should get something like this:
TEST_TEXT = 
- now source .bashrc and run the test.sh script
. ~/.bashrc
./test.sh
- and you get
TEST_TEXT = My test text
If you run this script via file manager you will always get TEST_TEXT = 
Change the script to 
#!/bin/bash
PS1='$ '
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
and .bashrc will get source everytime you run it.

nedelja, 1. januar 2012

2012

Let 2012 be a special one.
My New Year's resolution was also to blog more ofter with some interesting dtuff about Linux, version control, Java, ....

četrtek, 27. oktober 2011

Xmarks

Usually I'm using two web broswers: Firefox and Chrome. I always tried having one bookmarks set. I never found a way to share them between those web browsers. I've tried exporting bookmarks from one browser and importing into another, but that didn't feel right. Luckly, yesterday I found Xmarks. Now my bookmarks are in the cloud :)) and I can share them easyly between Firefox and Chrome, since Xmarks has plugins for both.

torek, 14. junij 2011

KDE Konsole

I've been a happy KDE user since the eary days of it.
I've also used Konsole as my primary terminal application, but in recent Kubuntu releases it became slow.
Yesterday I switched to good old xterm with screen:
xterm -bg black -fg grey -fn -*-console-*-*-*-*-*-*-*-*-*-*-*-* -geometry 166x45


and in xterm I start screen with 10 sessions.
Now everything is fast again. :)

sobota, 16. april 2011

Is my application running?

A neat way to check if a instance of an application is already running is to use FileChannel and it's ability to lock it.
An example:
File lockFile = new File("APP_NAME.lock");
FileChannel fileChannel = new RandomAccessFile(lockFile, "rw").getChannel();
FileLock fileLock = fileChannel.lock();


lock() will block, but you could use tryLock() to check it the fileChannel is already locked.
I've been using it in our application on Linux and Windows.

ponedeljek, 14. februar 2011

Mercurial server installation for Windows

Installation of hgweb interface:
- install Apache HTTPD 2.2 to c:/Apps/Apache
- install Python 2.6 to c:/Python26
- install Mercurial to C:/Apps/HG
- install EasyInstall
This will find your Python installation and install it there.
- put c:/Python26 and c:/Python26/Scripts in you PATH
- install Flup Python module
easy_install flup-1.0.3.dev_20110111-py2.6.egg
- unzip C:/Apps/HG/library.zip C:/Apps/HG/dev
- copy c:/Apps/HG/templates directory to c:/Apps/HG/dev/templates

I have my Mercurial repositories in d:/HG/repos.

hgweb.fcgi in d:/HG looks like:

#!C:/Python26/python.exe -u
#
# An example FastCGI script for use with flup, edit as necessary

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "d:/HG/hgweb.config"

# Uncomment and adjust if Mercurial is not installed system-wide:
import sys
sys.path.insert(0, "C:/Apps/HG/dev")

# Uncomment to send python tracebacks to the browser if an error occurs:
import cgitb; cgitb.enable()

import os
os.environ["HGENCODING"] = "UTF-8"

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
from flup.server.fcgi import WSGIServer
application = hgweb(config)
WSGIServer(application).run()

- configuration file for hgweb (d:/HG/hgweb.config) looks like:

[paths]
# One repository
#FOO = d:/HG/repos/FOO
# All repositories in d:/HG/repos
/ = d:/HG/repos/**

[web]
style = gitweb

- each repository under d:/HG/ has hgrc (in UTF-8) like this:

[web]
description = Repository description
style = gitweb
allow_push = *
push_ssl = false
verbose = false
allowbz2 = yes
allowgz = yes
allowzip = yes

[ui]
username = Owner of repo <repo.owner@example.com>
debug = false


NOTE: debug and verbose have to be false

- edit c:/Apps/Apache/conf/httpd.conf and add:

LoadModule cgi_module modules/mod_cgi.so
LoadModule env_module modules/mod_env.so

SetEnv FCGI_FORCE_CGI Y
ScriptAliasMatch ^/hg(.*) d:/HG/hgweb.fcgi$1
<Directory d:/HG>
Options ExecCGI FollowSymLinks
AllowOverride None
AddHandler cgi-script .cgi
Allow from all
AllowOverride All
</Directory>

- if you want to limit access to repositories add this to c:/Apps/Apache/conf/httpd.conf

<Location /hg>
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile D:/HG/hgusers
Require valid-user
</Location>

- then add valid users to D:/HG/hgusers like this:

htpasswd -c D:/HG/hgusers frodo # creates file D:/HG/hgusers and adds user frodo
htpasswd D:/HG/hgusers sam # only add usersam to exising D:/HG/hgusers file

DB2 SQL440 or SQL901 on DELETE

If you get SQL440 or SQL901 when you try to delete from a table, you might encountered this problem. The solution is to recreate all foreign keys that point to this table (MY_TABLE is the SQL script below).
The SQL to generate that SQL script for you is this (statement delimiter is #):

SELECT 'ALTER TABLE EMGSYS.' || TABNAME || ' DROP CONSTRAINT ' || CONSTNAME || '#' || CHR(13) || CHR(10) ||
'ALTER TABLE EMGSYS.' || TABNAME || ' ADD CONSTRAINT ' || CONSTNAME || ' FOREIGN KEY (' || TRIM(FK_COLNAMES) || ') REFERENCES EMGSYS.' || REFTABNAME || '(' || TRIM(PK_COL
NAMES) || ') ON DELETE ' ||
(CASE WHEN DELETERULE = 'R' THEN 'RESTRICT' WHEN DELETERULE = 'C' THEN 'CASCADE' END) || ' ON UPDATE ' || (CASE WHEN UPDATERULE = 'R' THEN 'RESTRICT' WHEN UPDATERULE = 'A
' THEN 'NO ACTION' END) || '#'
FROM SYSCAT.REFERENCES WHERE REFTABNAME = 'MY_TABLE' ORDER BY TABNAME WITH UR

There are still some constands missing in DELETERULE and UPDATERULE. The various values can be seen here.

ponedeljek, 7. februar 2011

Mercurial

At our company we used (well, still using) CVS as our versioning system. We've finally moved one of our main projects to Mercurial. I've been given a task to expose the repository over HTTP and securing access to it. In the following days I will post how I did that on Windows. Oh, well, I know. I'd rather use Linux, but what can you do....

sobota, 1. januar 2011

New Year

I wish to you all a better 2011

torek, 14. december 2010

Is this for real?

Read what Bjarne Stroustrup said about creating C++ here. Then tell me what you think.
I must admit I always found C++ a bit weird. :)

petek, 15. oktober 2010

More space on Linux HOME partition

I've been trying to post this for a while, but never came to it.
Here it goes.

On every Linux partition there is a certain percent (usually 5%).
For certain partition you can check the amount of reserved space like this:
sudo dumpe2fs /dev/sda3 | grep "Reserved block count"

On my computer I had about 6Gb of reserved space.
You can gain those 6Gb of space back simply by using:
sudo tune2fs -m 0 /dev/sda3

I DON'T recomend using this on you root, boot, ... partitions. More on this can be read at How to Gain Couple Of Gb Of Free Space On Linux

četrtek, 23. september 2010

First


Two days ago I bought an HTC Desire phone with Android 2.2. I'm still learning, installing applications, ... This is my first smart phone and it's great. :))

This is also my first post from the phone.

petek, 7. maj 2010

Compile DB2 plugin for Qt on Linux

Steps:
- get Qt from Nokia's page
- install it
- run configure like this:
./configure -plugin-sql-db2 -v -I /opt/ibm/db2/V9.7/include -L /opt/ibm/db2/V9.7/lib64/
make
make install (if you want to install it)


- this should compile DB2 plugin for Qt. Now you can use this installation or copy generated Qt db2 plugin (libsqldb2.so) to /usr/lib/qt4/plugins/sqldrivers

Access DB2 via ODBC on Linux

This is how to install ODBC on Linux (Kubuntu 10.04) and access it.
Steps:
- install DB2 (I always install everything)
- install unixODBC
- edit $HOME/.odbc.ini :
[DB_NAME]
Description = Connection to DB_NAME
Driver=$HOME/sqllib/lib/libdb2.so

- run db2ca and add DB_NAME (don't forget to add ODBC)
- now you can use it on Qt for example like this:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DB_NAME");
db.setUserName("DB_USER");
db.setPassword("DB_PASS");
db.open();
QSqlError error = db.lastError();
qDebug() << "db error = " << error;

QSqlQuery query = db.exec("SELECT 1 FROM SYSIBM.SYSDUMMY1");
while (query.next() == true) {
qDebug() << query.value(0).toString();
}

petek, 5. februar 2010

DB2 9.7.1, db2start and SQL1042C

As you may know I'm running Kubuntu 9.10.
The other day I installed DB2 Express-C 9.7.1 on it. When I tried db2start I got:
SQL1042C An unexpected system error occurred. SQLSTATE=58004

If you get the same try running db2ftok and then db2start again. It works for me.

ponedeljek, 1. februar 2010

"How to shoot yourself in the foot" in various languages

Follow this link.
ActiveX is the one I like the most. How about you ?

petek, 29. januar 2010

Sun is eclipsed. :(((

petek, 1. januar 2010

Happy new year

I hope it will be better that 2009

četrtek, 24. december 2009

Novatel Wireless MC950D on Kubuntu 9.10

All I had to do is:
- unmount the CD-ROM
- set a custom DNS server

petek, 18. december 2009

Opening OpenOffice.org application through Java crashes

This is on Kubuntu 9.10.
If you see an error:
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPixmap: It is not safe to use pixmaps outside the GUI thread
CE> QPainter::begin: Cannot paint on a null pixmap
CE> X-Error: BadDrawable (invalid Pixmap or Window parameter)
CE> Major opcode: 62 (X_CopyArea)
CE> Resource ID: 0x0
CE> Serial No: 621 (621)
CE> These errors are reported asynchronously,
CE> set environment variable SAL_SYNCHRONIZE to 1 to help debugging
com.sun.star.lang.DisposedException: java.io.EOFException
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge$MessageDispatcher.run(java_remote_bridge.java:171)

when you try to open OpenOffice.org program (scalc, swriter, ...) using Java you can uninstall openoffice.org-kde or openofice.org-gtk packages. I'm still not able to pinpoint why this is crashing.

četrtek, 17. december 2009

Open 7-Zip archives in Midnight Commander

Edit Midnight Commander's extension file and look for "7zip archives". You should see something like this:
# 7zip archives (they are not man pages)
shell/.7z
View=%view{ascii} 7za l %f 2>/dev/null

Now add:
Open=%cd %p#u7z

to get:
# 7zip archives (they are not man pages)
shell/.7z
View=%view{ascii} 7za l %f 2>/dev/null
Open=%cd %p#u7z

ponedeljek, 9. november 2009

Kubuntu 9.10, mc does not show files in zip/jar

Couple of days ago I upgraded my machine to Kubuntu 9.10. I like it a lot. :)
At lease hibernate is a lot faster. :))
I had a problem with mc not showing content of zip and jar archives. When I pressed Enter of them no files were displayed.
So the solution is:
- sudo vi /usr/share/mc/extfs/uzip
- set my $op_has_zipinfo to 1
- save and restart mc

petek, 18. september 2009

Ws and HTTP Basic authentication

If you want to create a client for a web service that uses HTTP Basic authentication, you can authenticate in two different ways:
- use your own Authenticator class:
public class SAPAuthenticator extends Authenticator
{
private String username;
private char[] password;

public SAPAuthenticator(String username, char[] password)
{
this.username = username;
this.password = password;
}

@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username, password);
}
}

and then use it is you client like this:
Authenticator.setDefault(new SAPAuthenticator("username", "password".toCharArray()));

- in your client you can write something like this:
((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");

torek, 1. september 2009

the science of motivation

Dan Pink - The science of motivation 1/2

Dan Pink - The science of motivation 2/2

sreda, 10. junij 2009

SQLCODE=-4214 on DB2 on Linux

If you get SQLCODE=-4214 when you try to connect to a database running on Linux then you can do:
usermod --password `openssl passwd PASSWORD_TO_USE` USERNAME

The problem is that DB2 doesn't like SHA-512 hashes, but MD5.
On Ubuntu you can also change /etc/pam.d/common-password and change line
password [success=1 default=ignore] pam_unix.so obscure sha512

to
password [success=1 default=ignore] pam_unix.so obscure md5

Now changing the password will use MD5 hashes instead of SHA-512. This is a bit unsecure, so you decide if you need it. usermod should do the trick anyway.
Just remember that DB2 expects username on Linux (probably on every UNIX) to be all lowercase.

torek, 26. maj 2009

Export public key from a X.509 certificate

If you have an X.509 certificate in .p12 file then you can export public key like this:
openssl pkcs12 -in myFile.p12 -out myPublicKey.pem -clcerts -nokeys

petek, 22. maj 2009

Enable/disable KDE 4 desktop effects on command-line

Today I had a problem that my laptop, running KDE4 with desktop effects turned on, froze before I could start systemsettings and disable it. So to manually disable it:
- start Ubuntu in recovery mode
- go to root console
- go to /home/$USER/.kde or /home/$USER/.kde4
- then edit share/config/kwinrc
- set Enabled to false under [Compositing]

četrtek, 21. maj 2009

When I came to work

If I want to know when I came to work in the morning I use this piece of code:
LANG=en_us date "+%b %d" | xargs -i grep -m1 -i {} /var/log/syslog.0 | awk '{ print "Today I got to work at " $3 }'

I can use this since I power up my laptop every morning.
I got this one on a blog that I cannot find now, so I hope the author will not be angry with me. I just added LANG=en_us since the date format in syslog.0 is in en_us.

sreda, 22. april 2009

COM port support on AMD64 and Sun JDK 6 under Linux

If you want to get support for COM ports under 64-bit Linux then you need to:
- go to http://www.ibm.com/developerworks/java/jdk/linux/download.html
- go to 64-bit AMD/Opteron/EM64T under Java SE Version 6
- download Java Communications API

Now you need to put:
- javax.comm.properties into $JAVA_HOME/jre/lib
- libLinuxSerialParallel.so into $JAVA_HOME/jre/lib/amd64
- comm.jar into your project or $JAVA_HOME/jre/lib/ext

Now you need to edit javax.comm.properties to point to a correct physical devices.

ponedeljek, 9. marec 2009

Child

I didn't post anything for a long time, but I have a good reason for that. About a month ago I got my first child, a daughter. :)))
She can only cry, eat, put things in her diper :)), make funny faces and sleep.
I'm over 30 and this is my first child. If I only knew how great is to have one I'd have her a long time ago. So anyone that is not decided to have one or not, just do it. Just make sure you have a child with a women you love.

četrtek, 11. december 2008

torek, 25. november 2008

rdesktop on Ubuntu 8.10

Running rdesktop on Ubuntu 8.10 is not as smooth as on 8.04, because the damn thing grabs keyboard input despite the -K parameter I specify.

Ubuntu 8.10

Few weeks ago I upgraded my Ubuntu 8.04 to 8.10 and I'm very happy with it. My laptop runs about 20°C cooler than before and it doesn't freeze on me. Since I run BOINC client all the time (running my Dual Core CPU at 100%) this happened daily with previous version, but not now. :))
So Ubuntu team, a great release and keep up the good work.

torek, 7. oktober 2008

Control fan speed on T60 with Ubuntu 8.04

You can follow this link, but basically you do this:
- add "options thinkpad_acpi fan_control=1" without quotes to /etc/modprobe.d/options
- then you control fan speed with this commands (as root):
echo level 0 > /proc/acpi/ibm/fan (fan off)
echo level 2 > /proc/acpi/ibm/fan (low speed)
echo level 4 > /proc/acpi/ibm/fan (medium speed)
echo level 7 > /proc/acpi/ibm/fan (maximum speed)
echo level auto > /proc/acpi/ibm/fan (automatic - default)
echo level disengaged > /proc/acpi/ibm/fan (disengaged)

sreda, 17. september 2008

sreda, 3. september 2008

Google's Chrome

Now that was a surprise, not.
It was expected for some time now and I personally don't like it, because it is just another web browser web administrators will have to support.
Oh and Google applications will, eventually, only work good on Chrome.

nedelja, 27. julij 2008

Easter eggs in OpenOffice.org

I just came across some Easter Eggs in OpenOffice. I hope you'll enjoy them. :)

sobota, 19. julij 2008

Big projects and vi/emacs

I'm working with Java on couple of projects with couple of hundreds or even thousands of files of source code. I'm using NetBeans, because of the project management system it provides, it's editor with code completion, refactoring, GUI designer tool and other stuff.
I've always admired people who use vi or emacs on projects of that size. I can't imagine to live without code completion. There are too much methods with different parameters in a project to remember them all.
I'd like to hear from someone using vi/emacs on large projects how they do it. Thanks. :))

petek, 18. julij 2008

Java in Hollywood

I've just finished watching movie called Antitrust. The movie is about a system called SYNAPSE. Couple of time you can see a snippet of code that makes SYNAPSE and the code is Java. Cool! I've never before seen Java in a movie.

četrtek, 12. junij 2008

OTS 2008

On my blog you can find the application that me and my colleague demoed at OTS 2008. It is build upon NetBeans Platform 6.1. The source code will be available shortly and the application itself will get updated with time.

ponedeljek, 14. april 2008

Why I like NetBeans 6.1

Of course, because it is getting faster and faster, better and better editor, JEE and Glassfish support,.. I could get on and on.
But the greatest thing, for me at least, is that when I open a file it gets opened on the far right side of all editor tabs. NetBeans 6.0 had this issue with this and files got put somewhere in the middle of tabs, sometimes at the end, ... The algorithm was a total mistery for me.
I just hope this won't get lost by the time 6.1 is released.

petek, 28. marec 2008

South Park for free

If you like South Park you can watch it here free.

ponedeljek, 11. februar 2008

Custom resolution with VMWare Server

I'm using VMWare to run Windows on my Linux machine and the machine supports 1680x1050 which is not supported by default when you install VMware Tools.
To get it to work you can follow this steps:
- open regedit
- go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{device id}\0000 use {device id} that has VMWare SVGA II in the description
- add a new binary value Resolution.x (x being by one bigger that other Resolution.y values), for example Resolution.11
- enter the value 31 36 38 30 78 31 30 35 30 (binary for 1680x1050)
- exit regedit and reboot

You can read more here and here.

četrtek, 31. januar 2008

Total size of a table in DB2

If you wonder how to get the total size of a table in DB2 you can use following SQL statement which gives you 30 largest tables:
SELECT TABSCHEMA, TABNAME, DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE AS TOTAL_SIZE FROM SYSIBMADM.ADMINTABINFO ORDER BY TOTAL_SIZE DESC FETCH FIRST 30 ROWS ONLY WITH UR

Total size here means size of data + size of indexes + size of long objects + size of LOB objects + size of XML objects.
More about this can be found at IBM DB2 InfoCenter or directly here.

New ATI drivers and hibernate

As you might remember I didn't have ATI drivers enabled since hibernate did not function correctly. Couple of days ago I installed ATI driver version 8.452.1 and hibernate does work.

ponedeljek, 21. januar 2008

GNUCash

For the past 18 days (yes, New Years' resolution) I've been using GnuCash for managing my finances. The biggest problem I've seen with it it that you cannot protect the file where transactions are written.
Today I came across a Wiki entry how to encrypt that file using GnuPG.
This script can be also used for other applications, not only GnuCash.

petek, 18. januar 2008

Software development process

Colleague pointed me to this post. Does it sound familiar ? :))

sobota, 12. januar 2008

Changing the CVS keywork substitution mode

If you want to change the CVS keywork substitution mode, you unfortunately cannot do it with NetBeans, but you can use this few steps:
- let's say the new keyword substitution mode should be -kkv
- cvs admin -kkv File.java
- cvs update -kkv File.java
- edit the File.java to change it a bit
- cvs commit -fm "Change substitution mode" File.java

I've used this on number of files, so it does work.

History of CVS changes

If you want to know what you and your colleagues changed in a period of time in the whole CVS managed project, just right click the root directory of the CVS managed project and use Search history command. There you can search by revision or date. Great. :)
You can for example see how much work did you do in year.

ponedeljek, 10. december 2007

Insert Unicode

If you need Insert Unicode module you can get it here. I didn't develop this module, I only compiled it to work on NetBeans 6.0. The original author is Jesse Glick.

petek, 7. december 2007

FoodTube

If you'd like to learn how to cook, go to FoodTube

ponedeljek, 3. december 2007

NetBeans 6.0 Released !

A good day it is. Long awaited NetBeans 6.0 is released !!! Rejoice :))

petek, 30. november 2007

Depp Copy of Objects

Ever wanted to do a clone of a Vector for example. You could use the clone() method on all objects that are in the Vector, but there are better solutions:
- Exploit Serialization To Perform Deep Copy
- Faster Deep Copies of Java Objects
- Low-Memory Deep Copy Technique for Java Objects

Whatever approach suits you best is the one for you. :)

četrtek, 8. november 2007

Migrating Class libraries between NetBeans versions

There is a nice entry in NetBeans Wiki on how to migrate class libraries between different IDE versions, so you don't have to manually enter them.

Cooler T60

After a week of using Ubuntu 7.10 I've noticed that my T60 is much cooler that it was running Ubuntu 7.04. I'm running BOINC all day long and the temperature of the CPU is 10˚C lower than on Ubuntu 7.04.

petek, 2. november 2007

Ubuntu 7.10

I've upgraded my T60 to Ubuntu 7.10. the main thing I noticed is that now hibernate/resume works as it should. Ubuntu 7.04 had a nasty bug when sound did not work anymore after resume. This has been fixed now.
And since I have an ATI x1400 card inside I also wanted to test the latest ATI drivers that support composite so compiz-fusion can work. But the drivers have a bug which prevents a notebook to go to hibernate mode. So now, until ATI releases new driver's, I'll not be using compiz-fusion since hibernate is more important to me. And for me these compiz gets in a way after a while, but it has some very nice graphics effects.

sobota, 29. september 2007

Description of DB2 sqlcodes

Did you ever need a description of a sqlcode in a programming language like Java? Did you ever wanted to know if an sqlcode is an error or a warning?
You can use SYSPROC.SQLERRM function for that:
VALUES(SYSPROC.SQLERRM('SQL0911N', '', '', 'en_US', 0))

There is a sqlcode: in the description and id this is negative then you have an error, otherwise a warning. I consider sqlcodes that don't have sqlcode: in the description as not important. :)

nedelja, 23. september 2007

Tetris

In my early days I played a lot of Tetris. On my 486 with a Turbo button :)) I even got so may points that the score counter flipped over, but I was never as good as this guy. :))
He truly is a Tetris Master.

sobota, 15. september 2007

Newline

Yesterday one of my coworkers said something that I'm laughing even today over it.
He was trying to open a CSV file with Excel, but he got some strange results. Then he noticed that a description column had newline characters in, so Excel made more lines as it should.
So he said: "Why don't they put newline in one line." :)))

nedelja, 2. september 2007

Easter Egg in Google Earth

Remember a while back when I blogged about Easter Eggs ?
There is a great one in the newest Google Earth. Download it and press CTRL-ALT-A. you'll see a flight simulator and here are the controls you can use.
Have a lot of fun. :)
What are the best Easter Eggs you've found in software?

sreda, 22. avgust 2007

How to get modem in T60 working?

Steps:
- install driver using program provided at:
http://www.linuxant.com/drivers/hsf/downloads-installer.php
or look at section "Identifying your modem"
- run "sudo sh cnxtinstall.run"
- follow instructions
- reboot
- run "sudo hsfconfig --country" to set the country
- run "sudo hsfconfig --license" to set the license. Choose FREE here.

When I start minicom, the program can initialize the modem. I have to admit I did not try if the modem really works.

torek, 21. avgust 2007

DB2 and string functions

If you have ever worked with DB2 and Unicode database, you must have stumbled across this problem:
If you are using characters that are not in ascii table, but nation specific ones, like đšžćč in my case, then function like LENGTH, SUBSTR, ... are not working right. Especially with JCC DB2 driver.
Example:
ResultSet rs = stmt.executeQuery("SELECT SUBSTR(NAME, 1, 10) AS NAME FROM TABLE1")
and then the tenth character is one of đšžćč(for example) then calling
rs.getstring("NAME") will give you an Exception.
There are three solutions:
- use APP/NET driver, so you at least don't get the exception
- do a substring in Java code
- use VARGRAPHIC like SELECT SUBSTR(VARGRAPHIC(NAME), 1, 10) AS NAME FROM TABLE1

At least I hope DB2 developers will fix this soon. Sometimes it really gets on my nerves.

četrtek, 9. avgust 2007

Specs

On Monday I got back from my R&R and started doing some work with a device that is connected to RS-232. I was following the specs for the protocol that it supports. But the device returned something that was not in the specs. Strange. Luckily I had a contact person at the company that provided the device. We figured out that the software on the device is not the right one, the one that supports the specs I got. Then we updated the software. And did it the second time, since the first was not the right version. The device still didn't function as written in the specs. Then we figured out that is was not set up correctly. Now after couple of days I have a working device as per spec. So the company says. :)
Then I found out that the specs are not right. They say something and the device says something else. Now who to believe? After three days I'm still not 100% sure if the spec and the device are on the same level.
Don't you just hate when this happens? And then your manager asks you why it took so long to send two lousy packets to the device. They are both 60 bytes long! Arrrgggg

petek, 3. avgust 2007

R&R

Last 14 days I've been on R&R. :))
The first of there magnitude this year. I really needed it. I've been involved in couple of large project this year (introduction of Euro currency in my country, introduction of Selfcheckout tills, ....).
During my R&R I've kinda started some work on Neural networks. We'll some where it takes us.

četrtek, 19. julij 2007

JSP form and UTF-8

Today I was trying to help one of my coworkers who had a problem accessing a value on a JSP page and storing it into a database. Of course he was using UFT-8 characters, so they ended up in database all wrong.
A solution is very simple :))))
Just add
request.setCharacterEncoding("UTF-8");

before you access any parameter in the request object.
I got the solution from a blog.

četrtek, 5. julij 2007

T-2 and IPTV and Ubuntu

If anyone has T-2 IPTV and wants to watch it on their computer then follow these steps:
- connect a cable from VOOD TV port to your computer
- have vlc installed and ready
- add a route like:
ip route add 224.0.0.0/4 via YOUR_CURRENT_IP

- get a playlist of all programs
- start vlc, load that playlist and enjoy

6516858 fixed

A bug that I reported about 6 months ago for Java is now fixed and in Java 6u2 and Java 5u12. This is my first reported and fixed bug for Java. :)

sreda, 4. julij 2007

Update on sound on T60

In my last blog I mentioned that sound sometimes is working and sometimes is not. Now I know when it is and then it isn't.
If I put my T60 into hibernation then on next boot sound is not working. If I shut down my T60 and boot it sound is working. Oh well.. :))

My own notebook

Yuppiii! Last week I got my own notebook, a ThinkPad T60:
- Intel Core 2 Duo 2.16 GHz
- 2 Gb RAM
- 120 Gb HDD
- Atheros wireless card
- ATI Technologies Inc Radeon Mobility X1400
- 15.4" display with 1680x1050

Of course it came with Windows XP, but I soon deleted it from the machine. :))) I put Ubuntu 7.04 on following this and this tutorials.
You have to use text installer to install Ubuntu 7.04, because ATIs card is not supported in this stage. After installing Ubuntu I had to follow this thread.
I had a lot of problems with the Atheros wireless card, since it was not recognized by the system, so I had to go and download the latest drivers from MadWifi homepage and do a simple make, make install. Of course every time I upgrade kernel-modules I have to do this again. Now wireless works like a charm. :))
The second problem was my sound card. It is an Intel AD1981. At first it didn't work, meaning that when I tried to play something I got a lot of Device not opened type of errors. Then I read something about this in Ubuntu forum and this thread. It seems that you have to have modem enabled in your BIOS. Doing this I still couldn't hear sound, so I followed this part of UbuntuGuide. I still kinda have a feeling that sound sometimes works and sometimes does not, like it would have a mind of it's own. :))) The main thing is that I know it does work. :)) For the most part. :))
OSD (On Screen Display) for sound and brightness (Fn + Home, Fn + End) were working from the ground up.
Of course I wanted to try beryl on T60. I have done everything that is described in these steps, but display was are mixed up. You couldn't see anything. For now I'm going to stick to GNOME and maybe later try another approach.
What is still not working is my modem. I'll have to look into this problem a bit more.

Bottom line I'm now working with a T60 for a week now and I love it. :)))
I'll keep you informed.

petek, 22. junij 2007

Glassfish on Windows and "space hell"

If you want to run Glassfish as a service on Windows than you have to use sc.exe and appservService.exe.
At first I tried this (D:\Apps\glassfish is my GLASSFISH_INSTALL directory):

D:\Apps\glassfish\lib>sc.exe create domain1 binPath="d:\Apps\glassfish\lib\appservService.exe
\"d:\Apps\glassfish\bin\asadmin.batstart-domaindomain1\"
\"d:\Apps\glassfish\bin\asadmin.bat stop-domain domain1\"" start= auto DisplayName= "SunJavaSystemAppServer DOMAIN1"

and it didn't work. Why? Look at the command that does work:

D:\Apps\glassfish\lib>sc.exe create domain1 binPath= "d:\Apps\glassfish\lib\appservService.exe
\"d:\Apps\glassfish\bin\asadmin.batstart-domaindomain1\"
\"d:\Apps\glassfish\bin\asadmin.bat stop-domain domain1\"" start= auto DisplayName= "SunJavaSystemAppServer DOMAIN1"

See the difference? No... Well, there is a space after binPath= operation. This is not the first or the second or the third, ... time I had to deal with this. And I HAVE IT ENOUGH!!!

nedelja, 10. junij 2007

Funny game

It's been a while since I played a game, but then I came accross this one.
It is very funny one to play. First time I saw it I laught for an hour. :)))