Skip to content

Instantly share code, notes, and snippets.

View imageaid's full-sized avatar

Craig Kaminsky imageaid

View GitHub Profile
@imageaid
imageaid / gist:db072556a5512696f710
Created December 26, 2014 14:17
Using a Hash a Multimap
data = Hash.new { |hash, key| hash[key] = [] }
data[:description] = "Test"
data[:expression] = "catch_all()"
data[:action] << "stop()"
data[:action] << "store()"
@imageaid
imageaid / gist:6100726
Created July 28, 2013 23:35
RubyMine regular expression to convert Ruby 1. hashes to the badass Ruby 1.9+ hashes. Can be used in RubyMine's Find/Replace option on a file.
Find -- :([a-z\_]*) =>
Replace -- $1:
@imageaid
imageaid / acf9-httpd-conf-jrun-mod.conf
Created June 7, 2012 19:41
Adobe ColdFusion 9 JRun Module Connector for Apache httpd.conf
# JRun Settings
LoadModule jrun_module /Applications/ColdFusion9/runtime/lib/wsconfig/1/mod_jrun22.so
<IfModule mod_jrun22.c>
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore /Applications/ColdFusion9/runtime/lib/wsconfig/1/jrunserver.store
JRunConfig Bootstrap 127.0.0.1:51800
#JRunConfig Errorurl url <optionally redirect to this URL on errors>
#JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying to reconnect to unreachable clustered server>
@imageaid
imageaid / revised-cfwheels-get-path
Created September 19, 2011 19:29
Revised $getPathFromRequest internal method for use with URLRewrite
<cffunction name="$getPathFromRequest" returntype="string" access="public" output="false">
<cfargument name="pathInfo" type="string" required="true">
<cfargument name="scriptName" type="string" required="true">
<cfscript>
var returnValue = "";
// ensure that the $pathinfo var is picked up from the URL struct when using URLRewriting via Tomcat/URLRewriteFilter
if (StructKeyExists(url, "$pathinfo"))
arguments.pathInfo = url.$pathinfo;
// we want the path without the leading "/" so this is why we do some checking here
if (arguments.pathInfo == arguments.scriptName || arguments.pathInfo == "/" || arguments.pathInfo == "")
@imageaid
imageaid / wheels-get-path
Created September 19, 2011 19:28
CFWheels $getPathFromRequest Method
<cffunction name="$getPathFromRequest" returntype="string" access="public" output="false">
<cfargument name="pathInfo" type="string" required="true">
<cfargument name="scriptName" type="string" required="true">
<cfscript>
var returnValue = "";
// we want the path without the leading "/" so this is why we do some checking here
if (arguments.pathInfo == arguments.scriptName || arguments.pathInfo == "/" || arguments.pathInfo == "")
returnValue = "";
else
returnValue = Right(arguments.pathInfo, Len(arguments.pathInfo)-1);
@imageaid
imageaid / urlrewrite-filter-xml-cfwheels
Created September 19, 2011 19:27
Sample URLRewriteFilter XML Config for CHWheels
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>
<rule match-type="regex">
<!-- folder conditions -->
<condition type="request-uri" operator="notequal" next="and">/flex2gateway/*</condition>
<condition type="request-uri" operator="notequal" next="and">/jrunscripts/*</condition>
<condition type="request-uri" operator="notequal" next="and">/cfide/*</condition>
<condition type="request-uri" operator="notequal" next="and">/files/*</condition>
<condition type="request-uri" operator="notequal" next="and">/flash/*</condition>
@imageaid
imageaid / web-xml-urlrewritefilter
Created September 19, 2011 19:26
Web.xml Settings for UrlRewriteFilter
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
@imageaid
imageaid / CFML Outputting Reports to XLS
Created March 23, 2011 22:07
The ease of using cfspreadsheet (or the spreadsheet cfscript functions) to generate an XLS from a CF query.
// the CFC I use to grab the data
component displayname="MemberActivity" hint="I generate reports on Member Activity"{
public MemberActivity function init(){
return this;
}
public query function getMemberLogonActivity(){
var result = "";
var q_service = new query();
@imageaid
imageaid / MailingLists.cfc
Created December 17, 2010 17:45
A CFWheels controller that outputs CSV data and sends a file to the user automatically
<cfcomponent extends="Controller" output="false">
<cfscript>
function init(){
// Let CFWheels know what type of output this controller can 'provide'
provides("html,xml,json,csv");
}
// I've removed all non-related methods for this sample
function export(){
if( !structKeyExists(params,"selection") ){
mailinglist = model("MailingList").findAll(where="exported=0",select="id,emailAddress");
<cfscript>
if(lcase(trim(cgi.request_method)) == 'post'){
sendChatRequestMessage();
}
</cfscript>
<cfoutput>
<html>
<head>
<title>Client-Specific Announcements</title>
</head>