boxshadow
boxshadow
Reputation Top 1%
Steve Reich
Full stack. Full tilt
16 Snippets  (50th place)
Published
1 Channel
Created
5 Channels
Following
363 points  (85th place)
Reputation
Top 10% Publisher
Serious Code Generator
Senior Code Generator
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Master Autobiographer
Senior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by boxshadow

public by stevereich  1340  0  3  0

Responsive Text CSS with Coldfusion

Responsive Text CSS with Coldfusion: rt.cfm
<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'
    };
    private string function rt(required numeric variableMultiplier,required numeric maxMultiplier){
        var reponsiveText = '';
        savecontent variable = 'reponsiveText' {
            writeoutput("font-size: #numberformat(arguments.variableMultiplier/arguments.maxMultiplier,'9.99')#rem;");
            writeoutput(chr(10)&chr(9));
            writeoutput("line-height: #numberformat((variables.baseSize.lineHeight*arguments.variableMultiplier)/arguments.maxMultiplier,'9.99')#rem;");
        }
        return reponsiveText;
    }
</cfscript>
<cfoutput>
.rt {
    font-weight: #variables.baseSize.fontWeight#;
}
@media only screen and (min-width: 360px) {
    .rt {
        #rt(1.2,1.68)#
    }
}
@media only screen and (min-width: 390px) {
    .rt {
        #rt(1.224,1.68)#
    }
}
@media only screen and (min-width: 420px) {
    .rt {
        #rt(1.248,1.68)#
    }
}
@media only screen and (min-width: 450px) {
    .rt {
        #rt(1.272,1.68)#
    }
}
@media only screen and (min-width: 480px) {
    .rt {
        #rt(1.296,1.68)#
    }
}
@media only screen and (min-width: 510px) {
    .rt {
        #rt(1.32,1.68)#
    }
}
@media only screen and (min-width: 540px) {
    .rt {
        #rt(1.344,1.68)#
    }
}
@media only screen and (min-width: 570px) {
    .rt {
        #rt(1.368,1.68)#
    }
}
@media only screen and (min-width: 600px) {
    .rt {
        #rt(1.392,1.68)#
    }
}
@media only screen and (min-width: 630px) {
    .rt {
        #rt(1.416,1.68)#
    }
}
@media only screen and (min-width: 660px) {
    .rt {
        #rt(1.44,1.68)#
    }
}
@media only screen and (min-width: 690px) {
    .rt {
        #rt(1.464,1.68)#
    }
}
@media only screen and (min-width: 720px) {
    .rt {
        #rt(1.488,1.68)#
    }
}
@media only screen and (min-width: 750px) {
    .rt {
        #rt(1.512,1.68)#
    }
}
@media only screen and (min-width: 780px) {
    .rt {
        #rt(1.536,1.68)#
    }
}
@media only screen and (min-width: 810px) {
    .rt {
        #rt(1.56,1.68)#
    }
}
@media only screen and (min-width: 840px) {
    .rt {
        #rt(1.584,1.68)#
    }
}
@media only screen and (min-width: 870px) {
    .rt {
        #rt(1.608,1.68)#
    }
}
@media only screen and (min-width: 900px) {
    .rt {
        #rt(1.632,1.68)#
    }
}
@media only screen and (min-width: 930px) {
    .rt {
        #rt(1.656,1.68)#
    }
}
@media only screen and (min-width: 960px) {
    .rt {
        #rt(1.68,1.68)#
    }
}
@media only screen and (max-width: 360px) {
    .rt {
        #rt(1.2,1.68)#
    }
}
</cfoutput>

;

public by Vadym Prosianiuk  1448  8  3  0

Element event monitor, similar to Web Inspector's `monitorEvents`

