Archive25 posts

Image for "Understanding Jest Mocks"

Understanding Jest Mocks

Decipher Jest's complex rules for mocking modules.

Image for "Faster Google Classroom Assignments with a Bookmarklet"

Faster Google Classroom Assignments with a Bookmarklet

A free tool for teachers to automate the repetitive task of assigning work to a group.

Image for "Segment S3 uploads by Cognito user"

Segment S3 uploads by Cognito user

Use S3 policies to isolate Cognito users into subdirectories of a bucket.

Image for "Calculate AWS v4 Signature with client-side JavaScript"

Calculate AWS v4 Signature with client-side JavaScript

Use AWS Cognito credentials to authenticate requests directly in the browser.

Image for "Code Style: Accessing JavaScript Variables"
Code Style

Code Style: Accessing JavaScript Variables

JavaScript's syntax allows for a lot of shortcuts when accessing variables. But shorter code can also be confusing. Which techniques are the shortest? Which are the easiest to read?

Image for "A Parser for Conditional Expressions"

A Parser for Conditional Expressions

I've created a tool for analyzing conditional expressions.

Image for "Managing Puppet modules on Vagrant with Librarian-Puppet"

Managing Puppet modules on Vagrant with Librarian-Puppet

Load Puppet's third-party dependencies on-demand and keep them out of source control.

Image for "Updated - Vagrant on Windows path limit fix"

Updated - Vagrant on Windows path limit fix

Improved Vagrant and Puppet scripts for hosting Linux VMs on Windows.

Image for "The Statistics of War (the card game)"

The Statistics of War (the card game)

How does shuffling affect the duration of a game of War?

Image for "Using the MEAN stack on Windows with PuPHPet"

Using the MEAN stack on Windows with PuPHPet

Lately I've been playing with Vagrant and Puppet to create virtual machines for local MEAN stack development.

Image for "Get bound property name in a KnockoutJS custom binding"

Get bound property name in a KnockoutJS custom binding

Retrieve the name of a variable passed to a Knockout binding.

Image for "KnockoutJS custom binding for Quicksand"

KnockoutJS custom binding for Quicksand

Animate KnockoutJS observable changes with the Quicksand plugin for jQuery.

Image for "Microsoft Access is confused"
Microsoft Access

Microsoft Access is confused

Solving Microsoft Access's "ambiguous outer joins" error.

Image for "Relative paths in PHP INI"

Relative paths in PHP INI

Improve the portability of your code from server-to-server with environment variables in your PHP INI.

Image for "Microsoft Office Link Pre-fetching and Single Sign-On"
Single Sign-On

Microsoft Office Link Pre-fetching and Single Sign-On

I updated a site to use Single Sign-On (SSO) capability, specifically with Shibboleth, and was shocked to discover that links to the site in Microsoft Office files stopped working. After thorough troubleshooting I found a workaround.

Image for "Multiple forms on the same page in Zend Framework"
Zend Framework 1

Multiple forms on the same page in Zend Framework

Processing two forms on the same page is not the simplest task in the Zend Framework. After a few attempts, I think I found an elegant solution.

Image for "Autoloading Symfony using Doctrine with Zend Framework"

Autoloading Symfony using Doctrine with Zend Framework

Fix Symphony autoloading in the Doctrine CLI.

Image for "Don't host on a .255 IP address"

Don't host on a .255 IP address

Not all IP addresses are created equal.

Image for "Preserve encoded slashes in URL"

Preserve encoded slashes in URL

Configure your IIS URL rewrite tool to preserve encoded characters in the original URL.

Image for "MVC Form Layer"

MVC Form Layer

Forms are a tricky part of any Model-View-Controller (MVC) application. They incorporate validation, presentation, and security logic that spans all tiers of the application. Separating these concerns is difficult but important. I'll walk through how I use Zend_Form in Zend Framework 1, but the same principles should apply to any MVC application.

Image for "Using sprintf with multiple iterations"

Using sprintf with multiple iterations

PHP's built-in sprintf() function is great for formatting complicated output and improving code readability. I recently had the need to output a string multiple times with some changes each time.

Image for "Zend_Form_Decorator_Fieldset for individual elements"
Zend Framework 1

Zend_Form_Decorator_Fieldset for individual elements

Here's a custom decorator to render your Zend_Form_Element with a <fieldset>.

Image for "Zend_Validate_Callback Success on False"
Zend Framework 1

Zend_Validate_Callback Success on False

What if you need to validate input using a callback function that will return False when the input is valid? Here's a custom validator to do the job.

Image for "Zend_Validate_Callback with no context"
Zend Framework 1

Zend_Validate_Callback with no context

This class is super simple, so we'll begin with the code.

Image for "Hosting PHP on IIS7"

Hosting PHP on IIS7

Running PHP sites on Internet Information Services (IIS) is easy! And with a few extra steps, you can achieve a versatile and extensible setup to avoid management headaches down the line. Follow this guide to add PHP functionality to your IIS server and avoid common mistakes.