Skip to content

Instantly share code, notes, and snippets.


Johan Steenkamp jsteenkamp

View GitHub Profile
jsteenkamp / upload.cfc
Created Jul 30, 2011
ColdFusion code for Plupload file uploading including chunked transfers
View upload.cfc
<cffunction name="upload" access="remote" returntype="struct" returnformat="json" output="false">
var uploadDir = expandPath('.') & '/uploads/'; // should be a temp directory that you clear periodically to flush orphaned files
var uploadFile = uploadDir & arguments.NAME;
var response = {'result' = arguments.NAME, 'id' = 0};
var result = {};
// if chunked append chunk number to filename for reassembly
if (structKeyExists(arguments, 'CHUNKS')){
View postmark.cfc
<cfcomponent name="PostMarkAPI" hint="Send email messages using API">
<cffunction name="sendMail" output="false" access="remote" returntype="struct" returnformat="json" description="Assembles JSON packet and sends it to Postmarkapp">
<cfargument name="mailTo" required="true" type="string" displayname="Recipient" />
<cfargument name="mailFrom" required="true" type="string" displayname="Sender" default="" />
<cfargument name="mailSubject" required="true" type="string" displayname="Subject" default="Testing Postmark" />
<cfargument name="apiKey" required="true" type="string" displayname="API key" default="xxx-xxx-xxx-xxx" />
<!--- optional --->
<cfargument name="mailReply" required="false" type="string" displayname="Reply-To (optional)" />
<cfargument name="mailCc" required="false" type="string" displayname="CC (optional)" />
<cfargument name="mailHTML" required="false" type="string" displayname="HTML body (optional)" />
jsteenkamp / gist:1721864
Created Feb 2, 2012
Bootstrap v2 legend with nested columns
View gist:1721864
<!-- fix legend margin with nested row and row-fluid in bootstrap - add this:
legend+.row, legend+.row-fluid{margin-top:18px;-webkit-margin-top-collapse:separate;}
<div class="row">
<div class="span12">
<legend>My Legend</legend>
<div class="row">
<div class="span6">form control group</div>
jsteenkamp / codepen-save
Created Jan 26, 2015
JSON object saved by CodePen
View codepen-save
pen: {
"defaultAJAXTimeout": 10000,
"failedRequestMsg": "Unable to reach Please contact",
"auto_run": true,
"checksum": 1415964482,
"created_at": "2015-01-26T19:05:43Z",
"css": "",
"css_external": "",
"css_pre_processor": "none",
jsteenkamp / osx-dsclean
Last active Aug 29, 2015
OSX bash function and alias to remove hidden directories from zip files
View osx-dsclean
$ nano ~/.bash_rc
function dsclean() {
if [ -f $1 ]
echo "Delete __MACOSX folder from $1"
zip -d "$1" __MACOSX*
echo "Delete all .DS_Store folders from $1"
zip -d "$1" \*.DS_Store
jsteenkamp / app.js
Last active Aug 29, 2015
Angular 1.x Component Architecture Application using JSPM for ES6 and importing CSS and HTML
View app.js
'use strict';
// vendor modules
import angular from 'angular';
import 'angular-touch';
import 'angular-animate';
import 'angular-aria';
import 'angular-ui-router';
// app modules
jsteenkamp / prototype
Last active Aug 29, 2015
JavaScript new vs Object.create( ... )
View prototype
*** see ***
*** Don't do this ***
function MyClass() {}
MyClass.prototype.method1 = function () { ... };
MyClass.prototype.method2 = function () { ... };
// ...
MyClass.prototype.methodN = function () { ... };
jsteenkamp / detached
Last active Aug 29, 2015
Detached DOM nodes
View detached
// create an element to attach to document
var d = document.createElement('div');
// take heap snapshot and filter on 'detached' will show the above node
// now attach element to document
// take heap snapshot and the detached node is no longer listed
// you can look at diff between two snapshots and see it has been added to HTMLBodyElement
jsteenkamp / factory-beats-class.js
Last active Aug 29, 2015
Better to use Prototypal OO and not ES6 class (Angular example)
View factory-beats-class.js
'use strict';
import _ from 'lodash';
// generate some list items
let items = _.times(10).map((n) => {
return {
title: `This is log item ${n + 1}`,
description: `This is item description ${n + 1}`
View angular-loadscript-with-documentwrite.js
* This module is a variant which supports document.write. If you need document.write use this instead
* Author: Deepak Subramanian @subudeepak(
* Distributed under MIT License
/*global angular */
(function (ng) {
'use strict';
app.directive('script', function() {
return {