piątek, 5 listopada 2010

Adjusting PostgreSQL sequence

Sometimes (hopefully not in production) you have "low" sequence values but "high" identifiers in the respective table. That usually results in primary key violation on an attempt to insert a new row.

So - if you really do not want to delete the data, you should make the sequence have those "high" values, ideally max(id_from_the_table) + 1.

In PostgreSQL it turns out to be much more elegant than in Oracle, where you can either come up with some PL/SQL FOR loop or use DDL ALTER SEQUENCE statements. The examples have been copied from

http://www.postgresql.org/docs/current/static/functions-sequence.html

SELECT setval('foo', 42); Next nextval will return 43

SELECT setval('foo', 42, true); Same as above

SELECT setval('foo', 42, false); Next nextval will return 42

niedziela, 10 października 2010

How to convert a collection of MonkeyAudio (ape) files to Ogg Vorbis on Ubuntu 10.04

OK, I have got some quite old backups of my audio CDs in APEs (created under Windows years ago). Would like to have them in Oggs of fairly low quality so that they do not take too much space. That page looks promising:

http://lossless2lossy.sourceforge.net/

It states you will need oggenc and MAC for such a conversion.

So...

1. For oggenc (a part of vorbis-tools)

sudo apt-get install vorbis-tools

2. And the MAC thingy? Well... seems there were some licensing problems with that and it is no longer in the official repos. So download it from

http://members.iinet.net.au/~aidanjm/mac-3.99-u4_b3-1_i386.deb

(as stated in http://aidanjm.wordpress.com/2007/01/26/using-monkeys-audio-ape-files-in-ubuntu/ which seems to be the root here, see also https://bugs.launchpad.net/ubuntu/+bug/119412 for the license problems discussion; even some PPA repo is mentioned there)

and install, e.g. by means of GDebi or

sudo dpkg -i mac-3.99-u4_b3-1_i386.deb

3. Download lossless2lossy:

http://sourceforge.net/projects/lossless2lossy/files/

4. Put it somewhere in your PATH (~/bin for example) and...

chmod u+x ~/bin/lossless2lossy-v1.21

ln -s ~/bin/lossless2lossy-v1.21 ~/bin/lossless2lossy

5. Convert the whole stuff, saving intermediary wav files to /tmp and not retaining them

lossless2lossy ogg vbr 1 ~/music/ape /tmp ~/music/ogg nosave

Quite recently support for MonkeyAudio has been added to ffmpeg - to be checked...

piątek, 14 maja 2010

Eclipse Data Tools Platform - getting nicer

Did not use to use it since it seemed inferior to more specialised tools. But I can see in Galileo (3.5 that is) it behaves much better and is suitable for many tasks involving just reviewing and/or editing data. Especially not BLOBS - haven't tried out the current DTP support for them though.


In preferences, under General/Data Manegement/SQL Editor on "General" tab you can set what "Execute current text" should mean. I do not like the default "Execute current line" but the other choices "between delimiters" and "between blank lines" are much better. Alt+s in SQL scrapbook and I have my query executed.

wtorek, 4 maja 2010

FlashGot-like download by means of wget in Opera under Linux

To have Opera behave similar way as Firefox with FlashGot http://flashgot.net/ - that is, to have wget download files:



  • Edit ~/.opera/menu/standard_menu_1.ini file (note: Opera must not run!)

  • In section [Link Popup Menu]
    add the following line:
    Item, "Download by wget"="Execute program, "xterm +132 -e wget -P/home/username/downloads","%l""



Inspiration: http://www.linux.com/archive/feature/59457

niedziela, 2 maja 2010

How to get a value of an XML element from XMLType in Oracle

EXTRACTVALUE method:
EXTRACTVALUE(XMLTYPE_instance,XPath_string) or
EXTRACTVALUE(XMLTYPE_instance,XPath_string, namespace_string)
e.g.
select extractvalue(details, '/SomeDoc/SomeDetail')
from SomeTable