John Cox

Blogs · @wyome

Tagged programming · everything

MySQL Triggers: An instruction guide

MySQL triggers are database objects that automatically execute procedural code in response to INSERT, UPDATE, or DELETE events, enabling complex data maintenance across multiple tables without requiring application-layer logic. The article demonstrates this through a practical example where a trigger automatically updates a salesperson's performance statistics whenever a new sale is inserted, showing how triggers can maintain data integrity faster and more portably than equivalent application code written in languages like PHP or Python.

Permalink

jQuery Calculation Plug-in

This documentation describes a jQuery Calculation plug-in that extracts numerical values from DOM elements like input fields, divs, and spans to perform dynamic mathematical operations. The plug-in can calculate sums, averages, minimums, and maximums from parsed numbers, with error handling that highlights fields containing non-numeric values. It supports automatic recalculation when values change and can be applied to practical scenarios like computing product totals and grand totals in shopping carts.

Permalink

An Introduction to MySQL Views - Techotopia

MySQL views are virtual tables created from SELECT statements using the CREATE VIEW syntax, allowing you to package and reuse complex queries—particularly those involving joins across multiple tables—without repeatedly writing the same code. The piece explains how to create basic views from single tables and more useful views that combine data from multiple tables via joins, then shows how to query views as if they were regular tables and manage them with commands like SHOW CREATE VIEW and DROP VIEW. Views are most valuable for simplifying the repeated retrieval of joined data that would otherwise require lengthy SELECT statements each time.

Permalink

jLinq

jLinq is a JavaScript library that lets you query arrays of JSON objects using fluent, chainable syntax instead of loops and conditionals, making it easier to filter, sort, and transform data. The library supports complex queries like filtering records by multiple conditions and sorting by multiple fields, with readable method chaining (for example, filtering people whose first names start with 'a', 'b', or 'c', then sorting by last name). It's also extensible, allowing developers to create custom functions that integrate seamlessly into the library's query interface.

Permalink

How I Hire Programmers (Aaron Swartz's Raw Thought)

The author proposes an alternative hiring process for programmers that replaces traditional interviews with three main steps: evaluating past work through code samples and demos, assessing intelligence through casual conversation (not formal interviews), and checking compatibility through informal team activities, followed by a final sanity check of assigning a small project. He argues this approach reveals whether candidates are genuinely smart, can execute, and work well with others better than standard interview questions do, though he acknowledges it requires a small sanity-check project to verify candidates haven't misrepresented themselves.

Permalink

PHP, XML, and Character Encodings: a tale of sadness, rage, and (data-)loss

A developer documents their multi-layered solution to handling international character encoding in RSS feeds across the Feed on Feeds aggregator, discovering that PHP's XML parser defaults to ISO-8859-1 and only natively supports three encodings, then implementing a workaround that detects the feed's declared encoding and uses the mbstring extension to convert non-standard charsets to UTF-8 before parsing. The post chronicles the frustrating limitations of PHP 4's XML support and notes that PHP 5's improvements, while better, remain artificially restricted by unclear design choices that will take years to deploy in practice.

Permalink