Skip to content

Instantly share code, notes, and snippets.

@elpete
elpete / ScrollManager.jsx
Last active August 27, 2015 14:47
Add a pin to bottom scroll behavior by wrapping a component in this ScrollManager.
import React, { Component, PropTypes } from 'react';
const styles = {
scrollManager: {
position: 'absolute',
height: '100%',
width: '100%',
overflowY: 'scroll'
}
};
@elpete
elpete / git-jump
Last active August 29, 2015 14:06
git-jump from Ben Alman
#!/usr/bin/env bash
function help() {
cat <<HELP
Git Jump (Forward & Back)
http://benalman.com/
Usage: $(basename "$0") [command]
Commands:
@elpete
elpete / gulpfile.js
Created February 7, 2015 04:31
React Gulpfile
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
path = require('path'),
vinylPaths = require('vinyl-paths'),
del = require('del'),
express = require('express'),
tinyLr = require('tiny-lr'),
@elpete
elpete / UndoRedo.js
Last active August 29, 2015 14:15
Undo Redo Mixin for React
var UndoRedoMixin = {
componentWillMount: function() {
this.undoAction = false;
this.redoAction = false;
this.pastStates = [];
this.futureStates = [];
},
componentDidUpdate: function(prevProps, prevState) {
if (this.undoAction) {
this.futureStates.push(prevState);
@elpete
elpete / singleton-factory-examples.js
Last active August 29, 2015 14:22
Singleton Constructor Factory
function Box(x,y) {
this.x = x;
this.y = y;
}
var Box1 = Singleton(Box, { argumentCheck: 'equal'});
var Box2 = Singleton(Box, { argumentCheck: 'equal'});
var obj1 = new Box1(1,2);
var obj2 = new Box2(1,2);
@elpete
elpete / Permission.cfc
Last active October 5, 2015 15:13
ColdFusion Model Relationships without an ORM
component name="Permission" {
property name="id";
property name="name";
property name="roles";
public Permission function init() {
return this;
}
@elpete
elpete / columnlist.cfm
Last active November 5, 2015 17:46
ACF vs Lucee ColumnList Implementation
<cfscript>
data = QueryNew('name,id,salary', 'cf_sql_varchar,cf_sql_integer,cf_sql_integer', [
{ name = 'Jack Harkness', id = 1, salary = 5800000 },
{ name = 'Donna Noble', id = 2, salary = 4800000 },
{ name = 'Clara Oswald', id = 3, salary = 6200000 },
{ name = 'Rory Williams', id = 4, salary = 2650000 },
{ name = 'Sarah Jane Smith', id = 5, salary = 2200000 }
]);
@elpete
elpete / Binder.cfc
Created November 10, 2015 08:52
Pull Request proposal for adding WireBox listeners on the fly (like in Modules)
<!--- listener --->
<cffunction name="listener" output="false" access="public" returntype="any" hint="Add a new listener configuration.">
<cfargument name="class" required="true" hint="The class of the listener"/>
<cfargument name="properties" required="false" default="#structNew()#" hint="The structure of properties for the listner" colddoc:generic="Struct"/>
<cfargument name="name" required="false" default="" hint="The name of the listener"/>
<cfargument name="registerWithInjector" required="false" default="false" hint="Register the listener with the injector"/>
<cfscript>
// Name check?
if( NOT len(arguments.name) ){
arguments.name = listLast(arguments.class,".");
@elpete
elpete / Application.cfc
Last active November 10, 2015 17:45
Default CommandBox-generated Application.cfc
/**
********************************************************************************
Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
www.ortussolutions.com
********************************************************************************
*/
component {
// Application properties
this.name = hash( getCurrentTemplatePath() );
this.sessionManagement = true;
@elpete
elpete / Main.cfc
Last active November 10, 2015 22:19
AOP approach to converting queries to an array of structs
component extends='coldbox.system.EventHandler' {
property name='dao' inject='models.TestDAO';
function index(event, rc, prc) {
var data = dao.getData();
writeDump(data);
abort;
}