PL/LOLCODE and INLINE functions
PostgreSQL 8.5 recently learned how to handle “inline functions” through the DO statement. Further discussion is here, but the basic idea is that within certain limitations, you can write ad hoc code in any language that supports it, without having to create a full-fledged function. One of those limitations is that you can’t actually return anything from your function. Another is that the language has to support an “inline handler”.
PostgreSQL procedural languages all have a language handler function, which gets called whenever you execute a stored procedure in that language. An inline handler is a separate function, somewhat slimmed down from the standard language handler. PostgreSQL gives the inline handler an argument containing, among other things, the source text passed in the DO block, which the inline handler simply has to parse and execute.
As of when the change was committed in PostgreSQL, only PL/pgSQL supported inline functions. Other languages may now support them; today I spent the surprisingly short time needed to add the capability to PL/LOLCODE. Here’s a particularly useless example:
DO $$
HAI
VISIBLE "This is a test of INLINE stuff"
KTHXBYE
$$ language …
postgres
ImageMagick EPS bug workaround
Sometimes software is buggy, and even with the malleability of open source software, upgrading to fix a problem may not be an immediate option due to lack of time, risks to production stability, or problems caused by other incompatible changes in a newer version of the software.
ImageMagick is a widely used open source library and set of programs for manipulating images in many ways. It’s very useful and I’m grateful it exists and has become so powerful. However, many longtime ImageMagick users like me can attest that it has had a fair number of bugs, and upgrades sometimes don’t go very smoothly as APIs change, or new bugs creep in.
Recently my co-worker, Jeff Boes, had the misfortune, or opportunity, of encountering just such a scenario. Our friends at CityPass have several site features that use ImageMagick for resizing, rotating, and otherwise manipulating or gathering data about images.
The environment specifics (skip if you’re not troubleshooting an ImageMagick problem of your own!): RHEL 5 with its standard RPM of ImageMagick-6.2.8.0-4.el5_1.1.x86_64. The application server is Interchange, running on our local-perl-5.10.0 nonthreaded Perl build, using the …
open-source perl redhat
Google Summer of Code Mentors Summit
I was able to attend the Google Summer of Code (GSoC) Mentors Summit last weekend in sunny Mountain View, CA. I’d spent the previous few days working with a team to write a mentor’s manual, so was full of ideas when it came time to create the actual sessions during the unconference.
The Mentors Summit is a great opportunity to mingle with the leaders in our many diverse communities. This year, the student participants were capped at 1000, and there were 150 participating open source projects mentoring them. Most of the projects were represented at the Summit.
I attended or presented at three sessions that I’ll quickly summarize:
-
Casablanca: This wasn’t a presentation so much as a discussion. There’s one room designed to be a salon—with lots of interesting gadgets, toys and clay. A group of about 20 of us talked about what they’d learned about mentoring that year, and strategies for getting the most out of students, and recovering from student and mentor failures. Some of the smaller project representatives were in awe of the level of discipline and organization of the larger projects. Several useful wiki templates were shared, as were best practices—like having scheduled, …
conference open-source
Pentaho Reporting 3.5 for Java Developers
I was recently asked to review a copy of Will Gorman’s Pentaho Reporting 3.5 for Java Developers, and came to a few important realizations. Principal among these is that my idea of what “reporting” means includes far too little. Reporting includes much more than just creating a document with some graphs on it—any document or presentation including information from a “data source” comprises a “report”. This includes the typical sheaf of boardroom presentation slides, but also includes dashboards within an application, newsletters, or even form letters. I recently discovered that a local church group uses a simple reporting application to print its membership directory. In short, it’s not just the analysts and managers that can use reporting.
The book gives the reader a tour of Pentaho’s newest Pentaho Reporting system, which consists of a desktop application where users define reports, and a library by which developers can integrate those reports into their own applications. So as an example, not only can Pentaho Reporting publish weekly sales printouts, but it can also produce real-time inventory information in a J2EE-based web application or even a Swing application running on a …
books java pentaho reporting casepointer
Performance optimization of icdevgroup.org
Some years ago Davor Ocelić redesigned icdevgroup.org, Interchange’s home on the web. Since then, most of the attention paid to it has been on content such as news, documentation, release information, and so on. We haven’t looked much at implementation or optimization details. Recently I decided to do just that.
Interchange optimizations
There is currently no separate logged-in user area of icdevgroup.org, so Interchange is primarily used here as a templating system and database interface. The automatic read/write of a server-side user session is thus unneeded overhead, as is periodic culling of the old sessions. So I turned off permanent sessions by making all visitors appear to be search bots. Adding to interchange.cfg:
RobotUA *
That would not work for most Interchange sites, which need a server-side session for storing mv_click action code, scratch variables, logged-in state, shopping cart, etc. But for a read-only content site, it works well.
By default, Interchange writes user page requests to a special tracking log as part of its UserTrack facility. It also outputs an X-Track HTTP response header with some information about the visit which can be used by a (to …
performance interchange seo compression
Upgrading from RHEL 5.2 to CentOS 5.4
I have a testing server that was running RHEL 5.2 (x86_64) but its RHN entitlement ran out and I wanted to upgrade it to CentOS 5.4. I found a few tips online about how to do that, but they were a little dated so here are updated instructions showing the steps I took:
yum clean all
mkdir ~/centos
cd ~/centos
wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/centos-release-5-4.el5.centos.1.x86_64.rpm
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/centos-release-notes-5.4-4.x86_64.rpm
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
rpm --import RPM-GPG-KEY-CentOS-5
rpm -e --nodeps redhat-release
rpm -e yum-rhn-plugin yum-updatesd
rpm -Uvh *.rpm
yum -y upgrade
# edit /etc/grub.conf to point to correct new kernel (with Xen, in my case)
shutdown -r now
It has worked well so far.
hosting
Talk slides are available! Bucardo: Replication for PostgreSQL
I’m in Seattle for the PostgreSQL Conference West today! I just finished giving a talk on Bucardo, a master-slave and multi-master replication system for Postgres.
The talk was full, and had lots of people who’ve used Slony in the past, so I got lots of great questions. I realized we should publish some “recommended architectures” for setting up the Bucardo control database, and provide more detailed diagrams for how replication events actually occur. I also talked to someone interested in using Bucardo to show DDL differences between development databases and suggested he post to the mailing list. Greg has created scripts to do similar things in the past, and it would be really cool to have Bucardo output runnable SQL for applying changes.
I also made a hard pitch for people to start a SEAPUG, and it sounds like some folks from the Fred Hutchinson Cancer Research Center are interested. (I’m naming names, hoping that we can actually do it this time. :D) If you are from the Seattle area, go ahead and subscribe to the seapug@postgresql.org mailing list (pick ‘seapug’ from the list dropdown menu)!
Thanks …
postgres bucardo
Rails Approach for Spree Shopping Cart Customization
Recently, I was assigned a project to develop Survival International’s ecommerce component using Spree. Survival International is a non-profit organization that supports tribal groups worldwide in education, advocacy and campaigns. Spree is an open source Ruby on Rails ecommerce platform that was sponsored by End Point from its creation in early 2008 until May 2009, and that we continue to support. End Point also offers a hosting solution for Spree (SpreeCamps), that was used for this project.
Spree contains ecommerce essentials and is intended to be extended by developers. The project required customization including significant cart customization such as adding a buy 4 get 1 free promo discount, adding free giftwrap to the order if the order total exceeded a specific preset amount, adding a 10% discount, and adding a donation to the order. Some code snippets and examples of the cart customization in rails are shown below.
An important design decision that came up was how to store the four potential cart customizations (buy 4 get 1 free promo, free giftwrap, 10% discount, and donation). The first two items (4 get 1 free and free gift wrap) are dependent on the cart contents, …
ecommerce open-source rails spree