Installing PostgreSQL 8.3 from Source

August 14th, 2010

So you like to cook things from scratch.

mv postgresql-8.3.11.tar.gz /usr/local/src
tar xvfz postgresql-8.3.11.tar.gz
cd postgresql-8.3.11
./configure
gmake
gmake install
adduser postgres
mkdir -p /usr/local/pgsql/data

chown -R postgres.postgres /usr/local/pgsql/data
su - postgres

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data > /var/log/pg.log 2>&1 &

admin Uncategorized

ImportError: No module named ext.reader

October 20th, 2009

I got this error while playing around with ZSI. The solution is as simple as installing PyXML.

http://pyxml.sourceforge.net/

For Ubuntu or Debian users a sudo apt-get install python-xml will do the trick. If this doesn’t work for you most likely you have multiple instances of python in your system. Also make sure that the package is installed or included in your python path variable.

erick@mac01 ~ $ python2.4
Python 2.4.6 (#2, Mar 19 2009, 10:00:53)
[GCC 4.3.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/site-python']
>>>

admin Programming, Python ,

Making web services call with HTTP Basic Auth in python

October 7th, 2009

Here is a sample code that will allow you to make web services call that requires HTTP basic authentication.

Assuming we have generated TimeService_services.py and TimeServices_types.py files  using wsdl2py we can do the following

loc = TimeServiceLocator()
kw = {'tracefile': sys.stdout}     # print output to the screen
proxy  = loc.TimeServicePort(url='http://localhost/TimeService.wsdl', ** kw)
proxy.binding.SetAuth(AUTH.httpbasic, 'username', 'password')
# make ws call

admin Python , ,

Speakers makes crakling static noises.

June 18th, 2009

The sound in my ubuntu 9.04 stopped working correctly, and instead of playing a song, all I heard was static.

I tried a number of different things such as restarting pulseaudio and reloading the kernel modules. But the problem was that the PCM mixer’s volume was muted, and a way to change it is with alsamixer.

 alsamixer -Dhw

admin GNU/Linux, Ubuntu, troubleshoothing

keys stop working when using VMWare under Ubuntu

May 7th, 2009

Sometimes the keyboard stops working properly when I run windows inside a VMWare virtual machine. The key bindings gets all screwed up and the the cap locks, shift, and ctrl keys stop working.

As a workaround you can just execute setxkbmap in to remap the the keyboard.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/195982

admin GNU/Linux, Ubuntu

VIm commands for Programmers

March 10th, 2009

These are the VIm commands I found most useful for coding.

Find And Replace

:%s/old/new/g Replace all occurences of “old” by “new” in file
:%s/old/new/gw Replace all occurences with confirmation
:2,35s/old/new/g Replace all occurences between lines 2 and 35
:5,$s/old/new/g Replace all occurences from line 5 to EOF
:%s/^/hello/g Replace the begining of each line by “hello”
:%s/$/Harry/g Replace the end of each line by “Harry”
:%s/onward/forward/gi Replace “onward” by “forward” , case unsensitive
:%s/ *$//g Delete all white spaces
:g/string/d Delete all lines containing “string”
:v/string/d Delete all lines containing which didn’t contain “string”
:s/Bill/Steve/ Replace the first occurence of “Bill” by “Steve” in current line
:s/Bill/Steve/g Replace “Bill” by “Steve” in current line
:%s/Bill/Steve/g Replace “Bill” by “Steve” in all the file
:%s/\r//g Delete DOS carriage returns (^M)
:%s/\r/\r/g Transform DOS carriage returns in returns
:%s#<[^>]\+>##g Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/ Delete lines which appears twice
Ctrl+a Increment number under the cursor
Ctrl+x Decrement number under cursor
ggVGg? Change text to Rot13

Indentation

:set autoindent Turn on auto-indent
:set smartindent Turn on intelligent auto-indent
:set shiftwidth=4 Defines 4 spaces as indent size
ctrl-t, ctrl-d Indent/un-indent in insert mode
>> Indent
<< Un-indent

Syntax highlighting

:syntax on Turn on syntax highlighting
:set syntax=java Force syntax highlighting (try java, perl, python, etc)

admin GNU/Linux, Programming, Tools , , ,

Retrieving Query String Parameters from a JSF Managed bean

February 24th, 2009

Here is a way of retrieving the a query string parameter from a URL. (e.g. http://localhost/app/details.faces?userId=1)


HttpServletRequest request = (HttpServletRequest) FacesContext.
                                        getCurrentInstance().
                                        getExternalContext().
                                        getRequest();
String ID = request.getParameter("userId");

admin JSF, Java, Programming

libnotify

February 21st, 2009

libnotify allows a program send a notification to your desktop through notification-daemon.

To be able to use it in your code you’ll need the appropriate header files and shared library to link against which can be found in the libnotify-dev package.

Here is a sample program taken from the libnotify package source.

#include <libnotify/notify.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char * argv[] )
{
    NotifyNotification *n;  

    notify_init("Basics");

    n = notify_notification_new ("Foo",
                                 "Bar",
                                  NULL, NULL);
    notify_notification_set_timeout (n, 5000); // 5 seconds

    if (!notify_notification_show (n, NULL))
    {
	fprintf(stderr, "failed to send notificationn");
	return 1;
    }

    g_object_unref(G_OBJECT(n));

    return 0;
}

libnotify-run

Alternatively, here is the same program in python.

import pynotify
pynotify.init(’foo’);
pynotify.Notification(’foo’, ‘bar’).show()

admin C/C++, GNU/Linux, Programming, Python , , ,

Hello world!

February 21st, 2009

w00t! First post.

admin Uncategorized