Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
@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 / 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 / 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.
*/