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, ....
nedelja, 1. januar 2012
č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:
and in xterm I start screen with 10 sessions.
Now everything is fast again. :)
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:
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.
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:
- configuration file for hgweb (d:/HG/hgweb.config) looks like:
- each repository under d:/HG/ has hgrc (in UTF-8) like this:
NOTE: debug and verbose have to be false
- edit c:/Apps/Apache/conf/httpd.conf and add:
- if you want to limit access to repositories add this to c:/Apps/Apache/conf/httpd.conf
- then add valid users to D:/HG/hgusers like this:
- 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.
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
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. :)
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
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:
- 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
- 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 :
- run db2ca and add DB_NAME (don't forget to add ODBC)
- now you can use it on Qt for example like this:
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.
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 ?
ActiveX is the one I like the most. How about you ?
petek, 29. januar 2010
petek, 1. januar 2010
č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
- 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.
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
# 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
Naročite se na:
Objave (Atom)