2011-07-01

Compiling cx_Oracle for Python from Source on Solaris

We needed to use cx_Oracle on Solaris. cx_Oracle is a Python driver for Oracle. It is mentioned in Oracle FAQ.

In each version, the binaries for Windows and Enterprise Linux are released, but there are no pre-built binary packages for Solaris.

But you can easily download the source package and compile for your system. Its README file mentions that it compiles on Solaris and even they had being informed about successful compilation on Mac OS X.

This post assumes that Oracle was already installed on the system, as in my case.

I have downloaded the "Source Code only" package. For version 5.1, find it here. Download and extract the file, and open a terminal to the directory containing "setup.py".

As its README file says, use the following commands to build (become "root" first):
python setup.py build 
python setup.py install 

After the compilation, you need to do something unrecommended, setting "LD_LIBRARY_PATH", which is labeled as "bad".

Note that using Oracle requires you to use the account "oracle", so we will be using its ".profile" file.

If you "LD_LIBRARY_PATH" is not defined in the profile, you can add the following to the end of the file ".profile".
LD_LIBRARY_PATH=/usr/lib/:$ORACLE_HOME/lib32/ 
export LD_LIBRARY_PATH 

If you have already defined "LD_LIBRARY_PATH" you can add the following code instead:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib32/ 
export LD_LIBRARY_PATH 

If everything went well, you can use it in Python:
import cx_Oracle 
Note that the "oracle" user should be used, not "root".

I have accomplished this using Python 2.4.4 and cx_Oracle 5.1.

To see your Solaris version use the following command:
cat /etc/release 
# Solaris 10 5/09 
# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved. 
# Use is subject to license terms. 
# Assembled 30 March 2009 

2011-06-27

Some Customizations on the Blog for Displaying and Printing, Vim Helps

I have made some theme customizations and modified two previous posts targeting less JavaScript requirements, shorter load time and some aesthetic.

I save web pages. I always do. I do not bookmark everything, but I print pages in PDF format. This way I can read them later, without making my bookmarks fat. They are already fat enough. I see my readings as my data, and I want to store them. And I go angry against unprintable, very very long pages. I also use ScreenGrab to store the screen-shot of a web page, but it can get stuck with the long web pages.

And I was thinking, my simple blog should be easily printable too. But it was not. Sadly, it seems that Blogger pages(may be not Blogger, but all the themes I have ever used in Blogger) can not be completely printed. Also I am a PasteBin user, and I have used its feature of embedding code pieces to the blog. But that made printing much more difficult. Without PasteBin code embedding, a great site, PrintFriendly, was able to print, but with embedded code from PasteBin, even PrintFriendly could not print the pages. So, I have decided to modify the blog, and make it printable as much as possible.

The first was to remove the embedded code from PasteBin and directly putting the code inside the blog post body. This way I could also control the colors.

As I am a Vim user, it is not difficult to find a cool Vim plugin, ScreenShot.vim to convert code pieces to HTML. By this way, I can easily convert a portion of code to HTML. The output of ScreenShot.vim is different from the built-in "TOhtml" command. ScreenShot.vim provides 3 commands essentially.

Screenshot : Just like it says, it takes the screenshot of the Vim window.
Its output looks like this:

 31 # This is only the file name:
 32 db_name = "our_db.sqlite"
 33 
 34 # The protocol and full path to our database
 35 db = DAL('sqlite://' + db_name, folder=modul

 36 
 37 # Define the table "genre", note that the fi
 38 db.define_table("genre",
 39         Field("name"))

 40 db.genre.name.requires = IS_NOT_EMPTY()
 41 
 42 # Define the table "band", note that the fie
 43 # band.genre_id references to genre.id field
 44 db.define_table("band",

 45         Field("name"), 
raw.py                        40,1           42%


Second command, Text2Html, converts the selected text to HTML. Looks like the built-in TOhtml command, but, TOhtml command creates a page with <html>, <head> etc. On the other hand, Text2Html command creates a portion of an HTML page, starting with a <table> and ending with a </table>, ready to embed in the blog post body or somewhere else. See a modified, previous blog post to have an idea on how it looks like. This is the command I will be using frequently from now on.

And the third command, Diff2Html is used to display two files comparing with differences highlighted.

Also there had been some color inconsistencies in this blog, but finally there will be no more. I will be using Molokai color scheme for Vim, based on Monokai for TextMate, since I like it much and goes very well with the current dark theme of the blog.

The ScreenShot.vim plugin is configurable. Read its script page for more options. Here are my settings from my vimrc targeting saving the maximum screen space:

let g:ScreenShot = { 
    \ 'Title' : 0, 
    \ 'Icon' : 0, 
    \ 'Credits' : 0, 
    \} 

Note that I have deleted the line numbers in the code above using Vim, it has no configuration in ScreenShot.vim it seems, but was a piece of cake using Vim's columnar editing.

Want to see it on PrintFriendly.com? Click here. It will remove the gadgets and other giggling things, and you will see clean, printable version of this blog post. I highly recommend PrintFriendly by the way.

After this modifications, the blog site is faster, more accessible, has more width in the layout, will display anyway if you use a JavaScript blocker like NoScript and it looks better. Have an advice? You are welcome.