Skip to content

Instantly share code, notes, and snippets.

View bittersweetryan's full-sized avatar

Ryan Anklam bittersweetryan

View GitHub Profile
@bittersweetryan
bittersweetryan / gist:1958664
Created March 2, 2012 14:23
CFHotfix Description
This is ColdFusion 10 Beta cumulative hotfix 2.
It includes fix for Bug ID 3117366(issue with implicit getters throwing error when they are called from inside cfc
corresponding cfproperty is not initialized).
Once the fix is installed, even without initialization of cfproperty, implicit getters can be called on it.
<cfscript>
public void function testStringsShouldBeEqual(){
var result = "Foo";
//in the koans __ represents a value that you need to fill in to make the test return true
//in some cases you'll want to keep the "" and in some you wont (see next example)
assertEquals(result,"__");
}
</cfscript>
@bittersweetryan
bittersweetryan / gist:2028645
Created March 13, 2012 13:06
Functional Extend in ColdFusion (think jQuery.extend())
<cfscript>
public Struct function extend()
output=false hint="I take structs and add their keys"{
var ret = {};
for(var i = 1; i <= arrayLen(arguments); i++){
for(key in arguments[i]){
ret[key] = arguments[i][key];
}
}
<cfscript>
public Array function list(Struct options = {})
output=false hint="I return a list of active, non-deleted people by default."{
//create our default options
var defaults = {
deleted = false,
active = true
};
//now combine this struct with the options
<cfscript>
//returns all active, non-delted people
list();
//returns only active, non-deleted people
list({active = false});
//returns only inacvie, delted people
list({active = false, deleted = true});
@bittersweetryan
bittersweetryan / hack.sh
Created March 31, 2012 15:00 — forked from rwaldron/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@bittersweetryan
bittersweetryan / gist:2787854
Created May 25, 2012 12:44
Flatten a JavaScript Object into a Flat Object With Dot Notation Prop Names
function flatten(obj,prefix){
var propName = (prefix) ? prefix + '.' : '',
ret = {};
for(var attr in obj){
if(_.isArray(obj[attr])){
var len = obj[attr].length;
ret[attr] = obj[attr].join(',');
/**
* @mxunit:decorators mxunit.framework.decorators.OrderedTestDecorator
*/
component extends="Koans.BaseKoan" {
private boolean function isTruthy(Any myVar){
if(isBoolean(arguments.myVar)){
return (arguments.myVar) ? true : false;
}
@bittersweetryan
bittersweetryan / gist:2890286
Created June 7, 2012 17:44
deferred to control animation timings
displayMessage: function(ev){
var id = ev.currentTarget.id,
dfd = $.Deferred(),
self = this,
statusCell = this.getStatusCell($(ev.currentTarget));
this.model.set('id',id);
if(statusCell.find('img').attr('alt') === 'unread'){
@bittersweetryan
bittersweetryan / gist:2919074
Created June 12, 2012 18:09
Mocking and Stubbing in MXUnit
<cfscript>
//stubbing
public void function testSavingPerson()
output=false hint=""{
//create the mock of your dao
var mockPersonDAO = mock("PersonDAO","typeSafe");
//tell the mock that when save is called with the cut to return void
mockPersonDAO.save(variables.Person).returns();
//add it to the cut