Element event monitor, similar to Web Inspector's `monitorEvents`: EventMonitor.js
(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' ],
			'other': [ 'copy', 'cut', 'paste' ]
		},
		ALL_EVENTS = [],
		PHASES = [ '', 'CAPTURING_PHASE', 'AT_TARGET', 'BUBBLING_PHASE' ],
		logEvent = function ( evt ) {
			console.log(evt.type, evt, PHASES[evt.eventPhase]);
		},

		bindEvents = function (eventName) {
			unbindEvents(eventName);

			this.addEventListener( eventName, logEvent, false);
		},

		unbindEvents = function (eventName) {
			this.removeEventListener( eventName, logEvent, false);
		};
	Object.keys(EVENTS).forEach(function ( curr ) { ALL_EVENTS = ALL_EVENTS.concat(EVENTS[curr]); });
	
	global.EventMonitor = {
		start: function ( elm, eventType ) {
			var binder = bindEvents.bind(elm);

			if(!eventType) {
				ALL_EVENTS.forEach( binder );
			} else if(eventType in EVENTS) {
				EVENTS[eventType].forEach( binder );
			} else {
				binder(eventType);
			}
		},
		stop: function ( elm, eventType ) {
			var unbinder = unbindEvents.bind(elm);

			if(!eventType) {
				ALL_EVENTS.forEach( unbinder );
			} else if(eventType in EVENTS) {
				EVENTS[eventType].forEach( unbinder );
			} else {
				unbinder(eventType);
			}
		}
	};
}(window));

;

public by stevereich  2270  3  3  0

Boss Key Autohotkey Script - Minimize or Lock Windows with one click on tray icon

Boss Key Autohotkey Script - Minimize or Lock Windows with one click on tray icon: bosskey.ahk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Auto Execute Section Starts Here;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Allow only one instance to run
#SingleInstance force
#Persistent

;Set tray tip and tray menu

Menu, MySubmenu, Add, Minimize Windows, setDefaultAction 
Menu, MySubmenu, Add, Lock Workstation, setDefaultAction

Menu, Tray, NoStandard
Menu, Tray, Tip, Windows Key.
Menu, Tray, Add, Execute, launchDefault
Menu, Tray, Add ;draw a line
Menu, Tray, Add, Set Default Action, :MySubmenu
Menu, Tray, Add, Run on Startup`?, startUpReg
Menu, Tray, Add, Exit, exitMe
Menu, Tray, Default,  Execute
Menu, Tray, Click, 1

defaultBossAction := 0

; set default boss key action
RegRead, setDefault, HKCU, SOFTWARE\BossKey, defaultAction
if (ErrorLevel <> 1) {
	if (setDefault = "boss") {
		RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss
		Menu, MySubmenu, Check, Minimize Windows
		Menu, MySubmenu, UnCheck, Lock Workstation
		defaultBossAction := 0
	}
	else if (setDefault = "lock") {
		RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, lock
		Menu, MySubmenu, UnCheck, Minimize Windows
		Menu, MySubmenu, Check, Lock Workstation
		defaultBossAction := 1
	}
}
else{
	RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss
	Menu, MySubmenu, Check, Minimize Windows
	Menu, MySubmenu, UnCheck, Lock Workstation
}

; check menu status of start up option
RegRead, startUp, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey
if (ErrorLevel <> 1) {
	Menu, Tray, Check, Run on Startup`?
}

return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Scripts;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;set registry key to run at startup
startUpReg:
RegRead, startUp, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey
if ErrorLevel {
	RegWrite, REG_SZ, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey, %A_ScriptFullPath%
	Menu, Tray, Check, %A_ThisMenuItem%
}
else{
	RegDelete, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, BossKey
	if errorlevel {
		reload
	}
	Menu, Tray, Uncheck, %A_ThisMenuItem%
}

setDefaultAction:
	intent = %A_ThisMenuItem%
	if(intent = "Minimize Windows"){
		RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, boss
		Menu, MySubmenu, Check, Minimize Windows
		Menu, MySubmenu, UnCheck, Lock Workstation
		defaultBossAction := 0
	}
	else if(intent = "Lock Workstation"){
		RegWrite, REG_SZ, HKCU, SOFTWARE\BossKey, defaultAction, lock
		Menu, MySubmenu, UnCheck, Minimize Windows
		Menu, MySubmenu, Check, Lock Workstation
		defaultBossAction := 1
	}
