Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
@atuttle
atuttle / artist.cfm
Created March 25, 2011 20:55
An example of writing REST web services in ColdFusion, without a framework. This code is provided as an example of a simple implementation, but should not be considered a best practice or something I am promoting. I use this in one of my presentations as
<!---
An example of writing REST web services in ColdFusion, without a framework (and why you should use one).
Provided as an example of a simple implementation, but should not be considered a best practice or something
I am promoting. Not thoroughly tested, not very maintainable, not even that reusable.
--->
<cfsetting enablecfoutputonly="true" showdebugoutput="false" />
<cffunction name="StructKeyRequire" output="false">
<cfargument name="s" type="struct" />
@atuttle
atuttle / api.js
Created February 4, 2014 14:31
Angular.js REST API Service Wrapper
app.factory('API', function($http, $q){
var basePath = 'http://domain.com/api/path';
// => http://domain.com/api/path/foo/bar
function makeRequest(verb, uri, data){
var defer = $q.defer();
verb = verb.toLowerCase();
//start with the uri
@atuttle
atuttle / Gruntfile.js
Created June 10, 2016 17:49
My Browserify & Grunt config for React.js with LESSCSS
module.exports = function(grunt){
'use strict';
grunt.initConfig({
less: {
bundle: {
options: {
compress: true
,report: 'min'
<cfscript>
function deORM( obj, depth = 1, depthLimit = 10 ){
var deWormed = {};
if (depth >= depthLimit){
return {};
}
if (isSimpleValue( obj )){
deWormed = obj;
}
else if (isObject( obj )){
@atuttle
atuttle / Cobalt2.spTheme
Created April 25, 2016 19:17
Cobalt2 theme (ported from the Sublime Text theme by @wesbos) for Sequel Pro: http://www.sequelpro.com/ -- save it as Cobalt2.spTheme and import it from your settings.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
@atuttle
atuttle / EOL.cfm
Created April 18, 2016 20:16
Determining what char codes ACF uses on different operating systems
<cfscript>
fn = "ram://eol.txt";
f = fileOpen( fn, "append", "utf-8" );
fileWriteLine( f, '1' );
fileWriteLine( f, '2' );
fileClose( f );
r = fileRead( fn );
chars = listToArray( r, '' );
var store = require('store') //my redux store
var unsubscribe
var MyComponent = React.createClass({
componentDidMount: function componentDidMount(){
unsubscribe = store.subscribe(function handleStateChange(){
// in ES6 we could do this: this.forceUpdate()
// but what is the solution for ES<6?
})
}
@atuttle
atuttle / .gitconfig
Created March 9, 2016 13:57
My ~/.gitconfig (with sensitive portions removed)
[color]
ui = auto
[core]
autocrlf = input
excludesfile = /Users/atcodes/.gitignore_global
[push]
default = tracking
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr,%an)%Creset' --abbrev-commit --date=relative
st = status -sb
@atuttle
atuttle / approach_a.cfc
Last active January 18, 2016 20:48
Which way is better? Why?
var messageStatus = new util.iQuery("
select
status
from
Message
where
messageId = :id
",{
id: { cfsqltype: "cf_sql_numeric", value: batch.messageId[1] }
});
@atuttle
atuttle / Default (OSX).sublime-keymap
Created August 8, 2014 18:17
My Sublime Text 3 Preferences and Keymaps
[
{ "keys": ["alt+up"], "command": "swap_line_up" }
,{ "keys": ["alt+down"], "command": "swap_line_down" }
,{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" }
,{ "keys": ["alt+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} }
,{
"keys": ["ctrl+alt+left"],
"command": "set_layout",
"args": {