John Cox

Blogs · @wyome

Tagged tutorial · everything

What No One Told You About Z-Index — Philip Walton

Most developers misunderstand z-index because they don't realize that z-index values only matter within a **stacking context**, which is a group of elements that move together in the stacking order. Stacking contexts are created when an element is the root element, has position and z-index set, or has an opacity less than 1—and this third method is rarely known outside specification documents. The article demonstrates this through a puzzle where adding opacity to a parent element causes its child's high z-index to become irrelevant, since the child is now confined to a lower stacking context created by that opacity rule.

Permalink

Make Pretty Charts For Your App with jQuery and xCharts | Tutorialzine

This tutorial demonstrates how to build an interactive AJAX-powered chart for displaying MySQL data using the xCharts library, a date range picker, and jQuery. The implementation involves setting up a simple HTML interface with a date selector, creating a PHP backend that queries a MySQL database and returns JSON-formatted sales data, and using JavaScript to render the data in a styled line chart with tooltips. The guide emphasizes using helper libraries like sugar.js for date manipulation and Idiorm for database queries to simplify the development process.

Permalink

Useful .htaccess Snippets

This article provides practical .htaccess code snippets for common web administration tasks, ranging from access control and security (password protection, blocking bots and referrers, hotlink prevention) to performance optimization (file compression, caching) and functionality adjustments (redirects to HTTPS, custom index pages, upload limits). Each snippet includes explanation of what it does and how to customize it for specific needs, making it a quick reference guide for implementing .htaccess rules without needing to understand the underlying Apache syntax deeply.

Permalink

Writing Fast, Memory-Efficient JavaScript | Smashing Coding

This article explains how JavaScript engines like V8 optimize code execution and provides practical strategies for writing memory-efficient applications. It covers garbage collection mechanics, closure pitfalls, performance traps with timers, V8-specific optimization tips for objects and arrays, and tools for profiling and detecting memory leaks in real applications. The author emphasizes measuring actual performance bottlenecks before optimizing, avoiding premature micro-optimizations, and understanding that DOM manipulation often poses greater performance risks than JavaScript execution itself.

Permalink

9 Command Line Tricks for Mac OS X You Should Know

This article offers practical command-line tricks for Mac users of varying skill levels, covering utilities like `caffeinate` to prevent sleep, `pkgutil` to extract package contents without installing, and `purge` to free up memory. It also explains how to launch multiple app instances, update OS X from the terminal, search your download history through Quarantine Services, hide files from Finder, and create password-protected zip files, along with the handy tip that dragging files into Terminal automatically inserts their full paths.

Permalink

It’s time to start using JavaScript strict mode | NCZOnline

Strict mode is an opt-in JavaScript feature that makes the language safer by throwing errors instead of silently failing when problematic code patterns occur. Key improvements include preventing accidental global variables, eliminating the `with` statement, preventing `this` coercion to the global object, disallowing duplicate function parameters or object properties, confining `eval()` scope, and throwing errors when attempting to modify immutable properties. To use it safely, apply the `"use strict"` pragma inside individual functions or IIFEs rather than globally, since global strict mode can affect concatenated scripts unexpectedly.

Permalink

Git: Twelve Curated Tips And Workflows From The Trenches - be present now

This collection of practical Git workflows addresses repetitive problems developers face, from display issues like line wrapping in diffs to complex operations like cherry-picking between repositories and rewriting commit history. The twelve tips range from simple configuration tweaks (wrapping long lines, setting proxies) to advanced techniques (selectively stashing files, modifying specific commits via interactive rebase, and promoting a branch to master while preserving merge history). The post emphasizes that many of these solutions come from repeated lookups and eventual alias creation, making it a curated distillation of real-world Git usage patterns.

Permalink

HTML5 Datalist

The HTML5 DATALIST element provides native browser autocomplete functionality by pairing a list of OPTION values with an INPUT field via a list attribute, eliminating the need for JavaScript-based autocomplete widgets that had dominated the previous decade. While the DATALIST approach is basic—offering no styling options for suggestions and no support for dynamic data from service endpoints—it represents a useful step forward in moving common web functionality from script libraries into standardized HTML.

Permalink

14 Handy jQuery Code Snippets for Developers - Treehouse Blog

This article provides 14 practical jQuery code snippets covering common frontend tasks like hover effects, preventing default link behavior, animating elements, toggling visibility, handling form data with Ajax, manipulating CSS classes and attributes, and traversing the DOM. The snippets are presented as blank templates that developers can customize for their own projects, ranging from beginner-friendly functions like scrolling to top to more advanced techniques like loading external content and keystroke event handling.

Permalink

CSS Grid Layout

CSS Grid Layout is a proposed W3C specification that provides a two-dimensional layout system for web applications, allowing developers to divide space into rows and columns and position elements by referencing grid lines or named areas. Unlike tables or floats, Grid has no inherent content structure, enabling responsive designs that adapt to different screen sizes through media queries without altering the semantic HTML. The specification details comprehensive sizing algorithms, automatic item placement, and alignment properties to support everything from basic application layouts to complex overlapping components like custom controls.

Permalink

5 More HTML5 APIs You Didn’t Know Existed

This article showcases five lesser-known HTML5 APIs with practical code examples: the Fullscreen API for launching fullscreen mode on any element, the Page Visibility API for detecting when users switch browser tabs to optimize resource usage, the getUserMedia API for accessing device cameras and microphones, the Battery API for mobile devices to monitor charging status and power levels, and link prefetching to preload resources for faster page transitions. The author emphasizes that familiarity with these APIs will become increasingly important as they become standard practice in web development over the coming years.

Permalink

Numeral.js

Numeral.js is a JavaScript library for formatting and manipulating numbers in various ways—as currency, percentages, bytes, or with custom delimiters and abbreviations. It allows you to create numeral objects from numbers or strings, format them according to preset or custom patterns, and perform basic mathematical operations like add, subtract, and difference. The library supports multiple locales and custom format definitions, making it useful for displaying numbers appropriately across different regions and use cases.

Permalink