Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / isImageCMYK UDF
Created July 9, 2013 00:09
This is a ColdFusion 10-only UDF that will identify whether a JPEG image is a CMYK or not.
<!--- isImageCMYK() v1 (7/6/2013)
UDF for ColdFusion 10 by James Moberg
Identifies whether a JPEG image uses a CMYK (CUSTOM) palette
--->
<CFSET ImageFile = expandPath("cmyk.jpg")>
<CFSET ImageObject = ImageRead(ImageFile)>
<CFOUTPUT>
File = #isImageCMYK(Imagefile)#<br>
@JamoCA
JamoCA / CSVtoQuery.cfm
Last active April 13, 2018 14:52
Convert CSV File to Coldfusion Query Object using ColdFusion & opencsv (Java)
<!---
Convert CSV file to a ColdFusion query object using opencsv.
Requirements:
- ColdFusion 8+ ( http://en.wikipedia.org/wiki/Adobe_ColdFusion )
- opencsv - free parser library for Java ( http://opencsv.sourceforge.net/ )
http://opencsv.sourceforge.net/
opencsv supports all the basic csv-type things you're likely to want to do:
- Arbitrary numbers of values per line
- Ignoring commas in quoted elements
- Handling quoted entries with embedded carriage returns (ie entries that span multiple lines)
@JamoCA
JamoCA / Excel.cfm
Last active December 7, 2016 16:48
ColdFusion Custom Tag - Converts database query object to XLS/XLSX Excel file w/optional formatting
<CFSETTING ENABLECFOUTPUTONLY="YES">
<!---
Excel.cfm
ColdFusion Custom Tag - Converts database query object to
XLS/XLSX Excel file w/optional formatting
(Based on a defunct CFX_Excel tag that we used with ColdFusion 5)
Author: James Moberg james at ssmedia dot com
Requirements: ColdFusionF 9+
<CF_Excel query="#GetResults#" filename="Products_#DateFormat(Now(),'yyyymmdd')#.xls">
@JamoCA
JamoCA / StripFormatting.ahk
Last active December 20, 2015 06:58
AutoHotKey script to remove hidden Microsoft mark-up from the clipboard when pasting from Word to online WYSIWYG editors, cleaning up Outlook replies, removing trailing non-breaking spaces or using the "Paste as Value" function in Excel. (Windows+V)
REMOVECHAR:
AutoTrim,Off
StringCaseSense,On
StringReplace,string,string,chr(160),A_Space,All ;Non-breaking space
StringReplace,string,string,–,-,All ;emdash
StringReplace,string,string,´,',All
StringReplace,string,string,’,',All
StringReplace,string,string,©,(C),All
StringReplace,string,string,“,",All ;left quote
StringReplace,string,string,”,",All ;right quote
@JamoCA
JamoCA / ColumnToSQLList.ahk
Created July 26, 2013 15:30
AutoHotKey script to convert clipboard columnar data (from Excel or text file) to SQL-compatible comma-delimited list (adds single quotes if data consists of non-numeric values) (Windows+C)
#c:: ;Window+C Convert Columnar Data to SQL-Compatible List
StringReplace,clipboard,clipboard,`n,`,,All
StringReplace,clipboard,clipboard,`r,,All
StringGetPos, pos, clipboard, ID`, ; remove "ID" if first item in the list (Access).
if pos = 0
StringRight, clipboard, clipboard, StrLen(clipboard)-3
testString = %clipboard%
StringReplace,testString,testString,`,,,All
testString := testString * 1
if (testString is integer) {
@JamoCA
JamoCA / CleanCSS.ahk
Created July 26, 2013 15:31
AutoHotKey script to minimizes spacing in CSS and convert common color codes to shorter values. (CTRL+ALT+S)
^!s:: ; CTRL+ALT+S Clean CSS (reduce whitespace + shorten hex color values)
WinGetActiveTitle, Title
IfInString, Title, HomeSite
{
StringReplace,clipboard,clipboard,;`r`n,;%A_Space%,,All
StringReplace,clipboard,clipboard,%A_Space%},},,All
StringReplace,clipboard,clipboard,{`r`n,{,,All
StringReplace,clipboard,clipboard,`r`n{,%A_Space%{,,All
StringReplace,clipboard,clipboard,{%A_Space%,{,,All
StringReplace,clipboard,clipboard,:%A_Space%,:,,All
@JamoCA
JamoCA / DedupeUniqueColumn.ahk
Created July 26, 2013 15:39
AutoHotKey script to sort and removed duplicate values from a column of data (ie, column of values from a spreadsheet). (CTRL+SHIFT+U)
SANITIZE: ;sanitize characters (optional, see below)
AutoTrim,Off
StringCaseSense,On
StringReplace,string,string,chr(160),A_Space,All ;Non-breaking space
StringReplace,string,string,–,-,All ;emdash
StringReplace,string,string,´,',All
StringReplace,string,string,’,',All
StringReplace,string,string,©,(C),All
StringReplace,string,string,“,",All ;left quote
StringReplace,string,string,”,",All ;right quote
@JamoCA
JamoCA / ExcelFindNext.ahk
Created July 26, 2013 15:41
AutoHotKey script to remap Excel's SHIFT+F4 "Find Next" to simply F3 (same as defunct Adobe HomeSite+, the IDE I'm still using.)
#IfWinActive ahk_class XLMAIN
F3::+F4
#IfWinActive
@JamoCA
JamoCA / CFSANTest.cfm
Last active December 20, 2015 09:09
ColdFusion SAN Certificate test. (NOTE: You can test this at CFLive.net)
<p>This sample CFML code is regarding the Adobe ColdFusion bug reported here:<br>
<a href="https://bugbase.adobe.com/index.cfm?event=bug&id=3566218">https://bugbase.adobe.com/index.cfm?event=bug&id=3566218</a><br>
and can be tested by pasting the code below at <a href="http://cflive.net/">http://cflive.net/</a></p>
<p>As of 7/29/2013, Railo is capable of performing a CFHTTP request to a SSL SAN certficate whereas ColdFusion 9.0.2.282541 fails:</p>
<blockquote>
<p><b>Connection Failure</b><br>
I/O Exception: Name in certificate `globalgatewaye4.firstdata.com' does not match host name `api.globalgatewaye4.firstdata.com'</p>
</blockquote>
@JamoCA
JamoCA / isTestCC.cfm
Last active December 20, 2015 15:59
ColdFusion UDF to test if a credit card number matches test card numbers provided by credit card merchants (as opposed to only validating against the Luhn algorithm.) (NOTE: You can test this at CFLive.net)
<cfscript>
function isTestCC(cc){
var testCCs = "135412345678911, 2211000000000001, 2211000000000019, 2211000000000027,
2211000000000035, 2211000000000043, 2211000000000050, 304985028090561515, 30569309025904,
3111111111111117, 340000000000009, 340682458348749, 342135898797783, 342337649030528,
342650299263839, 342781835011463, 342955624318368, 344058488426266, 345672983453416,
345796298727014, 347279493269015, 348771682068975, 3530111333300000, 3566002020140006,
3566002020360505, 3566111111111113, 3569990000000009, 36438999960016, 370000000000002,
370123456789017, 371449635398431, 375529360131002, 378282246310005, 378734493671000,
38520000023237, 4000000000000002, 4000000000000010, 4000000000000028, 4000000000000036,