With a little side of applesauce...

Tuesday, April 29, 2008

BASH - text tricks

How do I turn this:

    <option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">Dist of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>

Into this?

Why like this, of course!
cat /tmp/states | awk '{print $2 }' | cut -d\< -f1 | sed 's?value="??g; s?">?|?g' 

Zope - No module named i18n.normalizer.interfaces

This error showed up when I created a new ZEO and ZEO client instance on my server. (Zope/Plone were originally installed into a stand-alone instance by the Plone Unified Installer). This blog entry led me down the right path:

But, my fix was to copy the contents from:

cp -R /path/to/zinstance/lib/python /path/to/zeoclient/lib/python

Then zopectl start as normal.

Monday, April 28, 2008

OpenLDAP - groupOfNames group of object names

I have always thought of groupOfNames as a group of "uid" objects, but now realize that it is really just a group of DNs. I am currently adding groupOfNames to groupOfNames. Now... To figure out how to do a recursive search... Probably at the application layer :)

OpenLDAP - no dynamic groups

Interesting blog post this:
-- snip
A simple solution to this problem is in the use of dynamic groups. One small problem though, a dynamic group is only a concept and, technically speaking, cannot be modeled in OpenLDAP, eTrust and IBM Directory Server. Therefore, dynamic groups functionality must be built into the application security architecture.
-- end snip

Hardy - dual monitor setup fixed

Thanks to bug #199993:

gnome-display-properties wasn't working with my displays (1680-1050 laptop, and 1440x900 external LCD monitor which is used while the laptop is docked). (It was only allowing me to clone the desktops, and wouldn't fire up the external display unless the wind was blowing right). With Gutsy, I used some shell scripts, and just need to add the Display subsection to xorg.conf, with the Virtual size for my dual setup to work again.

Sunday, April 27, 2008

Thursday, April 24, 2008

BASH - add numbers in a file

