Skip to content

Instantly share code, notes, and snippets.

@ryanguill
ryanguill / c.cfc
Last active August 29, 2015 13:57
railo-interface-bug
component implements="i" accessors="true" {
property name="name" type="string";
public any function init(name) {
setName(arguments.name);
return this;
}
}
jdbc:as400://{servername};prompt=false;translate binary=true;lazy close=true;extended dynamic=false;package={package Name (keep it to 6 chars or less)};package library={packageLibrary};naming=system;libraries=qtemp {library list};errors=full;
ClassName: com.ibm.as400.access.AS400JDBCDriver
@ryanguill
ryanguill / ordered-struct.cfm
Last active August 29, 2015 14:01
how to create an ordered struct in Adobe ColdFusion and Railo - run this code here: http://www.trycf.com/scratch-pad/gist/bd92e8a7954076fd13af/railo
<cfscript>
//In Adobe ColdFusion
//instead of structNew() or {} create a java linked hashmap
myStruct = createObject( "java", "java.util.LinkedHashMap" ).init();
//now just use it like any other struct
//NOTE: one difference though is that it will be case sensitive, myStruct["one"] will be different than myStruct["One"]
//unlike normal cf structures
//In railo you can do it like the adobe example or use this shorthand
@ryanguill
ryanguill / dom-duplicate-element-ids-audit.js
Last active August 29, 2015 14:02
Small script that you can run in the console to see if you have more than one element with the same ID.
var allElements = document.getElementsByTagName("*"), allIds = {}, dupIDs = [];
for (var i = 0, n = allElements.length; i < n; ++i) {
var el = allElements[i];
if (el.id) {
if (allIds[el.id] !== undefined) dupIDs.push(el.id);
allIds[el.id] = el.name || el.id;
}
}
if (dupIDs.length) { console.error("Duplicate ID's:", dupIDs);} else { console.log("No Duplicates Detected"); }
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<a href="http://google.com">Google</a><br />
<a href="http://example.com" data-dont-fade="true">Example.com (dont fade)</a>
<!--- works properly --->
<cfdump var="randRange(0,2^31-2): #randRange(0,2^31-2)#"/><br />
<!--- returns a negative number every time --->
<cfdump var="randRange(0,2^31-1): #randRange(0,2^31-1)#"/><br />
<!--- The following line errors (expectedly) with
Parameter validation error for the RANDRANGE function.
The value of parameter 2, which is currently 2147483648, must be a int value. --->
<!--- <cfset x = randRange(0,2^31) /> --->
@ryanguill
ryanguill / mssql-columns-in-table.sql
Created August 7, 2014 12:46
mssql table and column information
SELECT
columns.*
, '' remarks
, data_type type_name
, character_maximum_length column_size
, column_default column_default_value
, syscolumns.is_identity
, CASE WHEN primaryKeyConstraints.constraint_type IS NOT NULL THEN 1 ELSE 0 END is_primarykey
, CASE WHEN foreignKeyConstraints.constraint_type IS NOT NULL THEN 1 ELSE 0 END is_foreignKey
FROM
<html>
<head>
<title>JS File Upload</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<input type="file" id="inpFile" value="" />
<input type="button" id="btnUpload" value="upload" />
<script>
<cfsetting requesttimeout="600" />
<cfscript>
public array function i1 (required array a, required array b) {
if (arrayLen(b) < arrayLen(a)) {
var t = a;
a = b;
b = t;
}
/* useful if you dont have a real exception join */
/* this will return the records in a that are not in b on the join conditions in the left outer join */
select
a.foo
FROM
a
LEFT OUTER
JOIN b
ON a.id = b.id
WHERE