Skip to content

Instantly share code, notes, and snippets.

Lorenz Lo Sauer lsauer

Block or report user

Report or block lsauer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lsauer
lsauer / html-hex-color-name-aliases.js
Created Oct 6, 2014
JavaScript: Hex Color to Name Alias - Table of Browser Color Namespaces / HTML Color Aliases
View html-hex-color-name-aliases.js
var htmlColorsMap = (function(scope){
var htmlColorsMap = {};
var _colorAliases = [
'#F0F8FF aliceblue'
, '#FAEBD7 antiquewhite'
, '#00FFFF aqua'
, '#7FFFD4 aquamarine'
, '#F0FFFF azure'
, '#F5F5DC beige'
, '#FFE4C4 bisque'
@lsauer
lsauer / exception_handler.js
Created Sep 23, 2014
Javascript: Lean Exception handler
View exception_handler.js
/**
* lsauer, 2013
* Lean handler for exception reporting; stdout is set by default to console.log
* @param {exc} exc an Exception instance of Error, containing a message and stack property
* @param {exc} stdOut A variadic function for error reporting. By default: console.log
* @return undefined
*/
var exceptionHandler = function(exc, stdOut){
var stdOut = stdOut || function() { console.log.apply(console, arguments) };
if(stdOut instanceof Function){
@lsauer
lsauer / a-invoke-a-bound-function-a-fixed-number-of-times-intervalCallNtimes.js
Created Aug 26, 2014
Custom scoped setInterval and repeat for n-times: intervalCallNtimes binds a function to a declared scope and invokes it after 'tm' milliseconds for n-times
View a-invoke-a-bound-function-a-fixed-number-of-times-intervalCallNtimes.js
//lsauer.com, 2012 lo sauer
//description: intervalCallNtimes; counter after nth time clearinterval; bind a function to a certain scope using 'intervalCall'
//requires: intervalCall, see: https://gist.github.com/lsauer/cf70e65c208cc311ce97
//@param fntimes: an integer-Number or function to control the number of invocations of the callback-counter-function:'fntimes'
// fntimes is passed an integer Number-counter, starting at 1;
//@param fn: the function to be invoked
//@param tm: timeout in milliseconds
//@param scope: scope in which the function should be invoked
//-> examples are provided below
function intervalCallNtimes(fntimes, fn, tm, scope){
@lsauer
lsauer / simulate-trigger-keyboard-key-events.js
Created Aug 26, 2014
JavaScript: Simulate Keyboard Events
View simulate-trigger-keyboard-key-events.js
//lsauer.com, 2012; rev. 2014 by lo sauer
//see also: http://stackoverflow.com/questions/596481/simulate-javascript-key-events/19883789#19883789
//description: trigger handlers attached to DOM elements, which listen to the type 'KeyboardEvent'
//@param s: A single keyboard-character passed as a string e.g. "\n", "a",...
//[@param fncb]:callback function which is passed a boolean event-state (OK=true/Cancelled=false)
var doKeyEvent = function(s /*single char*/, fncb /*callback function, with handler state*/) {
var evt = document.createEvent('KeyboardEvent');
evt.initKeyEvent ('keypress', true, true, window,0, 0, 0, 0, 0, s.charCodeAt(0))
var cncld = !document.getElementsByTagName('body')[0].dispatchEvent(evt);
@lsauer
lsauer / a-transform-change-switch-tag.js
Created Aug 25, 2014
JavaScript-transformTag: switch/change the HTML DOM tag type
View a-transform-change-switch-tag.js
//lsauer.com, 2012; rev. 2014 by lo sauer
//description: transformTag fully replaces a node by a different Tag, and re-attaches all children to the newly formed Tag
// Any desired EventHandlers must be re-attached manually
//@param tagIdOrElem: an HTMLElement Id-Name or an instance of any HTMLElement
//[@param tagType]: the HTML Tag Type. Default is 'span' (HTMLSpanElement)
function transformTag(tagIdOrElem, tagType){
var elem = (tagIdOrElem instanceof HTMLElement) ? tagIdOrElem : document.getElementById(tagIdOrElem);
if(!elem || !(elem instanceof HTMLElement))return;
var children = elem.childNodes;
@lsauer
lsauer / custom-scoped-setInterval-JavaScript.js
Created Aug 25, 2014
custom-scoped-setInterval-JavaScript.js: intervalCall binds a function to a declared scope and invokes it after 'tm' milliseconds
View custom-scoped-setInterval-JavaScript.js
//lsauer.com, 2012 lo sauer
//description: intervalCall binds a function to a declared scope and invokes it after 'tm' milliseconds
//@param scope: scope in which the function should be invoked
//@param fn: the function to be invoked
//@param tm: timeout in milliseconds
//[@param fntimes]: Optional. A function to control the number of invocations of 'fn', i.e. to declare events / triggers based on the invocation-count
// fntimes is passed an integer Number-counter, starting at 1;
function intervalCall(scope, fn, tm, fntimes)
{
@lsauer
lsauer / austria-citylist-letter-abbreviation.json
Last active Aug 29, 2015
JSON: Holidays in Austria's provinces - Austrian provinces ( Österreichische Feiertage )
View austria-citylist-letter-abbreviation.json
{
"B": "Burgenland",
"K": "Kärnten",
"N": "Niederösterreich",
"O": "Oberöstereich",
"S": "Salzburg",
"St": "Steiermark",
"T": "Tirol",
"V": "Vorarlberg",
"W": "Wien"
@lsauer
lsauer / 1-merging-or-extending-arrays-in-csharp.cs
Created Dec 11, 2013
C#: Merging,Appending, Extending two arrays in .NET (csharp, mono)
View 1-merging-or-extending-arrays-in-csharp.cs
//www.technical-programming.com, lorenz lo sauer, 2013
//description: extending C# for fast and easy string extension
//note: part of a larger Open-Source Project-Codebase
//see: http://stackoverflow.com/questions/59217/merging-two-arrays-in-net
//resides in IEnumerableStringExtensions.cs
public static class IEnumerableStringExtensions
{
public static IEnumerable<string> Append(this string[] arrayInitial, object arrayToAppend)
{
@lsauer
lsauer / tsql_update_field_when_conditional_value_is_set_trigger.sql
Created Dec 8, 2013
MS-SQL Server/TSQL Trigger: Update a field only when a specific value is set, otherwise set a different condition
View tsql_update_field_when_conditional_value_is_set_trigger.sql
/*www.technical-programming.com, lo sauer 2013
Target: MS/Microsoft SQL Server 2005 or higher
description: Upon update, the rows's timestamp field is set to the current unix-timestamp,
unless the timestamp is NULL or Empty. If the timestamp field is supplied in the update
statement, the supplied value is set as is.
The tstamp field is defined as:
[__unixtimestamp] INT NULL
The primary key is defined as:
[ID] INT IDENTITY (1, 1) NOT NULL
@lsauer
lsauer / 1backup_and_export_or_restore_and_import_bak_database.sql
Created Dec 6, 2013
Automated Microsoft MS SQL-Server / TSQL: backup and export or restore and import .bak Database backup files for attachment
View 1backup_and_export_or_restore_and_import_bak_database.sql
/*www.technical-programming.com, lo sauer 2013
* description: Step by step process to load or save .bak Database backup files
* credits: RameshVel,Tim Partridge for the @fileListTable; StackOverflow
*/
/* Export/Save a Database Backup
See: http://technet.microsoft.com/en-us/library/ms186865.aspx
*/
BACKUP DATABASE logicalnameofthedatabase TO DISK = 'c:\physicalnameofthedatabase.bak'
You can’t perform that action at this time.