Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / CFSpreadsheetTextWrap.cfm
Created September 22, 2014 19:45
ColdFusion's "textwrap" cell format (introduced in CF9) only works in ColdFusion 11, not in CF9 or 10.
<cfscript>
columnWidthInPoints = 10;
sheet = SpreadSheetNew();
spreadsheetformatcell(sheet, {textwrap=true}, 1, 1);
spreadsheetSetCellValue(sheet, "This is test to see if this text wraps. The columnWidth is set to #columnWidthInPoints# points and Spreadsheetformatcell is set to textwrap=true. This is test to see if this text wraps. The columnWidth is set to #columnWidthInPoints# points and Spreadsheetformatcell is set to textwrap=true. This is test to see if this text wraps. The columnWidth is set to #columnWidthInPoints# points and Spreadsheetformatcell is set to textwrap=true. This is test to see if this text wraps. The columnWidth is set to #columnWidthInPoints# points and Spreadsheetformatcell is set to textwrap=true.", 1, 1);
spreadsheetSetCellValue(sheet, "#columnWidthInPoints# points", 1, 2);
SpreadSheetSetColumnWidth(sheet, 1, columnWidthInPoints);
@JamoCA
JamoCA / GoogleAutoTranslate.cfm
Created October 23, 2014 16:54
jQuery (& ColdFusion) sample code to automatically translate a website during page-load using Google's free Website Translator plugin at https://translate.google.com/manager/website/
<!---
Requires jQuery http://jquery.com/ & Cookies library https://code.google.com/p/cookies/
Feel free to use a different cookie library, ajax technique or server-side application language.
Get site-specific translation ID at https://translate.google.com/manager/website/
--->
<CFSET GoogleAnalyticsID = "">
<head>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
@JamoCA
JamoCA / PopSquares_CSS.js
Created November 20, 2014 20:07
jQuery-generated CSS to add to PopSquares jQuery Screensaver
/* jQuery-generated CSS to add to PopSquares jQuery Screensaver http://chapman.id.au/popsquares */
$("<style type='text\/css'>div#popSquares{text-align:center;vertical-align:middle;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#000;filter:alpha(opacity=100);-moz-opacity:1.0;-khtml-opacity:1.0;opacity:1.0;z-index:10000;}div.popSquaresBox{width:14.19%;height:19.69%;float:left;background-color:blue;border:1px black solid;opacity:.0;}<\/style>").appendTo("head");
@JamoCA
JamoCA / CSS_Text_Blur.htm
Created November 21, 2014 18:23
CSS Blur w/Hover+Click Reveal: Hover over answer column to display "less-blurred" text. Click to reveal (fully unblur).
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Blur w/Hover+Click Reveal</title>
<style type="text/css">
#myTable, #myTable th, #myTable td {border-collapse:collapse; border:1px solid #000; padding:3px;}
#myTable th {text-align:left !important; background-color:#e0e0e0;}
#myTable tbody td {vertical-alignment:top;}
/* CSS for blur/reveal */
#myTable tbody td:nth-of-type(3) {white-space:nowrap; width:100px; color:transparent;}
@JamoCA
JamoCA / UDF_formFieldAsArray.cfm
Created November 25, 2014 19:51
formFieldAsArray - ColdFusion UDF - modified to support "multipart" form submissions.
<!--- http://www.cflib.org/udf/formFieldAsArray
Returns a form field as array, useful for when you have more than one form field with the same name.
@param fieldName Name of the Form or URL field (Required)
@return Returns an array.
@author Ryan Stille (ryan@stillnet.org)
@version 1, August 5, 2011
@version 2, February 19, 2013
@version 3, 11/1/2013 - Modified by https://gist.github.com/JamoCA to support "multipart" form submissions --->
<cffunction name="UDFformFieldAsArray" returntype="array" output="false" hint="Returns a Form/URL variable as an array.">
<cfargument name="fieldName" required="true" type="string" hint="Name of the Form or URL field">
@JamoCA
JamoCA / PDFDemo_header.htm
Created January 18, 2015 23:22
Header HTML for PDFDemo (WKHTMLTOPDF versus Adobe ColdFusion CFDocument)
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body style="margin:0; padding:10px; background-color:#000; color:#fff;">
<div style="font:bold 25px Arial,Helvetica;">WKHTMLTOPDF vs Adobe ColdFusion CFDocument</div>
</body>
</html>
@JamoCA
JamoCA / PDFDemo_Footer.htm
Created January 18, 2015 23:22
Footer HTML for PDFDemo (WKHTMLTOPDF versus Adobe ColdFusion CFDocument)
@JamoCA
JamoCA / PDFDemo_Page.htm
Last active August 29, 2015 14:13
Multiple Page HTML for PDFDemo (WKHTMLTOPDF versus Adobe ColdFusion CFDocument)
<!DOCTYPE html>
<html lang="en">
<head>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Gloria+Hallelujah" rel="stylesheet" type="text/css">
<style type="text/css">
body {font-family:Arial,Helvetica;}
h1 {margin:0; padding:0;}
.pb_before { page-break-before:always !important; clear: both;}
.pb_after { page-break-after:always !important; }
@JamoCA
JamoCA / PDFDemo.bat
Created January 18, 2015 23:24
Command Line BAT file for PDFDemo (WKHTMLTOPDF versus Adobe ColdFusion CFDocument)
"c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --header-html http://10.0.0.20:8080/PDFDemo_Header.htm --header-spacing 0 --page-size letter -T 23mm -R 7mm -B 14mm -L 7mm --footer-html http://10.0.0.20:8080/PDFDemo_Footer.htm --footer-spacing 0 http://10.0.0.20:8080/PDFDemo_Page.htm C:\PDFDemo\PDFDemo.pdf
@JamoCA
JamoCA / IESpartan_PageSpeed.cfm
Last active August 29, 2015 14:14
Microsoft Internet Explorer 12 Spartan "Edge" Compatibility Code for Google PageSpeed/IISpeed
<!--- As of 1/28/2014, the Spartan "Edge" (IE11) user agent looks like:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0
Use the following ColdFusion code to disable "convert_jpeg_to_webp" so that you don't disenfranchise 50% of internet users
use an honest user-agent and a real WebKit-based browser.
--->
<CFIF Find("Chrome", CGI.Http_User_Agent) AND Find("Edge/", CGI.Http_User_Agent)>
<CFHEADER NAME="PageSpeedFilters" VALUE="-convert_jpeg_to_webp,-convert_to_webp_lossless">
</CFIF>