Monday, June 27, 2011

Volumeicon : better volume applet in #lxde for !debian or #Lubuntu

I really like lxde and i have installed on all computers that i have (minus the android phone but soon enough i will install on that too :))
but there is one annoying bug or feature the volume applet at least at home
is controlling only the front speakers and no mixer to choose what to be controlled or any preferences , only if you modify the source.

There is the help of alsa mixer to the rescue
open console and type
alsamixer
but there is a better way volumeicon
it places an icon in status bar and when you right click you can choose mixer and it will show you the alsamixer in all it's glory
pretty cool that cli always saves you and is more trusted than the GUI
git clone https://github.com/icebreaker/volumeicon.git
cd volumeicon
./configure --prefix=/usr --enable-notify
sudo make install

I have two soundcars so i have added in the config
cat /proc/asound/cards
0 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                      HDA ATI HDMI at 0xfeaec000 irq 44
 1 [default        ]: USB-Audio - Microsoft LifeChat LX-3000 
                      Microsoft LifeChat LX-3000  at usb-0000:00:1d.2-1, full speed

vi ~/.config/volumeicon/volumeicon
[Alsa]
card=hw:1
Start volumeicon or add it to the startup session
volumeicon &
if you are on pure LXDE/Debian
editor ~/.config/lxsession/LXDE/autostart
#add to the file
@volumeicon
If you are on Lubuntu
editor ~/.config/lxsession/Lubuntu/autostart
#add to the file
@volumeicon

Thursday, June 23, 2011

Using Jaybird Firebird JDBC driver with Ubuntu/Debian - cli way

I have used eclipse to create  simple console projects before and there it's easy to add references to the jaybird-full-*.jar , This time i wanted to compile from the shell.

Download jaybird from firebird jdbc download page
unzip it somewhere in your home
I usually put in a dir named  jdbc_client

cd ~/jdbc_client
compile it
javac -cp jaybird-full-2.1.6.jar examples/DriverExample.java
run it
java -cp jaybird-full-2.1.6.jar:examples DriverExample
It will trow you
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jaybird21 in java.library.path


Simple fix is to use the pure type4 java jdbc driver and this is done by using the magic "localhost/3050:" in the connection string



After that it starts ok
java -cp jaybird-full-2.1.6.jar:examples DriverExample
Firebird JCA-JDBC driver version 2.0 registered with driver manager.
Connection established.
Auto-commit is disabled.
Transactions are supported.
PHONE_LIST is a view.
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544558. Operation violates CHECK constraint INTEG_30 on view or table EMPLOYEE
At trigger 'CHECK_4'
 at org.firebirdsql.jdbc.AbstractStatement.executeUpdate(AbstractStatement.java:273)
 at DriverExample.main(DriverExample.java:296)
at org.firebirdsql.gds.GDSException: Operation violates CHECK constraint INTEG_30 on view or table EMPLOYEE
At trigger 'CHECK_4'
 at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2169)
 at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2119)
 at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlExecute2(AbstractJavaGDSImpl.java:1185)
 at org.firebirdsql.gds.impl.GDSHelper.executeStatement(GDSHelper.java:226)
 at org.firebirdsql.jdbc.AbstractStatement.internalExecute(AbstractStatement.java:1102)
 at org.firebirdsql.jdbc.AbstractStatement.executeUpdate(AbstractStatement.java:269)
 at DriverExample.main(DriverExample.java:296)
Unable to increase everyone's salary.
GDS Exception. 335544558. Operation violates CHECK constraint INTEG_30 on view or table EMPLOYEE
At trigger 'CHECK_4'
Error Code: 335544558
SQL State: HY000
The query executed has 1 result columns.
Here are the columns:
FULL_NAME of type VARCHAR
Here are the employee's whose salary < $50,000
Bennet, Ann
Reeves, Roger
Stansbury, Willie
Nordstrom, Carol
O'Brien, Sue Anne
Brown, Kelly
Page, Mary
Parker, Bill
Yanowski, Michael
Green, T.J.
Montgomery, John
Guckenheimer, Mark
Closing database resources and rolling back any changes we made to the database.

Now we try the Jni way (aka using the not so pure driver)
chmod +x libjaybird21.so
Seems to be compiled for 32 bit (i'm on 64 but i have already the lib32 libs)
ldd ./libjaybird21.so 
 linux-gate.so.1 =>  (0xf770d000)
 libdl.so.2 => /lib32/libdl.so.2 (0xf76c7000)
 libc.so.6 => /lib32/libc.so.6 (0xf756d000)
 libstdc++.so.5 => /usr/lib32/libstdc++.so.5 (0xf74b3000)
 /lib/ld-linux.so.2 (0xf770e000)
 libm.so.6 => /lib32/libm.so.6 (0xf748d000)
 libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7470000)
To run using the compiled interface you need to add the -Djava.library.path when you run the program also change the connection string by adding the native keyword ":native:localhost/3050:"
java -Djava.library.path=. -cp jaybird-full-2.1.6.jar:examples DriverExample
For me it didn't worked because i have a 64bit machine so i need a jaybird source recompilation
libjaybird21.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

Tuesday, June 21, 2011

Mono Firebird Example updated for Mono 2.6/2.10.x release (#ubuntu / #debian)

Mono Firebird Example updated for Mono 2.6 release

First I hope you have Firebird 2.5 already installed with examples :)

Second Install Monodevelop and Mono
In my case was something like this on ubuntu
sudo apt-get install  mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol  monodoc-gtk2.0-manual 

Also on Debian you can use mono 2.10.x by using experimental repository (after you add it in /etc/apt/sources.list)

sudo apt-get -t experimental install  mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol  monodoc-gtk2.0-manual 

You must download the .Net Provider 2.6.5 for mono binary version NETProvider-2.6.5-MONO_LINUX.7z
Extract it somewhere in the project dir where you want to build it

Create an new C# Console Project
Then add the Firebird .net assembly to the test project
References-> Edit References -> .Net Assembly
browse to the FirebirdSql.Data.FirebirdClient.dll that you downloaded before (and extracted)
then click Add button



Fill the Main.cs this way and Build Solution (Also add System.Data references)



Then click run after the solution is build and the result should be like this