Tareq Alam

i have promises to keep and miles to go before i sleep – Robert Frost

download xml of various settings of plone from zmi April 1, 2009

in zmi of plone click on portal_setup
click on export tab
click on export selected steps button and save in local
done
u can now use these xmls where u need them

 

install python 2.4.3 in ubuntu 8.10 March 15, 2009

Filed under: Ubuntu, Zope, ploneCMS, python — tareqalam @ 2:14 pm
Tags: , ,

I have got error at first when i tried to install python 2.4.3 in ubuntu 8.10

error is something like this:

/usr/bin/install -c -m 644 ./LICENSE /usr/local/lib/python2.4/LICENSE.txt
PYTHONPATH=/usr/local/lib/python2.4   \
./python -Wi -tt /usr/local/lib/python2.4/compileall.py \
-d /usr/local/lib/python2.4 -f \
-x ‘badsyntax|site-packages’ /usr/local/lib/python2.4
*** buffer overflow detected ***: ./python terminated
then i searched the net for solution i got this

https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/286334

and the solution isgo inside the python 2.4.3 directory

$ ./configure CC=gcc-4.2 # works
$ ./configure OPT=”-g -O0″ # works

then

$ make

$sudo make install

then the python 2.4.3 will be installed

I need that version of python to run the bootstrap.py of plone svn

now I am happy that the buildout is running ..

Thanks

 

Internet explorer loads same image more than once with ajax December 5, 2008

In Internet Explorer  when an html is loaded with image inside if the image is same in all img tag internet explorer loads the image each time it foinds in img tag.. this makes the ajax loading slower. AJAX is used to make a web page faster but IE seems having problem with that.

To solve this i have applied an idea .. searching google i came to know that IE loads single time of same image located in style background of an element. so I made img tag to div with style background property to the src of the image … now if i load 100 of that div via ajax it loads only one time. Thus my web page loads faster in IE.. Thanks to FireFox it behaves nice with this problem.

Hope this helps

 

If you forget password of ZMI (zope management interface) … dont panic November 29, 2008

Filed under: Ubuntu, Zope, ploneCMS — tareqalam @ 6:19 am
Tags: , , , ,

here is a way to create a new user of zope

open terminal … go to zope instance directory.. (cd parts/instance in my case)

then type

bin/zopectl adduser user1 password1

then a user will be created with username user1 and password passord1

you can login with this
 

python setlocale .. not working?make it work.. November 22, 2008

Filed under: Ubuntu, python — tareqalam @ 2:46 pm
Tags: , , , ,

when you are using the function in python:

locale.setlocale(locale.LC_ALL, ‘en_GB‘)

have you got this error message?

return _setlocale(category, locale)
locale.Error: unsupported locale setting

Then you should do what I have done in ubuntu..

This intelligent man helped me .. please go to this link and follow the steps to add the locale to the list of ’supported locales’

http://blog.andrewbeacock.com/2007/01/how-to-change-your-default-locale-on.html

Also I am writing it here for your convenience:

Edit /var/lib/locales/supported.d/local and add the following line:
en_GB ISO-8859-1

Then run the python script again .. hope it will not show error this time

THanks

 

Pack ZODB with repozo.py October 25, 2008

Hi I have created a script which will pack zodb. here is the code:

#pack zodb with repozo.py

### CONFIGURATION START ##########
ZOPE_HOME=/home/tareq/Plone-3.1/zeocluster/parts/zope2 # this is the zope home find your zope home #from zmi control panel
PYTHONPATH=$ZOPE_HOME/lib/python # this is the python path that the zope is using
PATH_TO_REPOZOPY=/home/tareq/Plone-3.1/zeocluster/bin/repozo.py # find the repozo.py to find in #terminal type: locate repozo.py
BACKUP_DIRECTORY=/home/tareq/plone/Learning # where you want to keep the backup of data.fs file
PATH_TO_DATAFS_FILE=/home/tareq/Plone-3.1/zeocluster/var/filestorage/Data.fs #this is the path of zodb #database Data.fs

################### N-O N-E-E-D T-O E-D-I-T A-F-T-E-R T-H-I-S L-I-N-E ##############################
export PYTHONPATH #this is needed to be done else repozo.py cant find path

