John Cox

Blogs · @wyome

Tagged tutorial · everything

Using jQuery .on() and .off() – AndiSmith.com

jQuery 1.7 introduced `.on()` and `.off()` methods that unify all previous event handling approaches (`.bind()`, `.live()`, `.delegate()`, `.unbind()`, `.die()`, and `.undelegate()`) into a single, more efficient syntax. The `.on()` method attaches event handlers with flexible parameters for specifying event types, target selectors, and data, while `.off()` removes those handlers with matching specificity. The article provides migration guides for converting legacy code patterns to these new methods and introduces `.one()` for single-use event handlers.

Permalink

HTML5 download Attribute

HTML5's `download` attribute lets you specify a user-friendly filename for a link's destination file, separate from the actual server filename. This is particularly valuable for dynamically generated files that have cryptic names on the server side but need to appear meaningful to users in download dialogs. The attribute also forces browsers to download the file rather than attempting to open it, eliminating the need for server-side workarounds like PHP headers.

Permalink

Sundry MySQL Scripts and Docs

A collection of MySQL administration scripts that automate performance diagnostics and monitoring tasks. The MySQL Performance Tuning Primer analyzes server status variables to recommend optimal settings for connection limits, buffer sizes, and caching; complementary scripts track replication slave delays, monitor replication thread health, and automate hot backups of both MyISAM and InnoDB databases. The tools are designed to work across multiple MySQL versions (3.23 through 5.6) and various operating systems.

Permalink

A Beginner's Guide to Using the Application Cache - HTML5 Rocks

HTML5's Application Cache allows developers to specify which files browsers should persistently cache, enabling users to browse web applications offline, access them faster from disk storage, and continue using them even during server outages. The feature works through a manifest file (referenced in the HTML tag) that lists resources to cache, with additional NETWORK and FALLBACK sections for handling online-only resources and providing alternative content when resources fail to load. Developers can programmatically monitor and update the cache using the `window.applicationCache` object and its events, though the entire cache only refreshes when the manifest file itself changes—not when individual cached resources are modified.

Permalink

What does "size" in int(size) of MySQL mean? » alexander kirk » Blog Archive

The number in parentheses after numeric types like `INT(11)` specifies display width, not storage capacity—all `INT` values store the same range regardless of whether you write `INT(4)` or `INT(11)`. The display width only becomes functionally relevant when the `ZEROFILL` attribute is applied, at which point MySQL pads values shorter than the specified width with leading zeros (so an `INT(6) ZEROFILL` column displays `010000` instead of `10000`). Without `ZEROFILL`, the display width parameter has no practical effect, meaning values exceeding the width display fully and shorter values display normally.

Permalink

Lazy Load Plugin for jQuery

Lazy Load is a modern JavaScript library that defers image loading until they enter the browser viewport, using the Intersection Observer API to improve page performance on long pages with many images. The library supports multiple initialization methods (vanilla JavaScript or jQuery), optional low-resolution placeholders, responsive images via srcset, and can be configured through IntersectionObserver settings. It includes utility methods to force load all images or cleanly destroy the plugin instance.

Permalink

5 Ways to Boost MySQL Scalability

This article presents five practical techniques for improving MySQL database performance under growing traffic: optimizing slow queries using tools like EXPLAIN and the slow query log; setting up master-master replication to distribute read traffic across slave databases; configuring memory-related parameters like innodb_buffer_pool_size and key_buffer_size; using RAID 10 for disk I/O instead of the slower RAID 5; and tuning specific InnoDB settings like innodb_flush_log_at_trx_commit and innodb_file_per_table. The advice is grounded in common scalability problems the authors encounter with clients, emphasizing that most performance gains come from query optimization since many queries are functionally correct but not stress-tested for high loads.

Permalink

Untitled (http://mashable.com/2012/07/26/mountain-lion-clean-install/)

This guide walks through creating a bootable USB installer for OS X Mountain Lion, either manually using Disk Utility or with automated tools like Lion DiskMaker, as an alternative to upgrading through the Mac App Store for users who prefer a clean install. The process is nearly identical to the previous Lion clean install procedure, with the main difference being that the DMG file must be mounted before restoring to USB. Apple's Recovery Disk Assistant offers another option that can create bootable installation media and restore from Time Machine backups, though at the time of writing it only supported Lion.

Permalink

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