Skip to content

Instantly share code, notes, and snippets.

@stevereich
stevereich / pwGenerator.js
Created January 25, 2019 05:32
Javascript Random Password / String Generator Script
generatePassword = function(args){
// alpha array
var chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],
// numeric array
numArr = [0,1,2,3,4,5,6,7,8,9],
// special character array
sChars = ['!','@','#','$','%','^','&','*','?'];
// set default values of args
var defaults = {};
defaults['len'] = 16;
@stevereich
stevereich / Mobile Router.md
Last active March 5, 2017 17:44
This is a component that will do simple regex check and seamlessly route user to an alternate mobile url. URL parameters can be passed to force back and forth and return to the default view.

Coldfusion Mobile Page Router

This is a small component that does a simple regex check of the user agent string, then routes to the specified mobile url. There are parameters you can set in the send() function.

@stevereich
stevereich / application.cfc
Last active December 10, 2023 04:58
Commented Custom Application.cfc Template Boilerplate - Coldfusion
component output="false" {
/* **************************** APPLICATION VARIABLES **************************** */
// The application name. If you do not set this variable, or set it to the empty string,
// your CFC applies to the unnamed application scope, which is the ColdFusion J2EE servlet
// context.
THIS.name = "foo";
// Life span, as a real number of days, of the application, including all Application scope variables.
THIS.applicationTimeout = createTimeSpan(0, 1, 0, 0);
@stevereich
stevereich / 0_reuse_code.js
Created May 22, 2016 00:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stevereich
stevereich / EventMonitor.js
Created April 8, 2016 21:28 — forked from livingston/EventMonitor.js
Element event monitor, similar to Web Inspector's `monitorEvents`
(function (global) {
if ( !global.Event && !('keys' in Object) && !('bind' in Function) ) { return }
var eventProto = Event.prototype,
EVENTS = {
'mouse': [ 'click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout', 'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'drop'],
'key': [ 'keydown', 'keypress', 'keyup', 'input'],
'res': [ 'load', 'unload', 'beforeunload', 'abort', 'error', 'resize', 'scroll', 'readystatechange' ],
'form': [ 'select', 'change', 'submit', 'reset', 'focus', 'blur' ],
'ui': [ 'DOMFocusIn', 'DOMFocusOut', 'DOMActivate', 'DOMCharacterDataModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMSubtreeModified' ],
@stevereich
stevereich / rt.cfm
Created January 26, 2016 13:39
Responsive Text CSS with Coldfusion
<cfscript>
// serve content as mime type css
getPageContext().getResponse().setcontenttype('text/css;charset=utf-8');
// supress whitespace with cfoutputonly
setting enablecfoutputonly="true";
// example of url varialbe call: /rt.cfm?height=1.25&weight=bold
// structure of default values, if not received in url
variables.baseSize = {
lineHeight = (structkeyexists(url,'size')) ? url.height : 1.5,
fontWeight = (structkeyexists(url,'size')) ? url.weight : 'normal'
@stevereich
stevereich / bosskey.ahk
Created December 14, 2015 23:04
Boss Key Autohotkey Script - Minimize or Lock Windows with one click on tray icon
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Auto Execute Section Starts Here;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Allow only one instance to run
#SingleInstance force
#Persistent
;Set tray tip and tray menu
@stevereich
stevereich / callback_component.cfc
Created November 12, 2015 16:34
This is an example of using closures and callback functions with Coldfusion or Railo. This will probably bend your mind a little bit!
component output='false' {
// init component
public callback_component function init(){
return this;
};
// this function implicitly takes 2 named arguments. In this case, the arguments scope
// can be treated as an object with name value pairs or an array with the index being
// equal to the position they are expected. This was probably part of the thinking when
// Jeremy and JJ Allaire decided not to use a zero index way back when...
@stevereich
stevereich / getQuery.cfc
Last active August 28, 2015 04:48
Coldfusion query function to run and convert any SQL select query to json format, a struct, an array, or return as a query object. includes error checking, comments, supports cfqueryparams, and setting the Content-Type header for returning application/json.
component output="false" {
public getQuery function init(required string dsn){
variables.dsn = arguments.dsn;
return this;
}
// arg.sql String (required) - A SQL select statement to query
// arg.contentType Array (optional) - Array of obj with sqp query params having the keys name, value, and type.
// arg.label String (optional) - The label for the return (only applies if returnType is 'json'). Default is 'queryData'
@stevereich
stevereich / sortHexColors.cfm
Created July 27, 2015 05:05
This Coldfusion function takes an array of hex colors and sorts them from light to dark.
<cfscript>
private Array function sortHexColors(required Array colorArray) {
var valArray = [];
var sortArray = [];
for(var i=1;i<=arraylen(arguments.colorArray);i++) {
var color = replacenocase(arguments.colorArray[i], '##', '', 'ALL');
if(len(color) == 6) {
var strRed = mid(color, 1, 2);
var strGreen = mid(color, 3, 2);
var strBlue = mid(color, 5, 2);