Clipbook.it Website Architecure 1.0

Client: HTML + CSS + JavaScript + JQuery
Server-Side Web Tier: PHP
Data Tier: Python + MySQL

Client Tier

The client tier is the standard HTML, CSS and JavaScript. JavaScript is supported by JQuery.

Web Tier

The web layer is written in PHP. It roughly follows the principles outlined by Rasmus Leodorf's "No-Framework PHP MVC Framework".

Delete Records Recursively

I needed to delete records from a PostgreSQL table that has descendant tables related by foreign keys. Some tables have multiple foreign keys which complicates the matter. Here's the pseudo code to do it:
def delete_records(table, parent_tables=[]):
    "Pseudo code to delete all records from a table and its descendants"
    parent_tables.append(table)
    for child in child_tables(table):
        delete_it = True
        for fkey in foreign_keys_from(child):
            if not (fkey.f_table in parent_tables):
                delete_it = False
                break

        if delete_it:
            delete_records(child)
    execute_sql("DELETE FROM %s" % table)

PHP, Python, Ruby and JavaScript

Below, I list what I think the advantages are that one language has over the others. It should be noted that very often these advantages only apply within specific contexts.

What PHP has over Python and Ruby:

Introducing SQittle

SQittle is an SQL engine I wrote in JavaScript.

See the demo.

To read more about it, or get the source code, go to the SQittle page at GitHub.

Complex mocking with PHPUnit

PHPUnit provides an API for creating Mock Objects and testing code with them.

Clojure Tutorial For the Non-Lisp Programmer

Clojure is a new programming language that uses the Java Virtual Runtime as its platform. Clojure is a dialect of Lisp. The language home page is at http://clojure.org/.

Simple CRUD Generator

This is a simple application that lets you browse and edit a MySQL database in a CRUD-like manner. It requires PHP 5. Be warned, it doesn't generate code. Instead, it produces a user interface on-the-fly.

The user interface consists of three pages. One page show the tables. The second page shows the records for a given table, and the third page allows you to edit a record.

The application is based on some form generation work I've been developing for Modern Merchant. This opens up the application to some interesting extension points.

Try out Modern Merchant

I'm getting really excited about Modern Merchant. It's an open source e-commerce application (shopping cart) that I've been developing. It's developer-friendly, modular and object-oriented. Version 0.6 has just been released. If you're looking for an e-commerce application, give this one a try.

Javascript Console For IE

New Version: 0.4

I love Firebug for Firefox, but I really don't like debugging Javascript in IE.

I wrote this little console so that I can kind of see what's going on when scripts in IE don't behave the same way as in Firefox. It's inspired by one of my most favorite web development tools ever, Firebug, which is a Firefox extension.

It has three features:

  1. Outputs messages from anywhere in your javascript code.
  2. Provides a console to display the messages and evaluate Javascript expressions.
  3. Has a history of all the Javascript expressions entered. You can navigate the history with the up and down arrows.

Download it: ie-console.js

Try it!. You don't need IE to try it out. However, the history feature doesn't work in Firefox.

Enter this into the console:

document.body.childNodes

Instructions

  1. Download and save ie-console.js to your website
  2. Include the script in your HTML like this:
    <script type="text/javascript" src="/js/ie-console.js"></script>
  3. Press F12 to open the console.
  4. Or, use console.log() in your JavaScript code to output debugging messages, just like Firebug.
  5. Press F12 again to close the console.

Lightweight Neural Network Ruby Extension

[Updated: 2008-3-3]: I completed a Ruby extension to the Lightweight Neural Network C library. I really wanted to get into the thick of writing Ruby, and at the same time, I was getting into artificial neural networks, so I came up with a fun project. It's a Ruby extension for the lwneuralnet C library. The extension currently lets Ruby programmers create a simple back propagation network that can be trained to recognize patterns in its input.
Download and learn about the lwnueralnet C library here.
Syndicate content