Skip to content

Instantly share code, notes, and snippets.

View davejlong's full-sized avatar

David Long davejlong

View GitHub Profile
@davejlong
davejlong / 1.sql
Created May 13, 2011 14:24
SQL Output with Nulls at the bottom of the output
SELECT schools.id AS schoolid,schools.name AS school,districts.id AS districtid, districts.name AS district
FROM sms_schools AS schools
LEFT JOIN sms_districts AS districts ON schools.districtid = districts.id
WHERE 1 = 1
ORDER BY (CASE WHEN districts.id IS NULL then 1 ELSE 0 END),districts.name, schools.name;
@davejlong
davejlong / coldfusion
Created May 13, 2011 15:04
Ruby Output Compared to Coldfusion Output
foo = 'bar';
if(foo IS 'bar'){
writeOutput(foo);
}
@davejlong
davejlong / cfscp.cfc
Created May 18, 2011 13:46
SCP Functionality within ColdFusion using the SFTP
<cfcomponent displayname="CF SCP" hint="Handles SCP style functionality within ColdFusion" output="false">
<cfproperty name="scpserver" hint="Remote server to send files to" type="string" />
<cfproperty name="username" hint="Username for access to the remote server" type="struct" />
<cfproperty name="password" hint="Password of the remote server (required if not using private key authentication)" type="string" />
<cfproperty name="key" hint="Path to private key for private key authentication" type="string" />
<cfproperty name="connection" type="any" />
<!--- #### Object Constructor #### --->
<cffunction name="init" hint="Object constructor" access="public" output="false" returntype="any">
<cfargument name="server" type="string" required="false" default="" />
@davejlong
davejlong / ruby.rb
Created May 20, 2011 19:51
My first Ruby app
realNum = rand(10)
puts "What is your guess?"
checkNum = gets.to_i
while checkNum != realNum do
if checkNum != realNum
puts 'Your guess is wrong. What is your guess?'
checkNum = gets.to_i
end
end
puts 'You guessed correctly!'
@davejlong
davejlong / arrayfind.cfc
Created May 20, 2011 19:53
Array Find for Pre CF9 Servers
<cfcomponent>
<cfif left(Server.ColdFusion.productversion,1) LT 9>
<cffunction name="arrayFind" access="public" output="false" returntype="Numeric" hint="Returns the index of the first found element in the array containing the value argument">
<cfargument name="array" required="true" type="array" />
<cfargument name="value" required="true" type="string" />
<cfreturn (Arguments.array.indexOf(Arguments.value)) +1 />
</cffunction>
</cfif>
</cfcomponent>
@davejlong
davejlong / change-permission.sh
Created May 25, 2011 12:58
Hiding Adium Dock icons on Mac
sudo chmod 464 Info.plist
@davejlong
davejlong / app.js
Created May 25, 2011 16:57
Dyanimcally disableing tabs in jQuery UI
$(function(){
console.log('Tabbing interface');
// Create the array that stores our disabled tabs and populate it
var tabdisabled = [];
$('.tabs ul:first li a').each(function(index){
var $this = $(this);
var $enabled = $('.tabs div .enable#' + index);
if($this.hasClass('disabled'))tabdisabled.push(index);
// Add the handler to enable and disable the tab
@davejlong
davejlong / broken-save.cfc
Created May 25, 2011 17:02
Order of Execution in FW/1
public function save(any rc) void{
// Run an insert query called local.student here
local.history = {
student = local.student.GENERATED_KEY,
datestamp = now(),
active = Rc.active,
school = Rc.school,
grade = Rc.grade
};
variables.fw.service('student.newhistory','history',local.history);
@davejlong
davejlong / codes.cfc
Created May 26, 2011 17:43
Bundling Error Codes into INI Files
component{
function init(statusini){
variables.ini = expandPath(Arguments.statusini);
return this;
}
function getStatus(section, id){
var code = getProfileString(variables.ini, section, id);
if(!len(code)) getProfileString(variables.ini, section, 000);
if(!len(code)) throw(message="Status code not found", detail="There is no status code with id #Arguments.id# in #Arguments.section#, and no default status code was found.");
return code;
@davejlong
davejlong / create-table.cfm
Created May 26, 2011 17:52
In-memory databases with Railo
<cftry>
<cfquery name="create" datasource="inmemory">
CREATE TABLE testTable (
testID INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
test VARCHAR(50)
)
</cfquery>
<cfcatch type="any">
<!--- Well this sucks. Now our application can't do anything. --->
</cfcatch>