Skip to content

Instantly share code, notes, and snippets.

@cfvonner
cfvonner / git_commands
Created April 24, 2012 17:36 — forked from webRat/git_commands
9 Common Git Commands
git init - navigate to the appropriate directory and just type that.
git add . - adds everything in that path
git commit -m 'stuff' - Commits with the message 'stuff'
git branch - views branches
git checkout -b <new branch> - Creates & switches to new branch
git checkout <branch> - switches to branch
git merge <branch> - merges that branch to the existing branch that you're already in.
git branch -d <branch> - deletes branch
git push - This assumes you already have a remote setup (like github)
@cfvonner
cfvonner / gist:3018560
Created June 29, 2012 15:18 — forked from bittersweetryan/gist:2919074
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
@cfvonner
cfvonner / Person.cfc
Created June 29, 2012 15:20
Sample Components for CFKoans Mocking tests
component displayname="Person" hint="I am a person object." output="false" accessors="true"
{
// Define the properties for this component
property name="personID" type="numeric" getter="true" setter="false" hint="Unique numeric id assigned by the database.";
property name="firstName" type="string" getter="true" setter="true" hint="The first name of the person.";
property name="lastName" type="string" getter="true" setter="true" hint="The last name of the person.";
property name="dateOfBirth" type="date" getter="true" setter="true" hint="The date of birth of the person.";
property name="personDAO" type="Person" getter="false" setter="true";
// Define the functions other than implicit getters and setters for this component
@cfvonner
cfvonner / AboutMocks.cfc
Created June 30, 2012 00:38
First cut of my Mocking Koan
/**
* @mxunit:decorators mxunit.framework.decorators.OrderedTestDecorator
*/
component extends="Koans.BaseKoan" {
public void function beforeTests() {
variables.person = createObject( 'component','components.Person' ).init( 'Malcolm','Reynolds',CreateDate(2486,9,20));
}
public void function testSaveAsMock() {
@cfvonner
cfvonner / len-test.cfm
Last active September 18, 2016 13:43 — forked from anonymous/trycf-gist.cfm
No ColdFusion Len Member Function on Java numbers
<cfscript>
myNumber = 10;
writeOutput( myNumber.len() );
//This will throw a "The len method was not found"
myJavaNumber = JavaCast( "int", myNumber );
writeOutput( myJavaNumber.len() );
//This will throw a "The len method was not found"
myQueryNumber = queryNew( "id", "integer", {id: 16} ).id;
@cfvonner
cfvonner / box.json
Created March 29, 2017 20:00 — forked from elpete/box.json
ForgeBox deploys in one command
{
"scripts":{
"postVersion":"package set location='user/repo#v`package version`'",
"onRelease":"publish",
"postPublish":"!git push && !git push --tags"
},
}
@cfvonner
cfvonner / trycf-gist.cfm
Last active April 27, 2017 16:19 — forked from anonymous/trycf-gist.cfm
Using Closures to create an "object-like" struct
<p>Using closures, it is possible to create an "object-like" struct with cfml and not using any components. It allows you to do encapsulation, have methods, do chaining, etc. It's api is pretty much identical to an object, except that you use a function to create it (instead of new). ACF10+ and Lucee 4.5+</p>
<cfscript>
function make (required numeric input) {
var value = input;
var o = {
add: function (required numeric input) {
value += input;
return o;
component displayname="Base Service" accessors="true" output="false" {
property beanFactory;
public function init() {
return this;
}
private function populate ( any bean, struct properties, any beanFactory ) {
writeLog( text="#GetMetaData( this ).name#-->#getFunctionCalledName()#() arguments: #SerializeJSON( arguments )#", file="GISReports.local.dev", type="information" );
@cfvonner
cfvonner / gist:768152dce8345c3b758b709b400f5023
Created November 13, 2017 23:33
VSCode ShellLauncher Configuration with CommandBox
// Configure multiple shells
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\System32\\cmd.exe",
"args": [
""
],
"label": "cmd shell"
},
{
@cfvonner
cfvonner / assetService.cfc
Last active September 10, 2018 18:13
Testing a service with dependencies
component displayname="GIS Plant Asset Service" extends="app.model.services.baseService" accessors="true" {
property assetGateway;
public array function list() {
return populateBeans( "assetBean", assetGateway.select() );
}
public array function getByAssetID ( required string assetid ) {
var data = assetGateway.select( { assetid : assetid } );