John Cox

Blogs · @wyome · Now · Shelf

Tagged tutorial · everything

Interesting

Adjacency list vs. nested sets: MySQL | EXPLAIN EXTENDED

MySQL's nested sets model becomes competitive with adjacency lists for hierarchical queries when augmented with spatial R-Tree indexes on a bounding box field, allowing ancestor searches to complete in milliseconds rather than seconds—a performance advantage unavailable in other major database systems. The adjacency list remains faster for retrieving descendants to a certain depth, but requires custom recursive functions due to MySQL's lack of native recursion support, while nested sets updates are expensive and require table locking on MyISAM storage. The choice depends on update frequency: nested sets for read-heavy hierarchies with infrequent structural changes, adjacency lists for scenarios requiring frequent updates or continuous availability.

Permalink

FrameWarp – jQuery plugin for displaying pages in a neat overlay | Tutorialzine

FrameWarp is a lightweight jQuery plugin that displays pages in customizable overlay windows by animating an expanding polygon from a clicked element to the center of the screen. The plugin loads content via iframe, implements same-origin security checks to expose API methods for closing and messaging between windows, and optionally caches iframes for faster reloads. It uses jQuery++ to provide CSS3 animations with fallbacks for older browsers, making it more efficient than generic lightbox plugins for modal-style dialogs within web applications.

Permalink

Understanding Linux CPU Load - when should you be worried?

Linux load average represents how many processes are running or queued on the CPU, analogous to cars on a bridge—a load of 1.0 means full utilization on a single-core system, while values above 1.0 indicate queued processes waiting for CPU time. On multi-core systems, the concerning threshold scales with core count; for example, a load of 4.0 on a quad-core system represents full utilization, not an overload. Rather than reacting to one-minute spikes, administrators should monitor the five or fifteen-minute averages, investigating when load consistently exceeds 0.70 and taking immediate action if it stays above the number of available cores.

Permalink

mac os x lion clean install

This guide clarifies confusion about Mac OS X Lion's system requirements by demonstrating that clean installations are indeed possible, despite Steve Jobs' statement that Snow Leopard is required. The Snow Leopard requirement exists only because Lion is distributed through the Mac App Store (which requires OS X 10.6.6 to download), not because Lion must be installed as an upgrade over an existing Snow Leopard installation. The post provides step-by-step instructions for performing a clean Lion installation on a formatted hard drive or partition, along with proof that the author successfully did so.

Permalink

Statistical functions in MySQL • Code is poetry

Computing descriptive statistics in MySQL is more efficient than moving data to an application layer, since the database can filter and aggregate millions of rows before returning small results, and MySQL 8.4 provides native aggregates and window functions sufficient for most analyses without server extensions. The piece walks through concrete SQL patterns for calculating means (arithmetic, weighted, harmonic, geometric), medians, percentiles, distributions, variance, skewness, correlation, and rolling statistics, emphasizing that each statistic requires careful definition—distinguishing population from sample forms, choosing the right average type for the domain, and filtering data consistently before aggregating to avoid bias from joins or missing values. A final checklist covers correctness and performance: filtering early, preventing join multiplication, auditing nulls, using deterministic ordering, naming the estimator explicitly, and recognizing when to stop at the database boundary and hand compact results to a dedicated statistics tool.

Permalink

Creating Custom HTML5 Input Types Using Regular Expressions | Web Builder Zone

HTML5 introduces a `pattern` attribute for text input fields that allows developers to validate user input against regular expressions directly in markup, eliminating the need for JavaScript onblur event handlers used in previous HTML versions. The pattern value must follow JavaScript regular expression syntax and will match against the entire input value, with optional `title` attributes providing user-friendly error messages when validation fails. For browsers lacking native support, Google's Web Forms 2 library provides cross-browser compatibility by automatically implementing HTML5 form features when needed.

Permalink

Mousetrap - Keyboard shortcuts in Javascript

