Skip to content

Instantly share code, notes, and snippets.

View atuttle's full-sized avatar

Adam Tuttle atuttle

View GitHub Profile
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 / .jscsrc
Created July 1, 2015 20:39
My JSCS config and a sample of how it formats
{
"preset": "node-style-guide"
,"validateIndentation": "\t"
,"disallowAnonymousFunctions": true
,"disallowSpacesInsideParentheses": { "only": [ "{", "}" ] }
,"requireSpacesInsideParentheses": { "all": true, "except": [ "{", "}" ]
,"requireSpacesInsideBrackets": { "allExcept": [ "[", "]", "{", "}" ] }}
,"requireSpacesInsideObjectBrackets": "allButNested"
,"validateParameterSeparator": ", "
,"disallowCommaBeforeLineBreak": true
@atuttle
atuttle / timezones.cfm
Last active November 19, 2022 03:23
Dealing with Time Zones in ColdFusion
<!---
Many thanks to Sean Corfield and Ryan Guill who set me down the correct path of java.util.TimeZone
--->
<cfscript>
writeDump(label="Conversion Examples",var={
"0-local-tz": getSystemTZ()
,"1-local-now": now()
,"2-utc-now": toUTC(now())
,"3-eastern-now": TZtoTZ( getSystemTZ(), now(), "America/New_York" )
[user]
name = Adam Tuttle
email = adam@fusiongrokker.com
[color]
ui = auto
[core]
autocrlf = input
excludesfile = /Users/adam/.gitignore_global
[push]
default = tracking
@atuttle
atuttle / adminBase.cfc
Last active August 29, 2015 14:10
Securing FW/1 applications; segmented by controller
component accessors="true" {
property framework;
property memberService;
function before( rc ){
local.safeEvents = 'main:member.login,main:member.forgot,main:member.resetpassword';
//require login for everything in this controller except login method
if (!structKeyExists(session, 'user')){
@atuttle
atuttle / Application.cfc
Created November 4, 2014 16:27
How I like to do configuration with DI/1
component {
function getEnvironment(){
if (cgi.server_name contains ".local" or cgi.server_name contains ".dev"){
return "dev";
}
if (cgi.server_name contains "qa."){
return "qa";
}
return "prod";
@atuttle
atuttle / example.cfm
Last active August 29, 2015 14:07
Generating random numbers with a trend to make data appear more realistic in some scenarios. 50% chance for a direction change.
<cfscript>
//to initialize to a random number instead of 50, set last to ""
last = 50;
for(var i = 1; i <= 100; i++){
last = trendingRandom( 0, 100, 12, last );
writeOutput( "#last#<br/>" );
}
</cfscript>
@atuttle
atuttle / package.json
Created October 2, 2014 01:18
Using a free RedisToGo Nano instance on heroku, or the default settings on your local environment
{
"dependencies": {
"redis": "^0.10.1"
}
}