John Cox

Blogs · @wyome · Now · Shelf

Tagged tutorial · everything

Interesting

Optimizing the MySQL IN() Comparison Operations Which Include the Indexed Field – MySQL Diary

When a MySQL IN() clause references a field that's part of the query's index, the database evaluates the full result set for each IN value before merging and limiting results, which is expensive on large tables. Replacing the IN clause with a UNION ALL of separate queries—each with its own LIMIT—forces MySQL to limit results at each step before merging, dramatically improving performance. The post demonstrates this with a concrete example where `WHERE b=4 AND c IN (1,3,5,7,9)` becomes five separate queries joined with UNION ALL, each limited to 100 rows before the final merge and sort.

Permalink

(500) http://news.ycombinator.com/item?id=709713

This conversation discusses the trade-offs between nested set models and materialized path approaches for storing hierarchical data in relational databases. Commenters argue that materialized paths—storing the full path to each node as a denormalized column—offer simpler implementation and cheaper insert/delete operations than nested sets, though they require updating all descendant paths when moving subtrees and may have performance limitations with very large datasets. The discussion also touches on alternative approaches like PostgreSQL's native ltree type and adjacency lists, with general consensus that different tree storage methods suit different use cases and that no single approach solves all hierarchical data problems optimally.

Permalink

HTML5 Rocks - Improving the Performance of your HTML5 App

Smoothness in web animations depends on consistent frame rates rather than high absolute fps—true 30 fps is preferable to 60 fps with dropped frames since users perceive jaggedness. The article provides techniques for improving animation performance through GPU acceleration, CSS transitions, proper DOM interaction patterns, and profiling strategies that identify bottlenecks in JavaScript and browser rendering cycles. Key optimization tactics include caching DOM nodes, batching DOM reads and writes, using CSS transforms instead of position changes, and leveraging requestAnimationFrame for JavaScript animations.

Permalink

The Current State of HTML5 Forms · Wufoo

HTML5 introduces new form input types (email, tel, color, date, etc.), attributes (placeholder, required, pattern, etc.), and elements (datalist, meter, progress) designed to improve both development and user experience, though browser support varies significantly across vendors and versions. The document provides detailed compatibility tables showing which features are supported in major browsers, along with practical guidance for testing support, using JavaScript methods for form manipulation, and applying CSS styling to HTML5 form elements. Even when support is incomplete, these features degrade gracefully in older browsers, functioning as text inputs while still allowing developers to enhance modern browsers.

Permalink

Untitled (http://27.org/isocountrylist/)

This page describes a reusable SQL database table of ISO 3166 country codes and names that the author created to avoid repeatedly building the same reference data from scratch for international user registration forms. The author provides the downloadable SQL file, explains how to import it into MySQL, and demonstrates with PHP code how to use it to generate drop-down select lists while maintaining data integrity through foreign keys. The page also documents updates over several years, including additions of 3-letter codes, properly capitalized country names for display, and a similar table for U.S. states and postal abbreviations.

Permalink

10 Rock Solid Website Layout Examples | Design Shack

This article presents ten versatile, tried-and-tested webpage layout templates—ranging from simple three-box designs to complex power grids—that designers can adapt when facing creative block. The author emphasizes that while each layout appears in countless websites, their styling (colors, fonts, graphics) can be made unique, and the layouts themselves should be modified rather than used as-is to suit individual project needs. The piece includes silhouettes, real-world examples, and template recommendations for each layout to demonstrate practical applications across portfolios, e-commerce sites, blogs, and corporate pages.

Permalink

Curing the Navigation-itis Syndrome | SpyreStudios

The article argues that excessive website navigation menus—"navigation-itis"—overwhelm users and reduce engagement, then provides nine practical design principles to simplify the experience, including consolidating multiple menus into one, limiting dropdown depth to two levels, and keeping items text-based rather than icon-only. It illustrates these principles through a critique of National Geographic's website, which uses three separate navigation bars, and shows how dropdown menus and search consolidation could reduce cognitive load while preserving access to all content.

Permalink

Using Flexviews – part one, introduction to materialized views - MySQL Performance Blog

Flexviews is a tool that enables incrementally refreshable materialized views in MySQL—pre-computed, stored query results that update only the changed rows rather than recalculating from scratch. Unlike regular views (which recompute on every access) or complete materialized view refreshes (which rebuild entirely), incremental refresh examines only rows that changed since the last refresh, making it orders of magnitude faster for large datasets while maintaining transactional consistency across multiple views. The tool works through three mechanisms: capturing what changed in the database, computing the differences those changes produce, and applying those differences to update the stored results.

Permalink

Speeding Up Your Website’s Database - Smashing Magazine

While website speed improvements typically focus on file sizes and server settings, database query optimization is equally critical—a homepage might load in 1.5 seconds while slow database queries bog down search or product pages. The article provides practical techniques for identifying and fixing database bottlenecks, starting with simple methods like adding indexes to frequently queried columns (which can speed up queries 100+ times) and progressing to more complex solutions like restructuring queries with JOINs, caching results, and optimizing table storage. These approaches help developers diagnose whether sluggish page performance stems from poor database design or slow queries rather than network or server issues.

Permalink

What’s The Best Date Format? » SitePoint

ISO 8601 format in UTC (2011-03-21T00:18:56Z) is the optimal standard for storing and comparing dates programmatically because it's sortable, unambiguous, compatible with JavaScript's Date constructor, and works across systems without timezone complications. Rather than storing multiple timezone versions, all timestamps should be recorded in UTC on the server and converted to local time only when displaying to users, maintaining a single reference point for comparisons while preserving information needed for internationalization. The article provides practical implementation examples in PHP using `gmdate('Y-m-dTH:i:sZ')` and JavaScript methods for generating and formatting timestamps consistently across client-server applications.

Permalink

How to embed HTML5 into a native Mac OSX app - Lost Decade Games Blog

This tutorial explains how to embed an HTML5 web application into a Mac OS X desktop app using Xcode and WebKit, allowing developers to reuse the same HTML5 codebase across multiple platforms. The author walks through creating a new Cocoa application project, adding the WebKit framework, importing HTML files as resources, and configuring the application delegate to load and display the HTML content in a WebView. The approach enabled the creators of Onslaught! Arena to launch their Chrome Web Store game on the Mac App Store without modifying the source code.

Permalink