Annotating Your Logs
We recently did some PostgreSQL performance analysis for a client with an application having some scaling problems. In essence, they wanted to know where Postgres was getting bogged down, and once we knew that we’d be able to target some fixes. But to get to that point, we had to gather a whole bunch of log data for analysis while the test software hit the site.
This is on Postgres 8.3 in a rather locked down environment, by the way. Coordinated pg_rotate_logfile() was useful, but occasionally it would seem to devolve to something resembling: “Okay, we’re adding 60 more users … now!” And I’d write down the time stamp, and figure out an appropriate place to slice the log file later.
Got me thinking, what if we could just drop an entry into the log file, and use it to filter things out later? My first instinct was to start looking at seeing if a patch would be accepted, maybe a wrapper for ereport(), something easy. Turns out, it’s even easier than that…
pubsite=# DO $$BEGIN RAISE LOG 'MARK: 60 users'; END;$$;
DO
Time: 0.464 ms
pubsite=# DO $$BEGIN RAISE LOG 'MARK: 120 users'; END;$$;
DO
Time: 0.378 ms
pubsite=# DO $$BEGIN RAISE LOG 'MARK: 360 …database performance postgres
Interactive Git: My New Found Friend(s)
As a software engineer I’m naturally inclined to be at least somewhat introverted :-), combine that with the fact that End Point is PhysicalWaterCooler challenged and you have a recipe for two things to naturally occur, 1) talking to oneself (but then who doesn’t do that really? no, really.), 2) finding friends in unusual places. Feeling a bit socially lacking after a personal residence move, I was determined to set out to find new friends, so I found one, his name is “–interactive”, or Mr. git add –interactive.
“How did we meet?” You ask. While working on a rather “long winded” project I started to notice myself sprinkling in TODOs throughout the source code, not a bad habit really (presuming they do actually eventually get fixed), but unfortunately the end result is having a lot of changed files in git that you don’t really need to commit, but at the same time don’t really need to see every time you want to review code. I’m fairly anal about reviewing code and so I was generally in the habit of running a git status followed by a git diff on every file that was mentioned by status. These are two great friends, but of late they just don’t seem to be providing the …
git
Postgres Build Farm Animal Differences
I’m a big fan of the Postgres Build Farm, a distributed network of computers that are constantly installling, building, and testing Postgres to detect any problems in the code. The build farm works best when there is a wide variety of operating systems and architectures testing. Thus, while I have a rather common x86_64 Linux box available for testing, I try to make it a little unique to get better test coverage.
One thing I’ve been working on is clang support (clang is an alternative to gcc). Unfortunately, the latest version of clang has a bug that prevents it from building Postgres on Linux boxes. I submitted a small patch to the Postgres source to fix this, but it was decided that we’ll wait until clang fixes their bug. Supposedly they have in their svn head, but I’ve not been able to get that to compile successfully.
So I also just installed gcc 4.6.0, the latest and greatest. Installing it was not easy (nasty problems with the mfpr dependencies), but it’s done now and working. It probably won’t make any difference as far as the results, but at least my box is somewhat different from all the other x86_64 Linux boxes in the farm. :)
I’ve asked before on the list (with no …
community database open-source postgres testing
ActiveProduct — Just the Spree Products
ActiveProduct
I wanted to see how difficult it would be to cut out the part of Spree that makes up the product data model and turn it into a self sufficient Rails 3 engine. I followed the tutorial here to get started with a basic engine plugin. Since it sounded good and nobody else seems to be using it, I decided to call this endeavor ActiveProduct.
Which Bits?
The next step was to decide which parts I needed to get. Minimally, I need the models and migrations that support them. If that works out, then I can decide what to do about the controllers and views later.
That said, the lines between what is needed to create a product and the rest of the system are not always so clear cut. You have to cut somewhere, though, so I cut like this:
- Image
- InventoryUnit
- OptionType
- OptionValue
- ProductGroup
- ProductOptionType
- ProductProperty
- Product
- ProductScope
- Property
- Prototype
- Variant
Models
Each of these has a model file in spree/core/app/models, which I just copied over to the app/models directory of my engine.
Migrations
It’d be convenient if I could have just carved the appropriate parts out of the schema.rb file for the migration. But said file does not appear to be in evidence. Building …
ecommerce rails spree
Referral Tracking with Google Analytics
It’s pretty easy to use Google Analytics to examine referral traffic, including using custom referral tracking codes. Here’s how:
Once you have referrers or affiliates that plan to link to your site, you can ask that those affiliates append a unique tracking ID to the end of the URL. For example, I’ll use the following referral ID’s to track metrics from Milton and Roger’s websites to End Point’s site.
After you’ve seen some traffic build up from those affiliates, you must create two Custom Advanced Segments in Google Analytics:
| Follow the link to create an Advanced Segment. | The New Advanced Segment page. |
Once you’ve landed on the New Advanced Segment page, you create a custom segment by dragging “Landing Page” from the “Content” tab to define the criteria, and set it to contains your unique referral identifier.
| Roger’s Referral Traffic | Milton’s Referral Traffic |
That’s it! You now have custom Advanced Segments defined to track referral or affiliate data. You can select the Advanced Segments from any metrics page:
All traffic compared to referral traffic from Milton and Roger’s sites. …
analytics ecommerce
Lazy Image Loading in JavaScript with jQuery
This week I had a duh moment while working on a little jQuery-driven interface for a side hobby.
I’ve occasionally used or attempted to do image preloading in JavaScript, jQuery, and YUI. Preloading images happens after a page is loaded: follow-up image requests are made for images that may be needed, such as hover images, larger sizes of thumbnail images on the page, or images below the fold that do not need to load at page request time. Adobe Fireworks spits out this code for preloading images, which is a bit gross because the JavaScript is typically inline and it doesn’t take advantage of common JavaScript libraries. But this is probably acceptable for standalone HTML files that get moved between various locations during design iterations.
<body onload="MM_preloadImages('/images/some_image.png','/images/some_other_image.png')">I found many examples of preloading images with jQuery that look something like this:
jQuery.preloadImages = function()
{
for(var i = 0; i<arguments.length; i++)
{
jQuery("<img>").attr("src", arguments[i]);
}
}I implemented this method, but in my code the preloading was happening …
javascript jquery
Liquid Galaxy Project in GSoC 2011!
We’re very happy to announce The Liquid Galaxy Project has been accepted as a Mentoring Organization for the Google Summer of Code (GSoC) Program!
Talented students interested in Liquid Galaxy, panoramic systems, and the opportunity to be paid a stipend of $5000 by Google to develop and enhance open source code should go to the project’s Ideas Page and make a proposal to the project for review:
http://code.google.com/p/liquid-galaxy/wiki/GSoC2011
We look forward to student submissions on these exciting projects that will make Liquid Galaxy an even more impressive system, including:
- Controlling Liquid Galaxy with novel input devices like a Wiimote, Android phone, or Kinect
- Patching other open-source software enabling multi-system panoramic display
- Production of panoramic video, audio, and photography
- Your own innovative idea!
visionport
Product Personalization for Ecommerce on Interchange with Scene7
One of the more challenging yet rewarding projects Richard Templet and I have worked on over the past year has been an ecommerce product personalization project with Paper Source. I haven’t blogged about it much, but wanted to write about the technical challenges of the project in addition to shamelessly self-promote (a bit).
Personalize this and many other products at Paper Source.
Paper Source runs on Interchange and relies heavily on JavaScript and jQuery on the customer-facing side of the site. The “personalization” project allows you to personalize Paper Source products like wedding invitations, holiday cards, stationery, and business cards and displays the dynamic product images with personalized user data on the fly using Adobe’s Scene7. The image requests are made to an external location, so our application does not need to run Java to render these dynamic personalized product images.
Technical Challenge #1: Complex Data Model
To say the data model is complex is a bit of an understatement. Here’s a “blurry” vision of the data model for tables driving this project. The tables from this project have begun to exceed the number of Interchange core tables.
A snapshot of the …
ecommerce interchange

