Sunday, 4 March 2007

Windows remote control

It helps to be able to remote control another computer - for example if you need to install or fix something on your parents/family/friends computer and you cannot travel to their location.

One-Click VNC makes it easy.

Essentially, the person that is doing the controlling:

  1. If you are using a router with your internet connection you need to set up port forwarding for port 5500 to your computer.

  2. Run 'vncviewer.exe -listen' on your computer.

  3. Send your routers external ip address to the person to be controlled.


Now, at the other end, for the person who will be controlled:

  1. Update settings.ini with the controllers external ip address

  2. Run OneClickVNC.exe.


Now the client talks to the controllers routers external address which forwards to your internal ip address and you are done.See One-Click VNC for the full story...

Note, Windows Live Messenger allows remote controlling of computers you are chatting with (the user can select Actions/Request remote assistance and then pick from any of their online contacts), but I haven't had much luck with it. I'm not sure if it is the router configuration at either end, or just the network connection. I have used it successfully before, when there wasn't a router at the other end.

Saturday, 3 March 2007

Recovering disk space from Oracle

Where has the disk space gone
To find out which tables are the biggest you can run this query:
SELECT
owner, segment_name, segment_type, tablespace_name,
SUM (BYTES / 1024 / 1024) sizemb
FROM dba_segments
GROUP BY owner, segment_name, segment_type, tablespace_name
ORDER BY sizemb DESC

Recovering disk space
Most of the following was learned from this forum post. As tables grow, it can be necessary to compact them to free up disk space. Deleting unnecessary rows won't necessarily free disk space. The space occupied by those rows just becomes available for new rows to consume.

To free up space, you need to truncate (or drop and re-create) the table. If there are constraints referencing some of the rows in the table you want to shrink then you'll have to disable those first.

So, assuming:

  • you want shrink table FOO

  • you've deleted the rows you don't need from FOO

  • table BAR has constraints referencing FOO


-- copy those rows you want to keep into a new table
CREATE TABLE temp_storage_table AS SELECT * FROM foo;
-- disable constaints so you can truncate
ALTER TABLE bar DISABLE CONSTRAINT foo_fk01;
-- truncate which will release the disk space
TRUNCATE TABLE foo;
-- copy the rows you want to keep back into the original table
INSERT INTO foo SELECT * FROM temp_storage_table;
-- re enable constraints
ALTER TABLE bar ENABLE CONSTRAINT foo_fk01;
-- remove temp data
DROP TABLE temp_storage_table;

Try this out on a test table first to make sure everything is working as expected.

Making an ISO file from a DVD

Its really easy to convert a DVD or CD into an ISO file. Its really fast too (10MB/s or 5 mins for 3.6GB).

Use the dd command to create an ISO image:
dd if=/dev/dvd of=/tmp/mydvd.iso

Now, if you want to access the contents of this ISO image you can mount it and access it like a normal DVD player:
mkdir /mnt/iso
mount -o loop -t iso9660 /tmp/mydvd.iso /mnt/iso


To unmount use
umount -d /mnt/iso

If you use this to backup your DVD collection, you can play them back using VLC Media Player. This lets you 'open a disc' and you can use the URL dvd:///mnt/iso to access it like it was in the DVD tray. Very cool! Its nice having the whole disk as one file, which you can mount when you like to access the individual files. No more messing around finding disks and having problems reading them when they get scratched.

You can play straight from the iso (without mounting it) with Xine.

Use:
xine -pfhq dvd:/path/to/iso

Xine can be installed with apt-get install xine-ui

SYSDATE manipulation

I quite often work with database rows that contain audit information which includes the last modified time. Oracle allows SYSDATE addition so that you can add or subtract a number of days (or fraction of days):
select SYSDATE-1 from dual;

would return the current time minus 24 hours. So, if you are in the process of debugging and looking at the database rows you could restrict the select statement to show only those modified by yourself in the last hour:
select * from foo
where
last_modified_date > SYSDATE-(1/24)
and
last_modified_by='bar';


or last half hour:
select * from foo
where
last_modified_date > SYSDATE-(1/48)
and
last_modified_by='bar';

Copy and Paste

Copy and pasting code is a sure sign of a problem that you don't want to have. If you are a development team manager or team leader, then I suggest you set up PMD reports across your code and make use of the Copy/Paste Detector.

Adding these reports to your Maven 2 build is easy, but you can also run it from an ANT build or even through the WebStart client.

In an ideal environment, these reports would be generated and published as part of your continuous integration or nightly build process and would therefore be low maintenance and available at all times.

Keeping an eye on these sorts of reports can help you address issues before they become big problems, which is good for everyone involved. FindBugs is another tool you may want to make use of to keep the quality high.

Burning DVDs with K3B

K3B is a Linux CD/DVD burning application. I was recently using it to burn a DVD ISO image onto a DVD+RW disk, when I came across this error:

/dev/hdd: unable to proceed with recording: unable to unmount
Fatal error at startup: Device or resource busy
Unable to eject media.


This error hadn't occurred the first time I burnt the blank disk (K3B automatically formatted it for me). But this time it turns out that because the disk actually has some content, the DVD drive has been automatically mounted by the OS - and this is now causing problems for K3B. Presumably it can't issue the umount command when I run it because its not running as root.

To resolve this issue, as root, umount the volume:

umount /dev/hdd

Now try burning the disk again, and it should proceed.

Notes:
K3B can be installed on Fedora Linux using:
yum install k3b
Details:
Fedora Core 5 (2.6.16-1.2111_FC5), K3B 0.12.15 (Using KDE 3.5.2-0.2.fc5 Red Hat)