Skip to content

Instantly share code, notes, and snippets.

SELECT * FROM loadsplits WHERE Loadnumber = 7499999
@ryanguill
ryanguill / bitSearch.cfc
Created July 17, 2012 15:08 — forked from linkmckinney/bitSearch.cfc
BitAnd exercise
<cffunction name="valueSearch2" returntype="string" access="remote">
<cfargument name="input" type="numeric" required="true"/>
<cfset var local.msg = ''>
<cfset local.bitAR = arrayNew(1) />
<cfset local.bitAR[1] = { bit = 256, name = 'Authority' } />
<cfset local.bitAR[2] = { bit = 128, name = 'Claims' } />
<cfset local.bitAR[3] = { bit = 64, name = 'Service Failure' } />
@ryanguill
ryanguill / fizzbuzz.cfm
Created July 19, 2012 13:20 — forked from anonymous/fizzbuzz.cfm
Fizz Buzz
<!--- cf function that solves the fizzbuzz test --->
<!--- I generally don't like functions outputing themselves,
I would rather have it do a return - gives you more flexability later --->
<cffunction name="displayFBMsg" access="private" hint="whatever..."><!--- no returntype / no output --->
<cfargument name="numberOfIterations" required="true" type="numeric"><!--- personal preference, I like name, type, required, but thats not a big deal --->
<cfloop from="1" to="#arguments.numberOfIterations#" index="i"><!--- i is not var'd --->
<!--- with this logic, you're going to do at least 2 checks on every number,
and if those pass, you'll do 4, regardless (just as a comparison) --->
<cfif i MOD 3 EQ 0 OR i MOD 5 EQ 0>
<cfoutput>
<ol>
<cfloop from="1" to="1000" index="i">
<li>#fizzbuzz(i)#</li>
</cfloop>
</ol>
</cfoutput>
<cffunction name="fizzbuzz" access="public" returntype="string" output="false">
<cfargument name="input" type="numeric" required="True" />
<cfcomponent>
<cffunction name="processFizz" access="remote" returntype="String"><!--- no output --->
<cfargument name="input" type="numeric"><!--- no required --->
<cfset var local = structNew()/>
<cfset local.result = ''/>
<cfif arguments.input MOD 3 EQ 0 AND arguments.input MOD 5 EQ 0>
@ryanguill
ryanguill / foo.cfc
Created September 14, 2012 01:45
cache/facade example
<cfcomponent>
<cfset variables.settings = structNew() />
<cfset variables.settings.cacheExpirationSeconds = 10 />
<cfset variables.instance = structNew() />
<cfset variables.instance.cacheExpirationTime = 0 />
<cfset variables.instance.cache = queryNew("foo") />
<cffunction name="init" access="public" returntype="any" output="false" hint="">
WITH reserved AS (
SELECT
COUNT(sectionID) reservedCount
, sectionID
FROM
enrollmentReservation
), enrolled AS (
SELECT
COUNT(sectionID) enrolledCount
, sectionID
@ryanguill
ryanguill / gist:4739645
Created February 8, 2013 15:19
coldfusion strings are already java strings underneath, and you can call the java String class methods on a CF string.
<cfscript>
// Converts a ColdFusion string in a java byte array
function createByteArray(string){
var objString = createObject("Java", "java.lang.String").init(JavaCast("string", string));
return objString.getBytes();
}
</cfscript>
<cfset variables.myCFString = "Sally sells sea shells by the sea shore" />
@ryanguill
ryanguill / receive-test.cfm
Last active December 13, 2015 16:39
the simple example for rabbitmq I set up. rabbitmq configuration was out-of-box, no changes, running on a virtualbox centos 6.3 vm with a gig of ram. Example of results:100000 messages sent in 13847 ms ( 7221.78089117 messages/second ). 100000 messages received in 20865 ms. ( 4792.71507309 messages/second )
<!---
--- NOTE: YOU NEED THE JAVA LIBRARY FROM HERE: http://www.rabbitmq.com/java-client.html
--- http://www.rabbitmq.com/tutorials/tutorial-one-java.html
--- https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/java/Recv.java
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
@ryanguill
ryanguill / CFRemoteObjectFactory.as
Last active December 14, 2015 19:29
CFRemoteObjectFactory class - enables you to connect to any ColdFusion flex gateway without using compiler arguments. Much easier, lighter and more maintainable.
/*
// EXAMPLE USAGE
// copy this file to com/util/CFRemoteObjectFactory.as
import com.util.CFRemoteObjectFactory;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;