Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Nadel bennadel

View GitHub Profile
@bennadel
bennadel / test.cfm
Created Nov 27, 2020
Using String Literals In Date / Time Formatting In Lucee CFML 5.3.7.47
View test.cfm
<cfscript>
echoLine(
"DateFormat",
now().dateFormat( "yyyy-mm-dd 'and a string literal'" )
);
echoLine(
"TimeFormat",
now().timeFormat( "HH:nn:ss TT 'and a string literal'" )
);
@bennadel
bennadel / bookmarklet.js
Created Nov 22, 2020
Proof-Of-Concept: Injecting Features Into An InVision Share Link Experience Using AngularJS 1.6.7
View bookmarklet.js
javascript:(function(w,$,k){(w[k]||(w[k]=$.getScript("https://bennadel.github.io/poc-invision-share-lazy-load/feature.js?_="+Date.now())));})(window,jQuery,"LazyLoadPOC");void(0);
@bennadel
bennadel / bearer.cfm
Created Nov 20, 2020
Lists - The Unsung Heroes Of ColdFusion And Lucee CFML
View bearer.cfm
<cfscript>
include "./utils.cfm";
authorization = "Basic YW5uYTppY2FuaGF6Y2hlZXNlYnVyZ2Vy";
// The Authorization header is really just a space-delimited list.
echoLine( authorization.listFirst( " " ) );
echoLine( authorization.listRest( " " ) );
echoLine();
@bennadel
bennadel / date-helper.js
Created Nov 18, 2020
Replacing All External Date Libraries With 300 Lines-Of-Code In AngularJS 1.2.22
View date-helper.js
(function( ng, app ) {
"use strict";
app.factory( "dateHelper", DateHelperFactory );
var MS_SECOND = 1000;
var MS_MINUTE = ( MS_SECOND * 60 );
var MS_HOUR = ( MS_MINUTE * 60 );
var MS_DAY = ( MS_HOUR * 24 );
var MS_MONTH = ( MS_DAY * 30 ); // Rough estimate.
@bennadel
bennadel / app.component.html
Created Nov 17, 2020
Replacing All External Date Libraries With 300 Lines-Of-Code In Angular 11.0.0
View app.component.html
<div class="result">
<span class="result__absolute">
{{ formattedDate }}
</span>
<span class="result__relative">
{{ relativeDate }}
</span>
</div>
<div class="slider">
@bennadel
bennadel / app.component.html
Created Nov 15, 2020
Adjusting Dates By Adding Date / Time Parts In Angular 11.0.0
View app.component.html
<div class="result">
<span class="result__content">
{{ formattedDate }}
</span>
</div>
<div class="slider">
<div class="slider__label">
Year
</div>
@bennadel
bennadel / differ.cfm
Created Nov 13, 2020
Adding Differ() And DifferNoCase() Built-In Function Extensions In Lucee CFML 5.3.7.47
View differ.cfm
<cfscript>
/**
* I determine if the two values are different use a CASE SENSITIVE operation.
*
* @valueA I am the first value to compare.
* @valueB I am the second value to compare.
*/
public boolean function differ(
required string valueA,
@bennadel
bennadel / app.component.html
Created Nov 12, 2020
Building A Moment-Inspired .fromNow() Date Formatting Method In Angular 10.2.3
View app.component.html
<div *ngFor="let demo of demos" class="demo">
<div class="demo__slider slider">
<div class="slider__label">
{{ demo.minLabel }}
</div>
<div class="slider__range">
<input
#rangeRef
type="range"
@bennadel
bennadel / app.component.ts
Created Nov 10, 2020
Painless Date / Time Formatting With formatDate() In Angular 10.2.3
View app.component.ts
// Import the core angular services.
import { Component } from "@angular/core";
import { formatDate } from "@angular/common";
import { Inject } from "@angular/core";
import { LOCALE_ID } from "@angular/core";
// ----------------------------------------------------------------------------------- //
// ----------------------------------------------------------------------------------- //
interface Example {
@bennadel
bennadel / RedisGateway.cfc
Created Nov 7, 2020
Using Redis Blocking List Operations To Power Long-Polling In Lucee CFML 5.3.7.47
View RedisGateway.cfc
component
output = false
hint = "I provide a super simple wrapper around getting and returning Redis resources."
{
/**
* I initialize the Redis resource wrapper using Jedis 3.3.0.
*/
public void function init() {
You can’t perform that action at this time.