COMMAND_DB_BACKUP=”$PATH_TO_REPOZOPY -BvQ -r $BACKUP_DIRECTORY -f $PATH_TO_DATAFS_FILE” # creating the command here
`${COMMAND_DB_BACKUP}` # this line executes the command

### HOW TO RUN THIS COMMAND ##########

#1. Open Terminal type sh packzodb.sh
#see files created in the BACKUP_DIRECTORY
# Simple ;)

 

Ubuntu: mounting external drives forcefully October 17, 2008

Filed under: Ubuntu — tareqalam @ 7:05 am
Tags: , , ,

I am using both XP and ubuntu in 2 separate hard drive in the same pc. Couple of days ago i have installed XP in the secondary hard drive. I dont know why but after that I couldnt mount or see inside my drives where the xp is installed from ubuntu. Then I found help in ubuntu forum.http://ubuntuforums.org/showthread.php?t=603

I am just explaining what I have done:

opent terminal

tareq@User: sudo mount -t ntfs-3g /dev/disk/by-label/drive_name /media/a_directory/ -o force

If the directory is not created in media directory you have to create it first. with the command

tareq@User: sudo mkdir /media/a_directory

then run the above command

hope this works

 

multivalent: java tool to compress pdf September 30, 2008

Filed under: Ubuntu, java — tareqalam @ 9:59 am
Tags: , , ,

here i am describing how I have used multivalent
help link: http://multivalent.sourceforge.net/Tools/pdf/Compress.html
download link: http://sourceforge.net/project/showfiles.php?group_id=44509
to install:
1. place the attached jar file to anywhere in server
2. in terminal ype: sudo vi /etc/environment this will open a file something like this:
PATH=”/usr/local/sbin:/usr/

local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”
LANG=”en_US.UTF-8″
CLASSPATH=”:/home/tareq/projects/itext/iText-2.1.3.jar:/home/tareq/projects/itext/Multivalent20060102.jar:”

add the class path like the example here this /home/tareq/projects/itext/ path can be anywhere
3. restart the server
4. now run the python script placing it to the correct place or you can test in terminal just type java tool.pdf.Compress path_to_pdf_file

hope this works

 

install skype in ubuntu September 25, 2008

Filed under: Linux, Ubuntu, important links — tareqalam @ 10:21 am
Tags: , ,

Got this from ubuntu forum:

Skype Repository

  1. Add the Skype repository*: deb http://download.skype.com/linux/repos/debian/ stable non-free

  2. Reload or update the package information
  3. Install the skype package.

 

R and Rpy September 21, 2008

Filed under: Linux, Ubuntu, python — tareqalam @ 1:14 pm
Tags: , , , ,

R is a strong language. And there is a way in python with that R can be used that is called Rpy http://rpy.sourceforge.net/

its easy to install. here I will show you an example to create simple graphics using rpy

from rpy import *

def create_simple_bar_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
r.plot(r.table(r.rpois(150,7)),ylab=”hospital”,xlab=”patient”, type = “h”, col = “red”, lwd=10,main=”number of patients per hospital”)
r.dev_off()

def create_hist_with_R(file_name,size=5,bottom=1,left=1,top=0,right=0):
x = [24,60,18,63,32,47,88,64,72,87,100,16,37,46,50,\
64,11,45,77,35,38,39,84,90,6,87,25,67,51,71,52,\
98,57,5,65,75,8,68,35,75,95,29,50,44,30,1,92,93,\
56,56]

if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
#r.plot(r.table(r.rpois(100,5)),xlab=”frequency”, type = “h”, col = “red”, lwd=10,main=”rpois(100,lambda=5)”)
r.hist(x, xlab=”frequency”, ylab=”count”, main=”histogram example using R”, col=’cyan’)
r.dev_off()

def create_simple_bar_chart_rainbow(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)

r.plot(r.cos, -r.pi, 2*r.pi,col=r.rainbow(20),ylab=”biologic”,xlab=”total”,main=”Test Data”)

r.dev_off()
def draw_pie_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)

r.pie(r.rep(1, 24), col = r.rainbow(24), radius = 0.9,main=”test pie chart”)

r.dev_off()

draw_pie_chart(“rgraphics_pie.pdf”,5,1,1,0,0)

create_hist_with_R(“rgraphics_hist.pdf”,5,1,1,0,0)

create_simple_bar_chart(“rgraphics_bar.pdf”,4,5.5,0.5,0,0)