Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
@atuttle
atuttle / lawnchair-paginated-query.js
Created April 27, 2012 18:50
All I've done here is taken the pagination plugin and mashed it into the query plugin, so that we can have the awesomeness of .where(...).page(...)
// - NOT jsonPath or jsonQuery which are horrendously complex and fugly
// - simple query syntax 'its just javascript'
// - simple string interpolation
// - search then sorting
Lawnchair.plugin((function(){
//
var interpolate = function(template, args) {
var parts = template.split('?').filter(function(i) { return i != ''})
, query = ''
@atuttle
atuttle / gist:2790024
Created May 25, 2012 19:24
O(n) implementation of arrayMerge -- returns an array of the two input arrays combined and de-duped
<cffunction name="arrayMerge">
<cfargument name="a" />
<cfargument name="b" />
<cfset var i = 0 />
<cfset var base = StructNew() />
<cfloop list="#arrayToList(a)#" index="i">
<cfset base[i] = "" />
</cfloop>
<cfloop from="1" to="#arrayLen(b)#" index="i">
<cfset base[b[i]] = "" />
/cfformgateway/* = cfusion
/CFFormGateway/* = cfusion
/flex2gateway/* = cfusion
/flex2gateway = cfusion
/cffileservlet/* = cfusion
/CFFileServlet/* = cfusion
/cfform-internal/* = cfusion
/flashservices/gateway/* = cfusion
/flex-internal/* = cfusion
/rest/* = cfusion
component extends="taffy.core.api" {
function onTaffyRequest(string verb, string cfc, struct requestArguments, string mimeExt, struct headers) {
local.metadata = getMetadata( getBeanFactory().getBean(arguments.cfc) );
//do stuff with metadata
}
}
# force **NO** SSL for non-login, non-registration pages
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^admin\.company\.com$
RewriteCond %{URL} !^/register.cfm$
RewriteCond %{URL} !^/login.cfm$
RewriteRule ^(.*)?$ http://%{HTTP_HOST}/$1 [R=301,L]
# force SSL for login & registration pages
RewriteCond %{HTTPS} off
RewriteRule ^login.cfm(.*)$ https://%{HTTP_HOST}/login.cfm$1 [R=301,L]
@atuttle
atuttle / gist:3722564
Created September 14, 2012 15:17
JS Bookmarklet to show queries from the current page with sql params in-place.
javascript:if%20(typeof(%20ShowCFDebugSQL%20)%20==%20'undefined'){%20function%20ShowCFDebugSQL(){%20var%20arrTable%20=%20document.getElementsByTagName(%20'table'%20);%20var%20arrPre%20=%20null;%20var%20objCFDebugTable%20=%20null;%20var%20arrRawData%20=%20new%20Array();%20var%20objRawData%20=%20null;%20var%20objFrame%20=%20document.createElement(%20'textarea'%20);%20var%20i%20=%200;%20for%20(i%20=%200%20;%20i%20<%20arrTable.length%20;%20i++){%20if%20(%20arrTable[%20i%20].className%20&&%20(arrTable[%20i%20].className%20==%20'cfdebug')%20){%20objCFDebugTable%20=%20arrTable[%20i%20];%20break;%20}%20}%20if%20(objCFDebugTable){%20arrPre%20=%20objCFDebugTable.getElementsByTagName(%20'pre'%20);%20for%20(i%20=%200%20;%20i%20<%20arrPre.length%20;%20i++){%20if(%20arrPre[%20i%20].innerHTML.match(%20new%20RegExp(%20'SELECT|INSERT|DELETE|JOIN|WHERE',%20'i'%20)%20)%20){%20objRawData%20=%20new%20Object();%20objRawData.SQL%20=%20arrPre[%20i%20].innerHTML;%20objRawData.Params%20=%20'';%20if%20(%20(arrPre[%20i%20].nextSibling.n
@atuttle
atuttle / DataTypes.md
Created September 18, 2012 13:35 — forked from sipacate/DataTypes.md
Basics

In our last Chapter, we talked about variables, data and how to transport data around in your application. There are different kinds of data and each helps in specific ways.

Strings/Numbers

Is Simple: Yes

Strings and numbers are very easy to work with. To set a string or a number, just use the CFSET command like this:

<cfset aString = "hi">
@atuttle
atuttle / lawnchair-paginated-query.js
Created November 15, 2012 19:31
Pagination plugin & Query plugin, sitting in a tree...
/*
Confused? Start here: http://brian.io/lawnchair/
This plugin takes two awesome other plugins and mashes their naughty bits together.
Queries are awesome. Pagination is awesome. Paginated Queries are awesome^2.
I take no credit for any of the heavy lifting done here, all I did was take two genius
things and smash them together.
*/
<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">