Skip to main content
Ben Nadel at the jQuery Conference 2010 (Boston, MA) with: Eileen Koven
Ben Nadel at the jQuery Conference 2010 (Boston, MA) with: Eileen Koven ( @psychotropek )

Recent Blog Posts by Ben Nadel

Working Code Podcast - Episode 169: Earning Potential Of Spaces

By Ben Nadel on
Tags: Podcast

Several years ago, Stack Overflow noticed a small but surprising trend within their 2017 Developer Survey data. Even when attempting to adjust for several factors, it seems that the programmers who indent their code with spaces (as opposed to with tabs) have a higher earning potential. As an example of programmers who love using tabs, the hosts of the show offer up theories about this strange finding... read more →

Adding One-Click Unsubscribe SMTP Headers To My Comment Emails In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Last year, Google announced that it would start enforcing easy unsubscribe functionality for people sending bulk emails. On my blog, I don't send bulk emails; however, each blog post represents a subscription opportunity for my readers. As such, I thought it would be a fun learning opportunity to add the required one-click unsubscribe SMTP headers to my outbound ColdFusion emails... read more →

I Broke The Comment Subscription System For The Last Year

By Ben Nadel on

Apparently, when I updated my blog to use Hotwire Turbo, I broke the comment subscription system. That is, I accidentally removed the logic wherein people were automatically subscribed to receive notifications about new comments on posts that they had participated in. I never noticed the break because I always receive notifications (even when I haven't commented on a post previously)... read more →

Using The Angular.js Parser To Comply With CSP In Alpine.js 3.13.5

By Ben Nadel on

The Alpine.js library allows for expressions that run arbitrary JavaScript code. This is because, under the hood, Alpine.js is programmatically creating Function definitions using said code as the function body. This is very clever; but, it doesn't work in an application that blocks unsafe-eval using a Content Security Policy (CSP). The Alpine project has a CSP-compatible build. However, the consumable syntax is so reduced as to be almost unusable. As an experiment, I wanted to see if I could restore most of the non-CSP syntax—while staying CSP compliant—by stealing the Angular.js parser... read more →

Recursive JSON Explorer In Alpine.js 3.13.5

By Ben Nadel on

When I'm learning a new front-end JavaScript framework, I like to try building a JSON data structure explorer. I've built one in Angular 9; and, just recently in Svelte 4. It's a fun project because it's small enough in scope to be doable; but, it's complex enough in its functionality to make it a true learning experience. I've recently unblocked some technical limitations in Alpine.js. And so, I wanted to try building a JSON explorer in Alpine.js 3.13.5... read more →

Using Alpine.js To AJAX'ify HTML Fragments Served From ColdFusion

By Ben Nadel on

Over on Chris Ferdinandi's blog, I've been reading about how he "AJAX'ifies" his form submissions by wrapping his <form> elements in a custom HTML web component: <ajax-form>. He's a huge fan of web components because they are "the web platform"; but, I don't see why I can't do the same thing using an Alpine.js directive. As such, I wanted to start exploring some AJAX'ification of my own by swapping out ColdFusion generated content within a given branch of the Document Object Model (DOM)... read more →

DateGetTime() To Get UTC Milliseconds From Date In ColdFusion

By Ben Nadel on
Tags: ColdFusion

As of recent updates to Adobe ColdFusion 2021 / 2023, MySQL queries are no longer reporting dates as timestamps. For native ColdFusion logic, this isn't much of a problem. However, in my ColdFusion applications, I'm often preparing data for consumption in JavaScript. And, in those cases, I serialize ColdFusion timestamps as UTC milliseconds using the .getTime() method on the underlying java.util.Date instance. But, now that the MySQL dates are coming back as strings, this .getTime() method isn't available. As such, I wanted to create a more ColdFusion-native way to access this Epoch notation... read more →

ColdFusion 2021 MySQL Query No Longer Returning Dates As Dates

By Ben Nadel on
Tags: ColdFusion

Yesterday, I went to my site and was greeted with a Bad Request - Request Too Long error. IIS was rejecting my request because my HTTP request headers exceeded 16Kb in size. When I looked at my cookies, I had dozens upon dozens of cookies that should not have been there. And, when inspecting the cookies, they all had expiration dates in 2092. After a few hours of digging, I discovered that my MySQL database queries were no longer returning date/time values as date/time values. Instead, the ColdFusion query object was presenting them as strings; which was breaking my CFCookie settings in a very subtle way... read more →

Working Code Podcast - Episode 168: Memory Safe Mandate

By Ben Nadel on
Tags: Podcast

On today's show, we talk about two major announcements relating to the technology world. First, the government released a report calling on programmers to start using memory safe languages (see: Future Software Should Be Memory Safe). Second, Apple announced that it will halt work on Titan, its autonomous electric vehicle project. We also talk about the pros-and-cons of a Computer Science degree in relation to the web development industry... read more →

Ask Ben: Fisher-Yates Shuffle Algorithm In ColdFusion

By Ben Nadel on

I have been using code you shared on the internet to generate random passwords for a club site for years. Now my ISP all of the sudden changed the ColdFusion security to deny java.util.Collections. Is there an easy work around I am missing?.. read more →

Exploring DOM Mutation Observation In Alpine.js 3.13.5

By Ben Nadel on

When your document first renders, Alpine.js traverses the DOM (Document Object Model) tree and activates any existing directive bindings. After this initial activation phase, Alpine.js uses the MutationObserver API to listen for subsequent changes to the DOM structure. And, when it observes changes, it will initialize new directive bindings and teardown old directive bindings as needed. Let's take a closer look at these mechanics in action... read more →

Various Ways To Get ColdFusion Data Into An Alpine.js Component

By Ben Nadel on

So far, all of my Alpine.js explorations have been client-side focused. But, my ultimate goal is to see if Alpine.js is a good companion framework for a ColdFusion-based multi-page application (MPA). As such, I wanted to spend some time thinking about various ways in which to get my ColdFusion data into an Alpine.js component... read more →

Recursive Template Rendering In Alpine.js 3.13.5

By Ben Nadel on

Yesterday, I created a "template outlet" directive in Alpine.js. This directive allows me to take a template reference and render it at any arbitrary point within the document and provide it with local data bindings. This opens the door for recursive template rendering since the template definition can include a template outlet which is a reference back to the current template definition. Let's take a quick look at this recursive template rendering in Alpine.js 3.13.5... read more →

Creating A Template-Outlet Directive In Alpine.js 3.13.5

By Ben Nadel on

In my previous post, I looked at cloning templates in Alpine.js. More specifically, I was looking at the mechanics of supplying intermediary data to the cloned element that exists in between the clone's local x-data binding and the ancestral scope chain. In that post, I was explicitly cloning a template in my controller logic. In this post, I want to explore a more declarative cloning technique using a template outlet in Alpine.js... read more →

Cloning Templates In Alpine.js 3.13.5

By Ben Nadel on

Over my last few blog posts, I've developed a better understanding of how scopes are applied in an Alpine.js application. Each x-data node receives an "expando" property (_x_dataStack) which contains an array of reactives scopes that represent the "scope chain" for the given component. This understanding filled-in the missing pieces that I needed in order to understand <template> cloning. Specifically, I now understand how and why an intermediary scope can be applied during the cloning process... read more →

Overcoming Asymmetric Prototype Property Access With Proxies In JavaScript

By Ben Nadel on

I don't use JavaScript proxies all that often in my day-to-day programming life. Proxies are very cool; but, they solve a set of problems that don't normally present in the business logic of applications. As such, proxies are mostly used by library and framework authors. In fact, much of the "magic" in modern JavaScript frameworks is based on the Proxy object. For example, in Alpine.js, the reactive "scope tree" is managed by proxies. And, as I was looking through the Alpine.js code this morning, I saw that they were using proxies to overcome the natural, asymmetric access of the prototype chain... read more →

Working Code Podcast - Episode 167: Do You Have A Brand?

By Ben Nadel on
Tags: Podcast

The first duty in life is to assume a pose. What the second is, no one has yet discovered. —Oscar Wilde.. read more →

Scoping Reactive Object References In The DOM In Alpine.js 3

By Ben Nadel on

From what I can gather, Alpine.js works by maintaining a stack of reactive objects in the background; and then, attaches those reactive objects to the DOM tree via "expando" properties. When you then reference a value within an Alpine.js expression, Alpine.js walks up the DOM tree, finds the closest expando property, locates the appropriate reactive object, and evaluates your expression. Essentially, Alpine.js is creating a sort of "prototype chain" for its data bindings... read more →

Creating A CSS Class Name Directive In Alpine.js 3

By Ben Nadel on

Alpine.js uses the x-bind:class syntax (or :class shorthand notation) to dynamically apply CSS class names to a given element. This binding can take either a single class name or an inline object that defines multiple class names. This directive provides good developer ergonomics; but, I miss the additional way in which Angular allows individual CSS classes to be bound with separate attributes. Today, I wanted to see if I can recapture some of that Angular magic in a custom Alpine.js directive... read more →

Submitting Forms With CMD+Enter In Alpine.js

By Ben Nadel on

Now that I've taken the Alpine JS Masterclass by Sofiullah Chowdhury on Udemy, I need to start considering ways in which I can use Alpine.js to progressively enhance (PE) my web experience. That is, how can I take an already functioning site and provide a more luxurious user experience (UX)? One PE technique that has become somewhat of a standard is using the key-combo CMD+Enter to submit forms while in a <textarea> element. Let's consider ways in which this can be done in Alpine.js 3.13.5... read more →

Hello World In Svelte JS 4

By Ben Nadel on

After completing the Udemy course, Svelte.js Complete Guide by Maximilian Schwarzmüller, I wanted to build a small Svelte JS application for myself. It needed to be something complex enough to try a number of the features; but, not so complex that it would become a deterrent. I decided to build a JSON Explorer (much like the one I built in Angular 9). This small application uses a custom input, custom events, and recursive component rendering in Svelte 4.2.10... read more →

Working Code Podcast - Episode 166: Successful Onboarding

By Ben Nadel on
Tags: Podcast

On today's show, we respond to a listener question from Kamil Maráz:.. read more →

Casting Java Structs And Arrays To ColdFusion Structs And Arrays

By Ben Nadel on
Tags: ColdFusion

Most of the time, in modern ColdFusion, data flows seamlessly in between the ColdFusion layer and the underlying Java layer. Behind the scenes, ColdFusion is working to cast or proxy objects, as needed, so that we can consume these objects as if they were native ColdFusion data types. But, this magic isn't always perfect. In some edge-cases, we have to explicitly cast Java objects into ColdFusion objects in order to consume the full object API (such as member methods)... read more →

Polyfill Form Field Grouping Using Bracket Notation In Adobe ColdFusion

By Ben Nadel on
Tags: ColdFusion

One of the small features that I absolutely love in Lucee CFML is the ability to group form fields as an array by suffixing the form field names with []. As in name="tags[]". When a group of related form fields have this same name, Lucee CFML will automatically aggregate the field values as an array and remove the [] suffix from the field name (in the form scope). Unfortunately, Adobe ColdFusion doesn't offer this behavior. But, we can polyfill it at the top of each request... read more →

Working Code Podcast - Episode 165: Agile Methodology With Brian Sadler

By Ben Nadel on
Tags: Podcast

For the most part, software engineers like the concept of Agile methodology; and, they have a sense that agile development practices are the best way of getting work done. But, that doesn't mean we know how to put these agile practices in place (especially at scale). Today, we talk to Brian Sadler (@brian_sadler)—a seasoned software developer and Agile coach—about what Agile is, what parts of it work the best, and where teams often go wrong in their interpretation of best practices... read more →

Conditionally Updating Columns When Using ON DUPLICATE KEY UPDATE In MySQL

By Ben Nadel on
Tags: SQL

A couple of weeks ago, I talked about the lessons I learned while sending 7M emails using ColdFusion. In that post, I mentioned that I needed to store a cache of email validation codes in order to avoid sending an email to any address that was known to be invalid. But, an invalid email address isn't the only reason to skip a given send. If a user explicitly unsubscribes from a broadcast stream, I need to omit the given user in the next send (or my SMTP provider—Postmark—will mark the email as bounced)... read more →

Comparing Binary Values In ColdFusion

By Ben Nadel on
Tags: ColdFusion

I have a MySQL database table in which I'm storing a binary token (ie, a byte array). This binary token is easily passed from ColdFusion to the database. And, the database will happily compare binary values within an executed SQL statement. But, when that binary token is in a ColdFusion context, there's no native way to compare that binary token to another binary value. As such, I wanted to look at two possible ways to compare binary values in ColdFusion... read more →

Working Code Podcast - Episode 164: Potluck

By Ben Nadel on
Tags: Podcast

On this week's show, we explore a variety of topics. I want to perform a mini retrospective on my desire to support the legacy platform at work. Carol is feeling isolated as the only engineer on her team—her dog is a good listener, but isn't very helpful when it comes to brainstorming. And, Adam wants to talk about the browser landscape; and see which browser(s) everyone is currently using... read more →

Performance Of Struct vs. Ordered Struct In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Yesterday, in the Working Code podcast Discord, Sean Corfield and I were discussing the trade-offs of various data structures. The conversation started from a code-comment that I had made about using an ordered struct. To which, Sean mentioned that ordered structs were slower than regular structs due to the fact that they have to maintain insertion order in addition to the key-value pairs. This has never occurred to me before; especially since the size of my standard data structure makes any difference inconsequential. But, I thought it would be an interesting things to test more explicitly in ColdFusion... read more →

Powering Email Unsubscribe Links Using Signed URLs In ColdFusion

By Ben Nadel on
Tags: ColdFusion

Earlier this week, I talked about using signatures to prevent URL tampering in ColdFusion. Then, yesterday, I was having a conversation about spam emails and unsubscribe links. It occurred to me that using signed URLs is one way in which unsubscribe links can be implemented in ColdFusion. As such, I wanted to run through a small demo... read more →


I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel