Skip to content

Instantly share code, notes, and snippets.

View mjhagen's full-sized avatar

Mingo Hagen mjhagen

View GitHub Profile
@mjhagen
mjhagen / csv.cfc
Created April 26, 2021 14:47
CSV Parser using Univocity in CFML / ColdFusion
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 );
### 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:
@mjhagen
mjhagen / Preferences.sublime-settings
Last active May 12, 2017 09:32
Sublime Settings
{
"always_show_minimap_viewport": true,
"animation_enabled": false,
"binary_file_patterns": [
"*.dds",
"*.eot",
"*.gif",
"*.ico",
"*.jar",
"*.jpeg",
@mjhagen
mjhagen / gsonService.cfc
Created April 24, 2017 11:21
gson wrapper for CFML
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 = [ ];
<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 July 15, 2016 10:59
Debian/Tomcat/Lucee/FW1 Config File
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;
<cfscript>
isTheThingTrue = 0;
isTheThingTrue && executeSomeLogic();
function executeSomeLogic()
{
writeDump( 'a' );
}
@mjhagen
mjhagen / java-image-scaling.cfc
Created July 30, 2015 09:57
CFML Better Image Resize
<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 August 29, 2015 14:25
Bug in ORM inheritance mapping
component
{
this.name = "ormPlayground";
this.datasource = "mingo";
this.ormEnabled = true;
this.ormSettings.dbcreate = "dropcreate";
function onRequestStart()
{
ormreload();
@mjhagen
mjhagen / Preferences.sublime-settings
Last active August 29, 2015 14:25
My Sublime settings 7/2015
{
"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,