Skip to content

Instantly share code, notes, and snippets.

Avatar

Mingo Hagen mjhagen

View GitHub Profile
@mjhagen
mjhagen / csv.cfc
Created Apr 26, 2021
CSV Parser using Univocity in CFML / ColdFusion
View csv.cfc
component accessors=true {
public any function getCSVParser(
boolean delimiterDetectionEnabled = true,
boolean headerExtractionEnabled = true,
boolean lineSeparatorDetectionEnabled = true,
boolean quoteDetectionEnabled = true
) {
var csvParserSettings = createObject( 'java', 'com.univocity.parsers.csv.CsvParserSettings' );
csvParserSettings.setDelimiterDetectionEnabled( delimiterDetectionEnabled );
csvParserSettings.setHeaderExtractionEnabled( headerExtractionEnabled );
View gist:3c33c80fb0dbb4d9df7af3f1d0ab0a8a
### Keybase proof
I hereby claim:
* I am mjhagen on github.
* I am mjhagen (https://keybase.io/mjhagen) on keybase.
* I have a public key ASBrNIY96NYMcGf0PmTJvT1J-Y6jZqTFE08R7Kjz3T1IdQo
To claim this, I am signing this object:
View Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"animation_enabled": false,
"binary_file_patterns": [
"*.dds",
"*.eot",
"*.gif",
"*.ico",
"*.jar",
"*.jpeg",
@mjhagen
mjhagen / gsonService.cfc
Created Apr 24, 2017
gson wrapper for CFML
View gsonService.cfc
component accessors=true {
public component function init( root ) {
var jl = new javaloader.javaloader( [ root & "/lib/java/gson-2.7.jar" ] );
variables.gson = jl.create( "com.google.gson.GsonBuilder" )
.serializeNulls( )
.create( );
variables.structClass = createObject( "java", "java.util.LinkedHashMap" ).init( ).getClass( );
var array = [ ];
View adamcameron-2016-08-code-quiz.cfm
<cfscript>
arrayOfStrings = [ 'a', 'at', 'cat', 'scat', 'catch' ];
regex = '.+at';
writeOutput( arrayOfStrings.reduce( function( result='', item ){ return len( result ) ? result : item.reFind( regex ) ? item : ''; } ) );
</cfscript>
@mjhagen
mjhagen / nginx-fw1site.conf
Last active Jul 15, 2016
Debian/Tomcat/Lucee/FW1 Config File
View nginx-fw1site.conf
server {
listen 80;
server_name example.com;
root /path-to-tomcat-ROOT/path-to-webroot/;
access_log /var/log/nginx/example.com-access.log;
error_log /var/log/nginx/example.com-error.log;
index index.html index.cfm;
location / {
try_files $uri $uri/ /path-to-webroot/index.cfm$request_uri;
View thisAndThat.cfm
<cfscript>
isTheThingTrue = 0;
isTheThingTrue && executeSomeLogic();
function executeSomeLogic()
{
writeDump( 'a' );
}
@mjhagen
mjhagen / java-image-scaling.cfc
Created Jul 30, 2015
CFML Better Image Resize
View java-image-scaling.cfc
<cfcomponent>
<cfset this.jl = new javaloader.JavaLoader( ['#request.site.s_ANCHOR_PATH#/lib/java/java-image-scaling-0.8.5.jar'] ) />
<cffunction name="resizeImage" access="remote" returnType="string" returnFormat="plain">
<cfargument name="image" required="true" />
<cfargument name="width" required="true" />
<cfargument name="height" required="true" />
<cfset var originalImageLocation = this.forcedBasePath & arguments.image />
<cfset var originalImageDir = getDirectoryFromPath( originalImageLocation ) />
@mjhagen
mjhagen / Application.cfc
Last active Aug 29, 2015
Bug in ORM inheritance mapping
View Application.cfc
component
{
this.name = "ormPlayground";
this.datasource = "mingo";
this.ormEnabled = true;
this.ormSettings.dbcreate = "dropcreate";
function onRequestStart()
{
ormreload();
@mjhagen
mjhagen / Preferences.sublime-settings
Last active Aug 29, 2015
My Sublime settings 7/2015
View Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"animation_enabled": false,
"bold_folder_labels": true,
"caret_extra_bottom": 2,
"caret_extra_top": 2,
"caret_extra_width": 1,
"caret_style": "phase",
"color_scheme": "Packages/Material Color Scheme/sublime/material-dark.tmTheme",
"detect_indentation": false,