Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
@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
# 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]
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
}
}
/cfformgateway/* = cfusion
/CFFormGateway/* = cfusion
/flex2gateway/* = cfusion
/flex2gateway = cfusion
/cffileservlet/* = cfusion
/CFFileServlet/* = cfusion
/cfform-internal/* = cfusion
/flashservices/gateway/* = cfusion
/flex-internal/* = cfusion
/rest/* = cfusion
@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]] = "" />
@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 / leeroy.cfg
Created October 20, 2011 15:02
This is my preseed file for auto-installing Ubuntu 11.04 on my Jenkins server
#### Contents of the preconfiguration file (for squeeze)
### Localization
# Preseeding only locale sets language, country and locale.
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
# Optionally specify additional locales to be generated.
#d-i localechooser/supported-locales en_US.UTF-8, nl_NL.UTF-8
d-i debian-installer/locale string en_US
@atuttle
atuttle / gist:959038
Created May 6, 2011 14:23
A shell script for getting stats about your git repo (lines committed in HEAD by comitter)
#!/bin/sh
# this script requires GNU-SED for the "-r" option.
# Get it via: sudo brew install gnu-sed
# command found at: http://stackoverflow.com/questions/4589731/git-blame-statistics/4590487#4590487
echo "Lines in HEAD by Committer:"
git ls-tree -r HEAD|sed -re 's/^.{53}//'|while read filename; do file "$filename"; done|grep -E ': .*text'|sed -r -e 's/: .*//'|while read filename; do git blame "$filename"; done|sed -r -e 's/.*\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\1/' -e 's/ +$//'|sort|uniq -c
@atuttle
atuttle / artist.cfm
Created March 25, 2011 20:55
An example of writing REST web services in ColdFusion, without a framework. This code is provided as an example of a simple implementation, but should not be considered a best practice or something I am promoting. I use this in one of my presentations as
<!---
An example of writing REST web services in ColdFusion, without a framework (and why you should use one).
Provided as an example of a simple implementation, but should not be considered a best practice or something
I am promoting. Not thoroughly tested, not very maintainable, not even that reusable.
--->
<cfsetting enablecfoutputonly="true" showdebugoutput="false" />
<cffunction name="StructKeyRequire" output="false">
<cfargument name="s" type="struct" />
@atuttle
atuttle / deliciousBackupParser.cfc
Created February 24, 2011 04:19
Parses the HTML export from Delicious.com and returns an array of structures representing the links from delicious.
component {
public function init() output="false" {
return this;
}
public function parse(data) output="false" {
local.links = [];
//loop over each line in the file