Here is a cool solution for adding numbers in BASH, (here grep'ing web access stats for 2007):

set -- `< $@` ## for multiple files use: set -- `cat "$@"`
printf "%s\n" $(( ${q// / + } ))


Wednesday, April 16, 2008

MySQL - binary logs fill up /var/log/mysql

An interesting problem happened when MySQL filled up the /var partition with binary logs. Every connection was returning a "Too many connections" error, including mysqladmin -u admin -p shutdown.

Here were the steps I had to take:
1. /etc/init.d/apache2 stop
2. cd /var/log/mysql
3. for f in $(ls -ltr | head | awk '{ print $9 }'| grep -v "^$") ; do rm $f ; done
4. mysqladmin --force -u admin -p shutdown
5. /etc/init.d/mysql start
6. /etc/init.d/apache2 start

Everything was happy :)

I found this juicy tidbit to change the default number of days that binary logs are allowed to remain:

expire_logs_days is a global variable which is set in my.cnf with the following syntax:

expire_logs_days = 40

Firefox - Link to Personal Plugins

Adding this link to show all of my search engine plugins, so I don't have to hunt all over their site to find their developer search :P


Firefox - Plone 3.0 API search engine plugin

Last, but not least, is the search engine pluging for the Plone 3.0 API documentation:

You can narrow the search to "public" or "private" methods by adding that keyword to your search.

Now, that has been fun :) Time to get to work...

Firefox - Google Gdata API javadoc search engine plugin

And... A search engine plugin to search the javadocs for the Google gdata api:

Again, using the OpenSearch creation form :)

Plus, I can recommend the following search plugin for searching java documentation:

Firefox - Python 2.4 and 2.5 Documentation Online Search Engine Plugins

Adding to the Zope 3 apidoc search engine plugin, I am adding Python 2.4 and 2.5 search engine plugins for the Python Online Documentation at pydoc.org:


These are thanks to the cool opensearch search engine plugin creator at:

Zope 3 apidoc search tool for Firefox

I have submitted a new search engine plugin for firefox at:

It searches the Zope 3 apidoc site by keyword.

BTW, it was not me, but the great tool at:

which generated this plugin. (I just resized the logo :P) Thanks, Otto!

Plone folder created in ZMI doesn't exist in Plone until..

Plone folder created in ZMI doesn't exist in Plone until there are children in the folder object... If there are no children, Plone returns the following error, (though the object exists in ZMI):

We're sorry, but there seems to be an error…

The error has been logged as entry number 1208359114.130.723216275373.

If you need to report this to the site administration, please include this entry number in your message.

What is a "large plone folder"?

It is a folder object which is designed to hold 50 or more objects. Thanks, Richard!

Tuesday, April 15, 2008

Emacs - eldav/tramp weirdness

Notes for using Emacs to modify Zope files over webDAV:

emacs 22.1.1 (Ubuntu Gutsy)

1 since tramp is part of emacs 22, I needed to comment our my load entry in the .emacs

;; (require 'tramp)

2 you need to remove the default path entry for find-file ("~/") before starting your webDAV URL, or tramp will be used instead of eldav:

Find file: :http://myzope.com:9080/

3 You need to override the defun 'eldav-file-writable-p' by placing the following line in your .emacs:

(defun eldav-file-writable-p (file) t)

Thanks to the EmacsWiki for the tip!

I have been having issues with davfs2 and locking. It also seems to send a DELETE to the server as well, (thank God for the undo button :) ), plus I have ended up with a NullResource on an existing file, (also thanks undo! ). I'm hoping that emacs with eldav is going to be more stable...

Zope - Don't forget that webdav-source-server

Ye olde webDAV GET problem bit me on Plone today... You need to chttp://www.blogger.com/img/gl.link.gifonfigure the webdav-source-server to start in the /path/to/myinstance/etc/zope.conf:

# valid keys are "address" and "force-connection-close"
address 9080
force-connection-close off

I should know better... :(

Plone - Zope Page Template skeleton

I thought I had posted this at one time, but it must have been lost in the blog migrations over time. Zope Page Templates are central to Plone content creation, but it is difficult to find an example of the additional elements which are needed to get your Page Template to show up in the Plone main slot:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"


<div metal:fill-slot="main">

... fill in some HTML and TAL here


Thanks to the following tutorial for the example:

Interestingly, the page is still not showing up in the parent's "Contents" list, but that is not a blocking bug at this point...

Monday, April 14, 2008

Psycopg2 - "can't set encoding to" error

Due to a missing encoding field in the add.dtml file, psycopg2 sets to the default encoding of "".'t+set+encoding+to%22&hl=en&ct=clnk&cd=1&gl=us&client=firefox-a

This effects version 2.0.6. Here is the diff from my install:

--- DA.py.orig  2008-04-14 16:49:07.000000000 -0500
+++ DA.py 2008-04-14 16:49:37.000000000 -0500
@@ -79,7 +79,7 @@
icon = 'misc_/conn'

def __init__(self, id, title, connection_string,
- zdatetime, check=None, tilevel=2, encoding=''):
+ zdatetime, check=None, tilevel=2, encoding='utf-8'):
self.zdatetime = zdatetime
self.id = str(id)
self.edit(title, connection_string, zdatetime,

Just in case you can't get to the psycopg2 site.

Plone 3 - default index pages

The default index page used to be index_html, but it seems that Plone 3 has removed our ability to define the object id from the front-end, (which makes sense from a certain point of view). Plone 2 also offered a "create a default page" when you created a new folder object, which was nice. Now, Plone replaces the underscore with hyphens, meaning that index_html is given an id of "index-html", which is not included in the default_page list of site-properties. Furthermore, who wants to have a big index.html has a header for their index page? :P This causes the user to drop into the ZMI to rename the page object to "index_html, index.html, index.htm, or FrontPage". End-users don't want this...

Plone 3 - CSS changes without restarting Zope

This was the one blocking bug for me... Every CSS change was forcing a restart of Zope. What a waste of time. The fix is to set the "debug/development mode" flag in the plone_css object per a comment on this page:

Thursday, April 10, 2008

Java command-line arguments

Aahhhhh!! The heavens have opened... :P So the Java command-line delimiter is whitespace, as per:

That isn't a big surprise. BUT, when I am using a shell script to call /usr/bin/java, the command-line args with double or single quotes are split into:

u '"/home/myuser/Mail/Sent' 'Items"'

Sorry, Java!! I was bad-mouthing you the whole time :P

The fix was alluded to the the FAQ at:
http://tiswww.case.edu/php/chet/bash/FAQ Section E14

Assign the value to a SHELL variable, then quote it in the string passed to Java interpreter. ie:

java MyClass arg1 arg2 arg3 "${MYARG}"

Wednesday, April 9, 2008

Gutsy - no nvu

I found that kompozer is the replacement for nvu in gutsy...


Plone 3 - CSS and page templates

Another great post on how CSS and page templates are related:

Plone 3.0 - modify viewlets

Ok, so here is something new to me... I have jumped straight from about Plone 2.1 to 3, so wasn't prepared for viewlets and how to modify the text in the header and footer. This post shows how:

Tuesday, April 8, 2008

Zope/Postgresql - psycopg2

It seems that the folks at psycopg:

are having site issues, so I wasn't able to find the tarball for python-psycopg2. As a work-around, I installed psycopg2-latest.tar.gz from the directory above, and then downloaded the source tarball from the Ubuntu repositories:

then I installed it as normal:

~/plone/Python-2.4.4/bin/python setup.py install

Monday, April 7, 2008

Hardy/Eclipse Europa start problems

"Could not initialize the application's security component. The most likely cause is problems with files in your application's profile directory. Please check that this directory has no read/write restrictions and your hard disk is not full or close to full. It is recommended that you exit the application and fix the problem. If you continue to use this session, you might see incorrect application behaviour when accessing security features."

It is fixed by creating ~/.mozilla/eclipse:

mkdir ~/.mozilla/eclipse


Tuesday, April 1, 2008

Gutsy - sync Palm devices

Worked with a Palm Treo 650:

I then enabled the file conduit under conduit settings, and then got some ideas on how to transfer files from nautilus to the Treo by dragging and dropping them onto the gnome-pilot-applet from this bug:

and, specifically:

Nautilus scripts on Ubuntu


Nautilus - not mount Samba shares?

This seems crazy to me, but Nautilus doesn't mount samba shares to the filesystem... Ouch... I am falling back, and just mounting them manually following the following CentOS guide instructions:

Don't forget to install the smbfs package:

sudo apt-get install smbfs

LDAP - cross-platform browser and administrator

Very nice! It appears that my search for a good LDAP admin/browser is over:

Now, if I can just make the Eclipse editor behave more naturally... :P