środa, 11 grudnia 2013

Revive deleted file from Git

You accidentally deleted one file which you didn't want to. But together with a bunch of other files you no longer need. Well, you can make a temporary branch off the "last good" Git commit and take the file from there. But there is a better way.
git show LAST_GOOD_COMMIT_HASH:path/to-the/file > path/to-the/file
# if you have just done it so it has happened in the last commit
git show HEAD^1:path/to-the/file > path/to-the/fil
e
... etc, so in general:
git show COMMIT:path/to-the/file > path/to-the/file

poniedziałek, 2 grudnia 2013

A quick and dirty Groovy snippet to test JDBC connection to Oracle

That's a snippet to test JDBC connection to Oracle with minimum number of lines.
1. Run Groovy shell with ojdbc6.jar on the classpath:
groovysh -cp /opt/sqldeveloper/jdbc/lib/ojdbc6.jar
2. Run the script:
import groovy.sql.Sql
sql = Sql.newInstance('jdbc:oracle:thin:@localhost:1521:mysid',
'user', 'password', 'oracle.jdbc.OracleDriver')
result = sql.firstRow("select * from dual")

===> {DUMMY=X}
In the end it turned out to be a problem described here:
http://appsdbastuff.blogspot.com/2012/01/starting-listener-fails-with-tns-12557.html
In short, the solution was to run this as root:
mkdir /var/tmp/.oracle
chmod 01777 /var/tmp/.oracle
chown root /var/tmp/.oracle
chgrp root /var/tmp/.oracle

How to mount VMDK (VMware disk file) under Linux

Provided you have some VMware product installed (VMware Player will suffice)
sudo mkdir /mnt/vmdk
sudo vmware-mount the-disk.vmdk /mnt/vmdk/
If the disk has only one partition, that's everything you need.
To unmount:
sudo vmware-mount -d /mnt/vmdk/
To list partitions on a VMDK file:
vmware-mount -p the-disk.vmdk
To mount nth partition (they say the numbering starts from 1):
sudo vmware-mount the-disk.vmdk n /mnt/vmdk/
See also http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vddk.utils.doc_50%2Fdiskutils_mount.4.4.html