wtorek, 16 czerwca 2009

How to get X.509 certificate from CMS/PKCS#7 signature

openssl pkcs7 -in signaturefile.sig -inform DER -print_certs -text

sobota, 13 czerwca 2009

Display a command result in new Xfce terminal window

Sometimes you just want to display a result, as for ls:

xfce4-terminal -H -e ls

But sometimes it makes sense to display results continuosly, like for htop or elinks:

xfce4-terminal -e htop

How to get executable shell scripts from Subversion repository

All you have to do is to set svn:executable property on the file

svn propset svn:executable on somescript.sh

svn commit

Especially important when done on Windows (SVN client should set this automatically if executable file is being added to version control on Linux)

Keyboard shortcut for "Add to version control" in eclipse

I am really fed up with right-clicking and choosing "Add to version control". I defined a keyboard shortcut then. 

Press Ctrl Shift L twice. On "Keys" preference page find "Add to version control", preferably using the relevant search box. When - "In windows". I chose "Ctrl+Shift+Alt+C" so that it won't interfere with anything (I hope).

piątek, 22 maja 2009

End-of-line characters conversion between Windows and Linux

Just started to work for a project where the majority of the people use Windows. Quick fix for ^M occuring in shell scripts:

sudo aptitude install tofrodos

and then

find . -name '*.sh' | xargs dos2unix -d

(could be with exec, but for a small number of files it does not really matter)

sobota, 9 maja 2009

A cryptographic hash of an empty byte array does exist. Honestly.

An hour or so spent and finally the reason found - no data. That test proves it in a way:

@Test
public void testNullDigest() throws Exception {
MessageDigest md = MessageDigest.getInstance("SHA1");
System.out.println(ArrayUtils.toString(md.digest(new byte[0])));
}

The output:

{-38,57,-93,-18,94,107,75,13,50,85,-65,-17,-107,96,24,-112,-81,-40,7,9}


Exactly the same as the one I was getting. In particular, different from the expected one (suprise). I should make some constant ;-/

sobota, 2 maja 2009

Quick search in Midnight Commander

Just press Alt+s and then start typing the name.

Prune unnecessary log4j dependencies in maven

If you want to use the newest log4j with maven build, you may notice a few dependencies you may not want to include if you just want to have plain ordinary logging without JMX or mail support.

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>

czwartek, 30 kwietnia 2009

View all Subversion commiters

Do you want to see everyone who checked something in to SVN repo?
svn log | egrep 'r[0-9]* ' | cut -f2 -d '|' | sort -u

wtorek, 24 marca 2009

Templates in Thunar (Create document...)

Just put the template file in ~/Templates and that's it. Source

wtorek, 3 marca 2009

How to change the default WPS password in Websphere Integration Developer

Here is the file
~/.eclipse/ibm.websphere.integration.developer_7.0.0_1741360425/configuration/.settings/com.ibm.wbit.runtime.core.prefs 
and that context is to be changed:
security.user.wps_61=admin
security.password.wps_61={xor}PjsyNjE\=
For password encoding that entry might be helpful.
UPDATE: From now on you do not have to enter embedded WebSphere user/password every time you start WID. For Windows, the directory and file can somewhere in WID61\configuration\.settings\com.ibm.wbit.runtime.core.prefs. I think it could be in similar place on Linux, but that depends on your user's write rights to WID directory. I should have issued a proper umask prior to the installation apparently - but when you read installation docs few months after the installation, such things happen.

poniedziałek, 2 marca 2009

Oracle not starting after system reinstallation

After formatting root partition and installation of Xubuntu 8.10 instead of Kubuntu 8.04 (but preserving /home) Oracle failed to start:
oracle[SID]: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
ERROR:
ORA-12547: TNS:lost contact


Enter user-name:

The solution was to install libaio1:
sudo aptitude install libaio1
Well, somewhat natural consequence of the decision not to automatically reinstall all the packages present in my previous Hardy installation...
http://forums.oracle.com/forums/thread.jspa?messageID=2797706&tstart=0

piątek, 27 lutego 2009

Splitting and joining large files

cd /music/Pearl Jam/Ten
mkdir tmpoceans
# split the file
split -b 400k 07\ -\ Oceans.ogg tmpoceans/07\ Oceans.ogg.
# check the created parts
ls -1
tmpoceans
07 Oceans.ogg.aa
07 Oceans.ogg.ab
07 Oceans.ogg.ac
07 Oceans.ogg.ad
# split it back
cat 07\ Oceans.ogg.* > 07\ Oceans.ogg
# and play
ogg123
07\ Oceans.ogg

http://www.techiecorner.com/107/how-to-split-large-file-into-several-smaller-files-linux/

http://www.johnrockefeller.net/?p=195

wtorek, 24 lutego 2009

Thunar - single click instead of the default double

Edit/Preferences/Behaviour/
Single click to activate items

http://xfce.jakilinux.org/viewtopic.php?id=19

poniedziałek, 23 lutego 2009

Subversion - repository URL of working copy

That tiny script is useful when you've got a few branches and dir names do not reflect those in the repo, eg. branch1, branch2 vs http://oursvnrepo/importantproject/branches/{somefeature,anotherfature} (quite possible in large projects with frequently created branches). Yes, it could be a bit more elegant and discover when the parameter is not a directory, but anyway:
# !/bin/bash
# usage:
# svnpath - SVN repo URL for current dir
# svnpath dirname - svn repo URL for given dir
if [ -z "$1" ]
then
grep '//' .svn/entries | head -n1
else
grep '//' "$1"/.svn/entries | head -n1
fi

Other users' Oracle sessions

select process, program, osuser, sid, serial#,
BLOCKING_SESSION_STATUS, SECONDS_IN_WAIT, lockwait, status
from v$session
where type = 'USER'
and nvl(osuser, 'nomycurrentuser') != 'mycurrentuser'

Where are Oracle trace files written

select value from v$parameter
where name like '%user_dump%'
/

piątek, 20 lutego 2009

Useful SQL+ commands, part 1

Useful for "reports"
set linesize 200
set pages 0 -- effectively switches off any headers
Useful for displaying long columns - not only LONG but e.g. XMLType
set long 10000 -- ... or so

Import Oracle dump into an existing schema

  1. First drop all sequences for a user:
    declare
    cursor cr is select sequence_name from user_sequences;
    begin
    for c in cr loop
    execute immediate 'drop sequence ' || c.sequence_name;
    end loop;
    end;
    /

  2. Import dump file
    impdp appadmin/password directory=dmpdir dumpfile=appadmin.dmp SCHEMAS=appadmin table_exists_action=replace
  3. It uses non-standard directory dmpdir instead of the default one DATA_PUMP_DIR, to create it run sth like:
    CREATE OR REPLACE DIRECTORY dmpdir as '/opt/oracle/dmp'
    from an account with proper privs (CREATE ANY DIRECTORY, "/ as sysdba" has got it
    definitely)

Mocp output in Xfce panel

  1. Get Generic Monitor for the Xfce4 panel
    sudo aptitude install xfce4-genmon-plugin # or equivalent
  2. Create a script generating your output, e.g.
    echo "mocp -i | egrep 'SongTitle|Artist' | cut -d":" -f2" > ~/bin/mocpinfo4panel
  3. Add Generic monitor to Xfce panel and input the script name into Command field, probably also change label to "mocp" or "now playing" or "what I could listen to if I didn't forgot my earphones" (well, perhaps a bit excessive).