I had my first disk failure this week of my Windows 7 laptop hard drive. Fortunately I’ve been using Windows 7 Backup, and all I had to do was plug in the external USB drive with my backups to another machine, boot off the Windows 7 installation CD, and select ‘Repair…’ using the latest system image from the USB drive. Even restoring a system image from a Dell Latitude to a Toshiba Tecra (with the same sized drive and dual core x64 CPU) was painless, all the necessary drivers were changed automatically with no fuss. The only problem was reestablishing trust with a Windows domain, which was worked around by changing the computer name and re-adding to the domain. The default Windows 7 Backup configuration is to create a system image and backup all files in Libraries, which works just fine for me.
Google Trends – Databases & Languages
Google Trends is a great tool for graphing search term popularity over time. Here is a comparison of searches for several makes of database.
Perhaps it’s a quirk of the phrases I used, but I was surprised to see Oracle so dominant, and even MySQL more popular than SQL Server. PostgreSQL languishes in obscurity compared to MySQL, and Ingres barely registers at all.
Here’s some languages that I’m interested in. Java is hugely dominant.
Let’s take out Java and zoom in. I was surprised to see Ruby’s recent decline relative to Python. Books on Scala have come out only recently.
Looking more specifically at JVM language dialects I’m surprised to see Jython competing so strongly with JRuby. I’m not sure if I picked the right phrase for Groovy.
Choosing tools solely on the basis of popularity is obviously not a great idea, but I do feel better now about continuing to use Oracle, Java and Python.
P.S. See also the TIOBE Programming Community Index
Oracle tablespace utilization
I stole this from VS Babu
SELECT a.TABLESPACE_NAME,
a.BYTES bytes_used,
b.BYTES bytes_free,
b.largest,
round( ( ( a.BYTES - b.BYTES ) / a.BYTES ) * 100, 2 ) percent_used
FROM ( SELECT TABLESPACE_NAME, sum( BYTES ) BYTES
FROM dba_data_files
GROUP BY TABLESPACE_NAME ) a,
( SELECT TABLESPACE_NAME, sum( BYTES ) BYTES, max( BYTES ) largest
FROM dba_free_space
GROUP BY TABLESPACE_NAME ) b
WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME
ORDER BY ( ( a.BYTES - b.BYTES ) / a.BYTES ) DESC
Thunderbird and Lightning, DavMail & Exchange
Thunderbird is a cross platform email client, Lightning is a calendering add-on. Lightning will be integrated into Thunderbird 3. Thunderbird installation is straightforward, Lightning is installed from Thunderbird’s ‘Tools/Add-ons’ menu.
DavMail is an Exchange gateway that wraps standard protocols like IMAP around the proprietary interfaces to Exchange. DavMail setup is straightforward, following the instructions on it’s website, all I had to provide was the OWA URL.
To configure IMAP in Thunderbird all I had to do was specify a server name of localhost and port of 1143, not 143. To configure CalDAV I specified a CalDAV location of http://localhost:1080/users/me@mydomain.com/calendar To configure SMTP for outgoing mail I specified localhost port 1025, not 25.
I couldn’t figure out how to use DavMail LDAP, the documentation is too cryptic. Instead I configured a Thunderbird address book to directly access Active Directory, which works only locally on the LAN. With the address book available autocompletion works also.
Trying to replicate the directory for offline access did not work for me, however. This is supposed to be fixed in a later release. To work around not having the Exchange address book offline I installed Email Address Crawler which instantly scooped every to or from address from my existing mails into an address book. I took this home and it worked as expected: I could send and receive mails and had a limited address book.
Having proven this configuration under Windows I installed Ubuntu in a VM and used Synaptic to install Thunderbird. Lightning and DavMail are downloaded and installed the same way as on Windows. I did, however, run into a defect and workaround installing Lightning.
This solution seems to work OK, but I noticed some issues with the HTML email editor. This is improved in Thunderbird 3, which went into its fourth beta release a few days ago.
Portable PuTTY
Not unusually I work on both Windows and Linux systems, using SQL Server on Windows and Oracle on SuSE. I use Windows as the primary operating system on my workstation because I have greater confidence it will have driver support for devices like built in broadband wireless. Nonetheless I need to SSH regularly into Linux boxes to do administration and script development so I use Xming and Portable PuTTY.
Configuration options are stored in ‘session files’ located in in %appdata%Portable PuTTYsessions. They contain name value pairs like the following:
FontHeight8 FontLucida%20Console … TermHeight43 TermWidth120 WinTitlemyhost.mydomain.com%20-%20PuTTY
The session files may be edited directly, and this appears the only way to update the UserName setting for an SSH autologin, but this approach is unsupported and a corrupted session file is ignored without warning.
To create a shortcut that loads a PuTTY session set the start location to “%appdata%Portable PuTTYsessions” and append a -load parameter to the target invocation.
Cygwin
Like many enterprise developers I use both Windows and Linux. Sometimes I really want to be able to use POSIX text processing tools on Windows, for example when troubleshooting pipe delimted data files used in batch system interfaces. I often have to research issues with pipe delimited transaction logs, and awk can be used to filter out the records of interest, eg.
awk -F| '($3==276||$3==259) && $5=="Payment " { OFS="|"; print $0 }' < transaction_log
Using a command line text tool like this can be much more efficient than importing text files into Excel for filtering. Other text tools I use heavily include find, grep, sed, tr and wc.
POSIX tools for Windows include SUA (aka. Interix, aka. SFU) and MKS toolkit but I prefer Cygwin or Cygwin/X
Under Cygwin I used to use rxvt, but now I’ve switched to mintty which is similar to PuTTY. X can be started from a mintty session as follows:
xwin -multiwindow -clipboard
cx_Oracle callfunc()
I like wrapping database queries in stored procedures: it keeps the SQL in the database, where Oracle can track its dependencies and flag if some change makes it invalid. Here’s an example using Oracle’s demo schema SCOTT:
CREATE OR REPLACE PACKAGE emp_extract_k
AS
TYPE emp_t
IS
RECORD( ename varchar2( 10 ), hiredate date, sal number( 7, 2 ) );
TYPE emp_csr_t IS REF CURSOR
RETURN emp_t;
FUNCTION get_emps
RETURN emp_csr_t;
END;
/
CREATE OR REPLACE PACKAGE BODY emp_extract_k
AS
FUNCTION get_emps
RETURN emp_csr_t
IS
c emp_csr_t;
BEGIN
OPEN c FOR SELECT ename, hiredate, sal FROM scott.emp;
RETURN c;
END;
END;/
Now suppose I want to take the output from a stored procedure like the one above and write it to a CSV file. In Python this is trivially easy:
import cx_Oracle import csv reportName = 'emp_extract_k.get_emps' connection = cx_Oracle.connect(userid) cursor = connection.cursor() rs = cursor.callfunc(reportName, cx_Oracle.CURSOR) fd = open(reportName+'.csv', 'w') csvFile = csv.writer(fd) header = [] [header.append(col_defn[0]) for col_defn in rs.description] csvFile.writerow(header) for r in rs: csvFile.writerow(r) fd.close()
Wakoopa
After just over three months using Wakoopa I am now apparently an expert, having used 200+ applications and websites during over 500+ hours logged on a PC. Much of that time was spent with Quest TOAD, munging Oracle data and researching issues: a couple of weeks I was the heaviest user from Wakoopa and I filled out a review and screenshot. The biggest disappointment was the 3D desktop I tried, but Wakoopa did suggest I try Notepad++ again, and I’ve switched from EditPlus for now. It’s great to browse the categories and see what software is actually used by other members, and what might be the next great tool or package.
VBScript will never die, just fade away
I was looking for an official announcement of the end of life of VBScript but could not find one. Instead I stumbled across the following MSDN blog post with a vague reference: "I believe that it was [at the] IT Forum in Nov 2005 that this was announced." A colorful blog post from Ryan Stemkoski made me laugh, the comments are interesting also. The closest I could find to an official Microsoft announcement was a blog post five years ago by Eric Lippert, who admitted to being the last person to ever add a feature to VBScript, in November 2000.
Office 2003/2007 Coexistence
If you have Office 2003 you can read Office 2007 documents by installing Microsoft’s compatibility pack.
If you have Office 2007 you can make it save in Office 2003 format by default instead of having to remember each time you save, see this article by howtogeek