Skip to content

Instantly share code, notes, and snippets.

View aqlong's full-sized avatar

Ocean Longnion aqlong

  • Liquidity Services
  • Austin, TX
View GitHub Profile
<cfscript>
local.myURL = "https://api.sample.com/";
// cfscript replacement for cfhttp
local.httpService = new http();
local.httpService.setMethod( "post" );
local.httpService.setCharset( "utf-8" );
@aqlong
aqlong / server.xml
Last active December 13, 2015 17:18
<Server port="8008" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on">
</Listener>
<Listener className="org.apache.catalina.core.JasperListener">
</Listener>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener">
</Listener>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener">
</Listener>
<GlobalNamingResources>
<cfdump var="#createobject("component","CFIDE.adminapi.runtime").getinstancename()#">
<cfif structKeyExists(url, "setSessionTime")>
<cfset session.time = now()>
</cfif>
<cfdump var="#GetHttpRequestData()#">
<cfdump var="#session#">
component output="false" {
/* **************************** APPLICATION VARIABLES ******************* */
THIS.name = "clustertest0006";
// Life span, as a real number of days, of the application
THIS.applicationTimeout = createTimeSpan(0, 1, 0, 0);
@aqlong
aqlong / getMaxExternalItemID.cfm
Created June 23, 2011 16:03
MAX ID of Twitter / FB post IDs
<cfquery name="local.rsGetMaxExternalItemID"
datasource="#variables.settings.DSN_master#"
timeout="#variables.settings.databaseTimeout#">
<!--- below are samples of old MAX() statements that ran slower than ORDER BY --->
<!--- SELECT MAX( REPLACE(ExternalItemID, '_', '') ) AS ExternalItemID --->
<!--- SELECT MAX( CAST(ExternalItemID AS UNSIGNED) ) AS ExternalItemID --->
SELECT ExternalItemID
FROM StreamItems
WHERE UserID = <cfqueryparam value="#arguments.UserID#" cfsqltype="cf_sql_integer" />
AND FilterID = <cfqueryparam value="#arguments.FilterID#" cfsqltype="cf_sql_integer" />
@aqlong
aqlong / twitter_FB_streams.sql
Created June 23, 2011 15:27
MySQL table for tweets & FB posts
CREATE TABLE `StreamItems` (
`StreamItemID` int(11) NOT NULL AUTO_INCREMENT,
`UserID` int(11) NOT NULL,
`FilterID` int(11) NOT NULL DEFAULT '0',
`ItemText` varchar(2000) NOT NULL,
`Source` varchar(64) NOT NULL,
`DateTimeCreated` datetime NOT NULL,
`DateTimeLastUpdated` datetime NOT NULL,
`ExternalItemID` varchar(40) NOT NULL,
`ExternalObjectType` varchar(16) DEFAULT NULL,
@aqlong
aqlong / improved_mySQL_max.cfm
Created April 13, 2011 17:10
a slow query using MAX() vs a much faster version using ORDER BY and LIMIT 1
<!--- very slow once trying to get the MAX of over 200K records; presumably,
using MAX on varchar(40) that had to be CAST AS UNSIGNED was not performing well,
but I don't know the underlying reason; note adding an INDEX or not on ExternalItemID
did not make a noticeable difference --->
<cfquery name="local.rsGetMaxExternalItemID"
datasource="#variables.settings.DSN_master#"
timeout="#variables.settings.databaseTimeout#">
SELECT MAX( CAST(ExternalItemID AS UNSIGNED) ) AS ExternalItemID
FROM StreamItems
@aqlong
aqlong / dynamicMobileCSSHeader.cfm
Created March 14, 2011 20:57
snippet for using different CSS based on if it's mobile or not
<!--- note the order of the CSS / JS files matters; thus, the sort of strange organization of code --->
<cfif attributes.includeJQueryMobile>
<cfif attributes.isMobileDevice>
<link rel="stylesheet" href="/css/jquery.mobile-1.0a3.min.css" type="text/css" />
</cfif>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<cfif attributes.isMobileDevice>
@aqlong
aqlong / detectMobileDevice.cfm
Created March 14, 2011 20:51
ColdFusion / CFML customTag to determine if a device is mobile or not
<cfif ThisTag.ExecutionMode IS "start">
<!--- http://detectmobilebrowser.com/ - ColdFusion button; I added iPad & iPod cuz I consider them mobile --->
<cfif reFindNoCase("ipad|ipod|android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",CGI.HTTP_USER_AGENT) GT 0
OR reFindNoCase("1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|
@aqlong
aqlong / func_addLinkTagsToURLStrings.cfc
Created January 5, 2011 22:17
First, the function. Then, the tests...
<cffunction
name="addLinkTagsToURLStrings"
access="public"
returntype="string"
output="false"
hint="I parse some text, find URLs and apply an HTML HREF link to each.">
<cfargument
name="Text"
type="string"