Skip to content

Instantly share code, notes, and snippets.

View bennadel's full-sized avatar
💭
Life's a garden, dig it!

Ben Nadel bennadel

💭
Life's a garden, dig it!
View GitHub Profile
@bennadel
bennadel / bounce.htm
Created February 24, 2023 13:03
Creating Custom Turbo Stream Actions In Hotwire And Lucee CFML
<cfmodule template="./tags/page.cfm">
<cfoutput>
<h2>
Bouncing Back to Home
</h2>
<p>
<!--- Required for restoration visits - see note below. --->
<a href="index.htm">Go back to home</a> &rarr;
@bennadel
bennadel / frame.cfm
Created February 23, 2023 12:05
Including Inline Turbo-Stream Actions In Hotwire And Lucee CFML
<turbo-frame id="async-frame">
<p>
This is the async FRAME content.
</p>
<!---
In order for these inline Turbo-Stream elements to be picked up and applied to the
live document, they have to be included inside of the Turbo-Frame element.
Otherwise, they will not be transcluded into the calling page and will, therefore,
@bennadel
bennadel / index.cfm
Created February 22, 2023 13:28
Persisting An IFrame-Based Video Player Across Page Visits With Hotwire And Lucee CFML
<cfmodule template="./tags/page.cfm" section="home">
<cfoutput>
<h2>
Welcome to This Site
</h2>
<ul>
<li>
<a href="video.htm?id=meghan-trainor" data-turbo-frame="player">
@bennadel
bennadel / index.htm
Created February 20, 2023 12:54
Rendering Elements After The HEAD Tag In JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="./demo.css" />
<style type="text/css">
/**
* Creating a STACKING CONTEXT around the body.
@bennadel
bennadel / add.cfm
Created February 19, 2023 16:57
Updating Permanent Elements On Page Navigation In Hotwire Turbo And Lucee CFML
<cfscript>
param name="form.note" type="string" default="";
param name="form.submitted" type="boolean" default=false;
if ( form.submitted ) {
if ( form.note.len() ) {
application.notes.prepend( form.note );
@bennadel
bennadel / snippet-1-output.txt
Last active February 17, 2023 13:23
Parsing File Paths As Slash-Delimited Lists In MySQL
mysql> SELECT
-> ( @path ) AS path,
-> SUBSTRING_INDEX( @path, '/', 1 ) AS segment_1,
-> SUBSTRING_INDEX( @path, '/', 2 ) AS segment_2,
-> SUBSTRING_INDEX( @path, '/', 3 ) AS segment_3,
-> SUBSTRING_INDEX( @path, '/', 4 ) AS segment_4,
-> SUBSTRING_INDEX( @path, '/', 5 ) AS segment_5
-> \G
*************************** 1. row ***************************
@bennadel
bennadel / index.cfm
Created February 13, 2023 13:44
Using Stimulus To Preload Links On Hover In Hotwire And Lucee CFML
<cfmodule template="./tags/page.cfm" section="home">
<cfoutput>
<h2>
Welcome to Our Site!
</h2>
<p>
Copy, copy, copy....
</p>
@bennadel
bennadel / frame.cfm
Created February 12, 2023 14:13
Defer Loading Using Permanent Turbo Frames In Hotwire And Lucee CFML
<cfscript>
// Adding latency so that we can see the place-holder text and tell more clearly that
// the frame content is being loaded asynchronously.
sleep( 1000 );
</cfscript>
<turbo-frame id="home-frame">
<cfoutput>
<p>
@bennadel
bennadel / index.cfm
Last active February 11, 2023 18:50
Extending The Current Request Timeout In ColdFusion / CFML
<cfscript>
requestSetTimeout( 5 );
blockForSeconds( 4 );
// CAUTION: !! DOES NOT WORK !!
requestSetTimeout( 5 );
blockForSeconds( 4 );
writeOutput( "Done" );
@bennadel
bennadel / frame.cfm
Created February 11, 2023 12:49
Exploring Turbo Drive Back-Button Caching Behavior In Lucee CFML
<turbo-frame id="home-frame">
<p>
This is lazy-loaded frame content. Copy, copy, copy ....
</p>
</turbo-frame>