return

launchDefault:
if(defaultBossAction = 1){
	DllCall("LockWorkStation")
	return
}
else{
	send, #d
	return
}


exitMe:
sayBye()
return


sayBye(){
	ExitApp
}

ExitApp

;

public by stevereich  1386  0  3  0

This Coldfusion function takes an array of hex colors and sorts them from light to dark.

This Coldfusion function takes an array of hex colors and sorts them from light to dark.: sortHexColors.cfm
<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);
				// this formula comes from https://en.wikipedia.org/wiki/HSL_and_HSV
				var retVal = (0.21 * inputbaseN(strRed, 16)) + (0.72 * inputbaseN(strGreen, 16)) + (0.07 * inputbaseN(strBlue, 16));
				var tempObj = {};
					tempObj['###color#'] = retVal;
					arrayappend(sortArray,tempObj);
					arrayappend(valArray,retVal);
			}
		}
		arraysort(valArray,'numeric','desc');
		var returnArray = [];
		for(var ii=1;ii<=arraylen(valArray);ii++){
			for(var j=1;j<=arraylen(sortArray);j++){
				for(key in sortArray[j]){
					if(sortArray[j][key] == valArray[ii]){
						arrayappend(returnArray,key);
						continue;
					}
				}
			}
		
		}
		return returnArray;
	}
	variables.unsortedColors = ['##2A2A2A','##777777','##373737','##b7b7b7','##333333','##505050','##3C3C3C','##d0d0d0','##7f7f7f','##323232'];
	variables.sortedColors = sortHexColors(variables.unsortedColors);
	
	writeoutput("<div style='padding:0;margin:0;width:"&arraylen(variables.unsortedColors)*100&"px;height:100px'>");
		for(i=1;i<=arraylen(variables.unsortedColors);i++){		
			writeoutput("<div class='colorBox' style='padding:0;margin:0;height:100px;width:100px;display:inline-block;position:relative;background-color:#variables.unsortedColors[i]#'></div>");
		};
		for(ii=1;ii<=arraylen(variables.sortedColors);ii++){
			writeoutput("<div class='colorBox' style='padding:0;margin:0;height:100px;width:100px;display:inline-block;position:relative;background-color:#variables.sortedColors[ii]#'></div>");
		};
	writeoutput("</div>");
</cfscript>	

;

public by Steve Reich  2070  0  3  0

This file will enable/disable the Windows built-in administrator account. This account is disabled by default, but is sometimes needed in order to have certain permissions. Be sure you run this file as administrator or assign the appropriate permission...

This file will enable/disable the Windows built-in administrator account. This account is disabled by default, but is sometimes needed in order to have certain permissions. Be sure you run this file as administrator or assign the appropriate permissions to execute it.: toggleAdministratorAccount.bat
:: This will enable/disable the Windows built-in administrator account.
:: Run this file as "Run as administrator", and then at the prompt, enter
:: one of the following options: y | n | yes | no ... the /i flag makes the
:: options case insensitive, so either capital or lower case is accepted. 
:: Enter any other value, or no value at all, will return an error message
:: and not run the command.
ECHO OFF
SETLOCAL
SET /P doAdmin="Enable Windows built-in administrator account? (y/n) "
IF /i "%doAdmin%" EQU "n" SET doAdmin=no
IF /i "%doAdmin%" EQU "y" SET doAdmin=yes
IF NOT DEFINED doAdmin (
	ECHO No action was taken. User input is required.
	PAUSE
	EXIT
) ELSE (
	IF /i "%doAdmin%" EQU "no" (
		SET domainLabel=disabled
		net user administrator /active:%doAdmin%
		GOTO runAdmin
	)
	IF /i "%doAdmin%" EQU "yes" (
		SET domainLabel=enabled
		net user administrator /active:%doAdmin%
		GOTO runAdmin
	)
	ECHO No action was taken. "%doAdmin%" is not a valid option.
	PAUSE
	EXIT
)
:runAdmin
	ECHO The built in administrator has been %domainLabel%
	PAUSE
ENDLOCAL
EXIT

;