Skip to content

Instantly share code, notes, and snippets.

View michaelborn's full-sized avatar
🏠
Working from home

Michael Born michaelborn

🏠
Working from home
View GitHub Profile
@michaelborn
michaelborn / timezone_conversion.cfm
Created August 4, 2023 14:39
Test timezone conversions
<cfscript>
// midnight in Malaga
theDate = '2023-09-11T00:00:00+02:00';
// Should show the previous day at 10PM in Lisbon
writeDump( dateTimeFormat( theDate, "YYYY-MM-dd'T'hh:nn:ss", "UTC") );
// Should show the previous day at 06PM in NY
writeDump( dateTimeFormat( theDate, "YYYY-MM-dd'T'hh:nn:ss", "America/New_York") );
</cfscript>
@michaelborn
michaelborn / HibernateStatistics.cfc
Created March 6, 2023 19:27
ColdBox interceptor to report Hibernate session statistics
component {
/**
* Undocumented property
*/
property name="HibernateSessionStats";
/**
* Undocumented property
@michaelborn
michaelborn / test.sh
Created January 23, 2023 12:48
Run Hibernate extension tests and Lucee ORM tests using Ant and script runner
#!/usr/bin/env bash
# Path to the checked out Lucee source
# Note that the tests run are pulled from this directory,
# so you'll have best luck (up to date tests) if you check out the tag that matches the LUCEE_VERSION variable.
LUCEE_PATH=/home/michael/server/lucee/lucee
# Path to the checked out lucee/script-runner project,
# which is what sets up and runs the CFML-based tests
LUCEE_SCRIPT_RUNNER_PATH=/home/michael/server/lucee/script-runner/
@michaelborn
michaelborn / cfml-uuid-validator.cfm
Created November 29, 2022 17:27
CFML UUID Validator test - confirm CF engines properly validate UUIDs.
<cfscript>
if ( server.keyExists( "lucee" ) ){
cfEngine = server.lucee.version;
} else {
cfEngine = server.coldfusion.productversion
}
writeOutput('<h1>#cfEngine#</h1>' );
// LOWERCASE
writeOutput("<h2>lowercase UUID</h2><code>isValid( 'uuid', 'b0e494c1-2ff8-44d5-a897-70af769e568c' )</code><br><br>");
writeDump( isValid( 'uuid', 'b0e494c1-2ff8-44d5-a897-70af769e568c' ) );
<cfscript>
if ( server.keyExists( "Lucee" ) ){
writeOutput( '<h3>Lucee #server.lucee.version#</h1>' );
} else {
writeOutput( '<h3>Adobe Coldfusion #server.coldfusion.productversion#</h1>' );
}
testQry = queryNew( "lineData" );
row = {
lineData : {
@michaelborn
michaelborn / lucee-queryaddrow-bug.cfm
Last active November 14, 2022 15:49
Lucee bug with structs in queryAddRow
<cfscript>
if ( server.keyExists( "Lucee" ) ){
writeOutput( '<h3>Lucee #server.lucee.version#</h1>' );
} else {
writeOutput( '<h3>Adobe Coldfusion #server.coldfusion.productversion#</h1>' );
}
testQry = queryNew( "lineData" );
row = {
lineData : {
@michaelborn
michaelborn / valuePrevalenceGrapher.cfc
Created September 16, 2022 13:36
Random number prevalence grapher - determine the prevalance or "randomness" of a value generator.
component {
/**
* Get a distribution struct of the prevelance of certain values
*
* @callback the random number generator or value generator.
*/
public struct function getValuePrevalence( required callback ){
var graph = {};
for( var i = 0; i < 10000; i++ ){
var number = callback();
@michaelborn
michaelborn / .vimrc
Last active August 28, 2022 23:29
My Favorite Vim settings
" Set indentation via spaces
" @cite https://linuxhandbook.com/vim-indentation-tab-spaces/
set autoindent expandtab tabstop=4 shiftwidth=4
" Show line numbers by default
set nu
" F3: Toggle list (display unprintable characters).
" https://stackoverflow.com/a/12534401
nnoremap <f3> :set list! list?<cr>
@michaelborn
michaelborn / isvalid-isSimpleValue-speed-test.cfm
Created August 15, 2022 13:15
Compare IsValid vs IsSimpleValue in a speed test on various CF Engines
<cfscript>
if ( structkeyExists( server, "lucee" ) ){
writeOutput( "<h2>Lucee #server.lucee.version#" );
} else {
writeOutput( "<h2>Adobe CF #server.coldfusion.productversion#" );
}
writeOutput( "<h4>isSimpleValue at 10,000 iterations</h4>" );
iterateTest( "string", "isSimpleValue" );
iterateTest( "function", "isSimpleValue" );
iterateTest( "struct", "isSimpleValue" );
@michaelborn
michaelborn / ORMTypesUtil.cfc
Created July 21, 2022 17:06
Util object for working with Hibernate ORM Types OR Lucee SQL Types
component{
/**
* Convert the given cfsqltype string name to a Hibernate Type object.
* i.e. `toHibernateSQLType( "cf_sql_varchar" )` or `toHibernateSQLType( "varchar" )`.
*
* @param cfsqltype Type name, like "cf_sql_integer" or "cf_sql_bit"
* @returns one of the classes from the org.hibernate.type package.
*/
public function toHibernateSQLType( required string cfsqltype ){