jQuery Tips and an Ecommerce Demo
I’ve recently been jumping back and forth between YUI and jQuery on several different client projects. I prefer working with jQuery, but whenever I work with another framework, I realize what’s out there and how I should continue to improve my skills in my preferred framework. I read up on jQuery tips and put together a summary of common tips I need to follow more explained here in an ecommerce demo.
The Setup
Before we get started, some notes on the ecommerce demo and performance testing:
- The fake product images come from DryIcons
- A JSON array contains product information (price, image, and title).
- The code runs on a quick and dirty sinatra app.
console.time('task')andconsole.timeEnd('task')are used to debug task runtime for performance measurement- The performance numbers provided in the article were measured in Chrome on Ubuntu where the average of 10 tests is reported. In all the tests, an additional for loop was added as part of the test to see measurable performance differences. See the notes at the bottom of the article on performance differences between Chrome and Firefox.

A screenshot from the demo app.
1. The first tip I came across was a recommendation to use a …
ecommerce javascript jquery performance
DROID 2 review
I got a Motorola DROID 2 phone a couple of months ago and have assembled here my notes about how it has worked out so far. First, some background.
This is my second Android phone. My first was the Google Ion, basically the same as the HTC Magic. That was running standard Android 1.5 (Cupcake), while the DROID 2 runs Android 2.2 (Froyo) tweaked somewhat by Motorola. I’ve used several other Android phones belonging to friends and relatives.
Overall I like the Android operating system fairly well. Like everything, it can be improved. It’s been advancing at a fairly quick pace. It’s mostly free software. Too many phones are locked down and have to be broken into to change the operating system, but Android’s still a freer computing environment than most phones have and I hope the situation will improve over time.
I take for granted much of Android’s feature set: The excellent system-wide notification bar that many apps hook into and which is always easy to get to. The solid multitasking. Automatic screen adjustment for using the phone in landscape vs. portrait mode. The ability to mount the normal filesystem on the SD card from another computer via USB or by removing the SD card. The …
android mobile
Ruby Ecommerce with Sinatra: Admin and Products
Last week, I wrote about creating a very simple ecommerce application on Ruby with Sinatra. This week, we continue on the yellow brick road of ecommerce development on Ruby with Sinatra.
A yellow brick road.
Part 2: Basic Admin Authentication
After you’ve got a basic application running which accepts payment for a single product as described in the previous tutorial, the next step is to add admin authorization to allow lookup of completed orders. I found several great resources for this as well as a few Sinatra extensions that may be useful. For the first increment of implementation, I followed the instructions here, which uses Basic::Auth. The resulting code can be viewed here. I also introduce subclassing of Sinatra::Base, which allows us to keep our files a bit more modular and organized.
And if we add an “/admin” method to display orders, we can see our completed orders:
Completed orders.
Part 3: Introducing Products
Now, let’s imagine an ecommerce store with different products! Whoa! For this increment, let’s limit each order to one product. A migration and model definition is created to introduce products, which contains a name, description, and price. For this increment, …
ecommerce rails sinatra
check_postgres without Nagios (Postgres checkpoints)
Version 2.16.0 of check_postgres, a monitoring tool for Postgres, was just released. We’re still trying to keep a “release often” schedule, and hopefully this year will see many releases. In addition to a few minor bug fixes, we added a new check by Nicola Thauvin called hot_standby_delay, which, as you might have guessed from the name, calculates the streaming replication lag between a master server and one of the slaves connected to it. Obviously the servers must be running PostgreSQL 9.0 or better.
Another recently added feature (in version 2.15.0) was the simple addition of a –quiet flag. All this does is to prevent any normal output when an OK status is found. I wrote this because sometimes even Nagios is overkill. In the default mode (Nagios, the other major mode is MRTG), check_postgres will exit with one of four states, each with their own exit code: OK, WARNING, CRITICAL, or UNKNOWN. It also outputs a small message, per Nagios conventions, so a txn_idle action might exit with a value of 1 and output something similar to this:
POSTGRES_TXN_IDLE WARNING: (host:svr1) longest idle in txn: 4638sI had a situation where I wanted to use the functionality of check_postgres …
database monitoring open-source postgres
Ecommerce on Sinatra: In a Jiffy
Several of us at End Point have been involved in a non-ecommerce project for one of our clients running on Ruby, Sinatra, Unicorn, using DataMapper, PostgreSQL, PostGIS, with heavy use of JavaScript (specifically YUI). Sinatra is a lightweight Ruby web framework – it’s not in direct competition with Rails but it might be a better “tool” for lightweight applications. It’s been a fun project to work with Sinatra, DataMapper, and YUI as I’ve been working traditionally focused on their respective related technologies (Rails, ActiveRecord, jQuery).
Out of curiosity, I wanted to see what it might take to implement a bare-bones ecommerce store using Sinatra. Here is a mini-tutorial to develop an ecommerce store using Sinatra.
A snapshot of our final working app.
Getting Started
I create a new directory for the project with the following directories:
sinatrashop/
db/
migrate/
models/
public/
images/
stylesheets/
views/Data Model
Now, let’s look at the data model. Since this is a bare-bones store, I have one order model which contains all the order information including contact information and addresses. We’re not storing the credit card in the database. Also, since …
ecommerce ruby sinatra
Zayda Internet joins End Point
End Point is pleased to announce the merging of web hosting firm Zayda Internet into our company as of December 2010.
Zayda Internet was a small hosting company that started in 1999 and focused on Linux web and email hosting and consulting for many small businesses and individuals, and a few larger sites including most prominently the busy community site OSNews.com.
We’re happy to welcome all Zayda Internet customers into the End Point fold and look forward to working with them in the future.
company
DBD::Pg, UTF-8, and Postgres client_encoding
Photo by Roger Smith
I’ve been working on getting DBD::Pg to play nicely with UTF-8, as the current system is suboptimal at best. DBD::Pg is the Perl interface to Postgres, and is the glue code that takes the data from the database (via libpq) and gives it to your Perl program. However, not all data is created equal, and that’s where the complications begin.
Currently, everything coming back from the database is, by default, treated as byte soup, meaning no conversion is done, and no strings are marked as utf8 (Perl strings are actually objects in which one of the attributes you can set is ‘utf8’). If you want strings marked as utf8, you must currently set the pg_enable_utf8 attribute on the database handle like so:
$dbh->{pg_enable_utf8} = 1;This causes DBD::Pg to scan incoming strings for high bits and mark the string as utf8 if it finds them. There are a few drawbacks to this system:
- It does this for all databases, even SQL_ASCII!
- It doesn’t do this for everything, e.g. arrays, custom data types, xml.
- It requires the user to remember to set pg_enable_utf8.
- It adds overhead as we have to parse every single byte coming back from the database.
Here’s one proposal for a new …
database dbdpg perl postgres
SSH config wildcards and multiple Postgres servers per client
The SSH config file has some nice features that help me to keep my sanity among a wide variety of servers spread across many different clients. Nearly all of my Postgres work is done by using SSH to connect to remote client sites, so the ability to connect to the various servers easily and intuitively is important. I’ll go over an example of how a ssh config file might progress as you deal with an ever‑expanding client.
Some quick background: the ssh config file is a per‑user configuration file for the SSH program. It typically exists as ~/.ssh/config. It has two main purposes: setting global configuration items (such as ForwardX11 no), and setting things on a host‑by‑host basis. We’ll be focusing on the latter.
Inside the ssh config file, you can create Host sections which specify options that apply only to one or more matching hosts. The sections are applied if the host name you type in as the argument to the ssh command matches what is after the word “Host”. As we’ll see, this also allows for wildcards, which can be very useful.
I’m going to walk through a hypothetical client, Acme Corporation, and show how the ssh config can grow as the client does, until the final example …
clients linux postgres ssh sysadmin tips



