Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
@atuttle
atuttle / gist:4127365
Last active April 25, 2024 02:43 — forked from learncfinaweek/gist:4121263
Application.cfc

By now you've learned the basics of ColdFusion, script vs. tag syntax, scopes, how to deal with data, and even some code-reuse techniques. You're now able to write something useful, so it's time we introduce you to the Request Lifecycle.

You see, when someone requests a ColdFusion page, CF doesn't just start executing your code. There are several events that first take place, which you can be waiting for, and to which you can react. This is not strictly necessary, but you'll find that any complex application will eventually want to make use of some or all of these features, so it's best that you know about them. In order to react to these events, you need to have an Application.cfc file. ColdFusion has designated Application.cfc as a special component that it will automatically look for, and in which we can put our event listeners for request lifecycle events.

A Note on Terminolog
<cfscript>
_ = new underscore();
fail = _.range(10);
writeDump(var=fail, label="_.range(10)");
customRange = [];
@atuttle
atuttle / gist:4340972
Created December 19, 2012 22:04
Fuck Twitter's stupid date formatting in its goddamn ear. Worst idea ever.
<cffunction name="unfuckTwitterDateTime">
<cfargument name="fucked" />
<cfargument name="GMTOffset" default="0" />
<cfset fucked = trim(fucked) />
<cfset var d = right(fucked, 4) & '-' & monthAbrToNum(mid(fucked, 5, 3)) & '-' & mid(fucked, 9, 2) />
<cfset var t = mid(fucked, 12, 8) />
<cfreturn dateAdd("h", GMTOffset, ParseDateTime(d & ' ' & t)) />
</cffunction>
<cffunction name="monthAbrToNum">
@atuttle
atuttle / Amazon S3 Upload.cfm
Created January 28, 2013 19:11
Upload files to Amazon S3 with ColdFusion. This is heavily based on code from Joe Danziger's s3.cfc: http://amazons3.riaforge.org/
<cffunction name="uploadToAmazonS3">
<cfargument name="fileName" required="true" />
<cfargument name="contentType" required="true" />
<cfargument name="data" required="true" />
<cfargument name="acl" default="public-read" />
<cfargument name="storageClass" default="STANDARD" />
<cfargument name="HTTPtimeout" default="300" />
<cfargument name="bucket" default="#getProperty('EmailAttachmentS3Bucket')#" />
<cfargument name="accessKeyId" default="#getProperty('EmailAttachmentS3AccessKeyId')#" />
<cfargument name="secretKey" default="#getProperty('EmailAttachmentS3SecretKey')#" />
@atuttle
atuttle / sublime-keymap.json
Last active December 14, 2015 15:59
My personal sublime keymap
[
{ "keys": ["alt+up"], "command": "swap_line_up" }
,{ "keys": ["alt+down"], "command": "swap_line_down" }
,{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" }
,{ "keys": ["alt+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} }
,{
"keys": ["ctrl+alt+left"]
,"command": "set_layout"
,"args": {
[11:33 AM] • jrichards|away is now known as jrichards.
[12:01 PM] • mikewallace is now known as mikewallace|away.
[12:20 PM] • dongshengcn is now known as ds|away.
[12:51 PM] • ds|away is now known as dongshengcn.
[1:01 PM] • robfraz is now known as robfraz_away.
[1:17 PM] • dongshengcn is now known as ds|away.
[1:19 PM] • kocolosk is now known as kocolosk|away.
[1:24 PM] • ds|away is now known as dongshengcn.
[1:38 PM] • dongshengcn is now known as ds|away.
[1:42 PM] • splsrvc is now known as splsrvc|food.
@atuttle
atuttle / .gitconfig
Last active December 16, 2015 02:59
my .gitconfig
[user]
name = Adam Tuttle
email = adam@fusiongrokker.com
[color]
ui = auto
[core]
autocrlf = input
excludesfile = /Users/adam/.gitignore_global
[push]
default = tracking
@atuttle
atuttle / gist:5775766
Last active December 18, 2015 11:29
"28.4% of the top-100 grossing films of 2012 included speaking roles for women" #skeptic

According to this article, only 28.4% of the top-100 grossing films of 2012 included speaking roles for women. (Hat tip to @lindseybieda for the heads up!)

According to Wolfram Alpha (I'm happy to use a better or more complete source if one is available... Also I don't have a ton of time to put into this research at the moment...), the top 10 are:

  1. The Avengers (Scarlett Johansson, Gwyneth Paltrow)
  2. The Dark Knight Rises (Anne Hathaway, Marion Cotillard)
  3. The Hunger Games (Jennifer Lawrence, Elizabeth Banks)
  4. Skyfall (Dame Judy Dench
component {
this.contains = function(){
writeOutput("Hi from ScriptBased.contains()<br>");
};
}
<cfscript>
original = fileRead(expandPath("./src.html"), "UTF-8");
encoded = encodeForHTML(original);
function htmlDecode(HTML){
return replaceList(arguments.HTML, "&lt;,&gt;,&amp;,&quot;", '<,>,&,"');
}
decoded = htmlDecode(encoded);