Skip to content

Instantly share code, notes, and snippets.

View aarongreenlee's full-sized avatar

Aaron Greenlee aarongreenlee

View GitHub Profile
@aarongreenlee
aarongreenlee / coldbox.cfm
Created January 14, 2012 00:27
ColdBox: processColdBoxRequest() - Trying to diagnose Event Cache Bug
<cffunction name="processColdBoxRequest" access="public" returntype="void" hint="Process a Coldbox Request" output="true" >
<cfset var cbController = 0>
<cfset var event = 0>
<cfset var exceptionService = 0>
<cfset var exceptionBean = 0>
<cfset var renderedContent = "">
<cfset var eventCacheEntry = 0>
<cfset var interceptorData = structnew()>
<cfset var renderData = structnew()>
<cfset var refResults = structnew()>
@aarongreenlee
aarongreenlee / EnvironmentDetector.cfc
Created August 27, 2011 00:35
ColdBox Environment Detection Interceptor that ensures proper environment
/** Ensure the proper environment regardless of domain used to construct the app **/
component {
// PUBLIC METHODS ---------------------------------------------------------------
public void function configure(){
// You don't have to put this in the application scope.
// I just like to keep it there.
application.machine
= createObject('java','java.net.InetAddress').getLocalHost().getHostName();
@aarongreenlee
aarongreenlee / getMockRequestContext
Created February 16, 2011 16:47
Allow Custom RC
<!--- getMockRequestContext --->
<cffunction name="getMockRequestContext" output="false" access="private" returntype="coldbox.system.web.context.RequestContext" hint="Builds an empty functioning request context mocked with methods via MockBox. You can also optionally wipe all methods on it.">
<cfargument name="clearMethods" type="boolean" required="false" default="false" hint="Clear Methods on it?"/>
<cfargument name="classname" type="string" required="false" default="coldbox.system.web.context.RequestContext" hint="By default, the core ColdBox RequestContext will be created; however, a full classpath may be provided to allow you to use a decorated RequestContext object within your tests."/>
<cfscript>
var mockRC = "";
var rcProps = structnew();
if( arguments.clearMethods ){
return getMockBox().createMock(className=arguments.classname,clearMethods=true);
@aarongreenlee
aarongreenlee / Learning Ruby 2.7 Text Adventure
Created January 27, 2011 15:48
Have fun in a text adventure game inside the Matrix.
# Text Adventure Game
# "Inside the Matrix"
# http://aarongreenlee.com/
SLEEPTIME = 1
INTRO_STRINGS = ['The Matrix has you.','Follow the White Rabbit.']
# Helpers
def print_delay(s)
sleep(SLEEPTIME)
# Aaron Greenlee
# http://aarongreenlee.com/
# Activity 2.1: Warmup 3
puts "Give me three sets of words like 'apples and oranges' and 'are good to eat'"
puts "You'll then see every combination between the two groups."
word_groups = { :one => [],:two => [],:three => [] }
word_groups.each { |k,v|
# Aaron Greenlee
# http://aarongreenlee.com/
# Activity 2.1: Warmup 2
array1 = [1, 2, 3, 4]
array2 = %w{peter piper picked peppers}
array3 = []
array3 = array1.zip(array2).join(',').split(',')
# Aaron Greenlee
# http://aarongreenlee.com/
# Activity 2.1: Warmup 1
MIN_N = 1
MAX_N = 1000000
STOP_GOING = ['no','n']
KEEP_GOING = ['yes','y']
GOOD_GOING_ANSWERS = KEEP_GOING | STOP_GOING
GOOD_GOING_ANSWERS_STRING = "'" + GOOD_GOING_ANSWERS.join('", "') + '"'
@aarongreenlee
aarongreenlee / Guess Da Numba v1
Created January 17, 2011 23:24
Learning Ruby
# Aaron Greenlee (http://aarongreenlee.com)
# Learning Ruby exercise. It's fun.
MAX_NUMBER = 100
MIN_NUMBER = 1
ALLOWED_ATTEMPTS = 10
MESSAGE_BREAK_POINT = ALLOWED_ATTEMPTS / 2
CONTINUATION_INPUT_ANSWERS = ['yes','no','y','n','ok','sure','fo sizzle']
QUIT_ANSWERS = ['n','no']
CLUE_ANSWERS = ['clue']