LAMP server in Ubuntu 11.x / 10.x

October 1st, 2011

It doesn’t get any easier than this.

sudo apt-get install lamp-server^

It will install all these packages for you…

apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common
libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1
mysql-client-core-5.1 mysql-common mysql-server mysql-server-5.1
mysql-server-core-5.1 php5-cli php5-common php5-mysql

I noticed that PHP doesn’t work after the install. So all you have to do is restart apache.


$ sudo /etc/init.d/apache2 restart

Installing rsyslog

September 22nd, 2011

# INSTALL RSYSLOG
sudo yum install rsyslog

# DISABLE STOCK SYSTEM LOG
sudo /etc/init.d/syslog stop
sudo /sbin/chkconfig –level 2345 syslog off

# ENABLE RSYSLOG AT STARTUP INSTEAD
sudo /sbin/chkconfig –level 2345 rsyslog on

#Now EDIT /etc/rsyslog.conf AS FOLLOWS
$umask 0000
$ModLoad imudp
$UDPServerRun 514

My .vimrc and .gvimrc

September 22nd, 2011

I find these settings handy specially for coding in python.

.vimrc

syntax on
set ai
set number
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
set smarttab
set smartcase

.gvimrc

set guifont=Bitstream\ Vera\ Sans\ Mono\ 9
set lines=45 columns=110

Color schemes are optional

colorscheme torte

How to remove blank lines in Netbeans

September 22nd, 2011

Netbeans 7.0.x doesn’t provide a shortcut to delete blank lines. Fortunately this can be achieved by doing a replace operation:

Make sure you select regular expressions checkbox.

Search patter: \n\s*(\n)
Replace with: $1

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 &

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']
>>>

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

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

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

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)