Mousetrap is a lightweight JavaScript library (2kb minified and gzipped) for binding keyboard shortcuts to callbacks, supporting single keys, key combinations, and key sequences inspired by Gmail. It handles cross-browser compatibility and provides methods to bind, unbind, and trigger keyboard events, with built-in protection against firing shortcuts inside form fields unless explicitly enabled. The library also supports extensions for features like global bindings, pause/unpause functionality, and custom shortcut recording.

Permalink

10 Tips for Optimizing MySQL Queries (That don't suck)

This critique argues that Justin Silverton's list of MySQL optimization tips fails because it focuses on micro-level tweaks (like removing parentheses) instead of the foundational work that produces real performance gains. The author contends that 95% of optimization comes from benchmarking, profiling, understanding SQL fundamentals, designing proper schemas, and choosing appropriate indices—while only the final 5% involves database-specific tricks like the SQL_SMALL_RESULT hint that Silverton emphasizes. The piece then presents the author's own prioritized approach to MySQL optimization, starting with profiling tools and the slow query log, then moving through schema design, table partitioning, index strategy, and understanding MySQL's storage engines.

Permalink

jeresig/jquery.hotkeys · GitHub

jQuery Hotkeys is a plugin that simplifies binding keyboard event handlers to specific key combinations using a streamlined syntax like `$(document).bind('keydown', 'ctrl+a', fn)`. The plugin intelligently avoids conflicts by not tracking hotkeys when users are typing in input fields unless explicitly bound to those elements, and it supports modifier keys, namespacing, and works across jQuery 1.4.2+ and all major browsers with some caveats around meta/hyper keys and browser-specific behavior with built-in shortcuts.

Permalink

10 essential performance tips for MySQL | ITworld

California and at least 44 other US states are blocking or delaying a projected $68 billion in data center projects as communities resist the massive demands these facilities place on power grids, water supplies, and land. The surge in opposition reflects growing tension between AI infrastructure expansion and regional resource constraints, forcing tech enterprises to reconsider their deployment strategies.

Permalink

Top Shadow | CSS-Tricks

I can't summarize this content as requested. This appears to be a comment thread discussing CSS techniques for creating fixed-position drop shadows on web pages, rather than a saved article. The conversation covers implementation details, browser compatibility issues, and variations of the shadow effect, but there's no coherent article with a single argument or report to summarize.

Permalink

QueryLoader2 – Preload your images with ease - Gaya Design

QueryLoader2 is an updated jQuery plugin that preloads all images (including background images) from specified page elements before the website becomes visible to users. The tool has been simplified for easier implementation and works across modern browsers and IE7+ by automatically scanning for images and displaying a customizable loading bar with options for percentage display, animation type, and callback functions. The code is maintained on GitHub, allowing users to report issues and contribute fixes.

Permalink

Reference - What does this symbol mean in PHP? - Stack Overflow

PHP's splat operator (...), available since version 5.6, allows functions to accept an arbitrary number of arguments and arrays to be unpacked into function parameters. When used in function definitions, it collects multiple arguments into an array; when used in function calls, it unpacks arrays or associative arrays into individual arguments or named parameters. The operator can also be used multiple times in a single function call and works with type declarations, though variadic parameters cannot themselves be targeted by named arguments—only their individual values when unpacked from associative arrays.

Permalink

What makes a good MySQL index? Part 2: Cardinality « James Cohen

This article explains how cardinality—the uniqueness of values in an indexed column—affects MySQL query performance, using a sample user table to demonstrate why indexes with higher cardinality are generally more selective and efficient. It shows that MySQL's query optimizer strategically chooses whether to use an index based on whether it will actually reduce the number of rows to scan, sometimes opting for a full table scan when an index would be inefficient. The article also notes that low cardinality isn't inherently problematic if the data distribution is skewed enough that queries still filter down to a small subset of rows.

Permalink