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 / 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 / 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 / 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 / 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 / global-scope-finding-setting.js
Created Feb 5, 2015
find and set the globalObject in JavaScript
View global-scope-finding-setting.js
"use strict";
if(!this.hasOwnProperty('globalScope')){
var globalScope;
try {
globalScope = Function('return this')();
}catch(ex){
//extend else-if cases for other globalObject-names as needed...
if(this && this.hasOwnProperty && this.hasOwnProperty('window')){
globalScope = window;
}else{
@lsauer
lsauer / php array merge by value
Created Sep 6, 2011
PHP: Array_merge by value, or array merge by values and keys
View php array merge by value
/**
L. Sauer,2011
license: public domain
http://xhr2.blogspot.com/2011/09/php-arraymerge-by-value-or-array-merge.html
*/
function array_merge_values_explode(){
$args = func_get_args();
$elem = array();
$delim = strlen(end($args))<=2 ? array_pop($args) : ',';
@lsauer
lsauer / gist:1197178
Created Sep 6, 2011
SyntaxHighlighter-script Render Fallback
View gist:1197178
//L.Sauer 2011; Public Domain
//renders code even without SyntaxHighlighter present
//see http://xhr2.blogspot.com/2011/09/alexgorbatchevcom-down-changing.html
//dp is the typical SyntaxHighlighter object;
//use the class 'shFallback' for styling the fallback <pre>-tag
if(typeof dp === 'undefined' ){
(function(){
var els = document.getElementsByTagName('script');
var elClass = null; //or e.g. class 'shFallback'
for(var i in els) {
@lsauer
lsauer / gist:1197340
Created Sep 6, 2011
ANSI C Determine the sign of a variable
View gist:1197340
( a >= 0 && ~a >= 0 )
First statement ensures that the variable is positive, the second ensures that no sign-bit is flipped.
@lsauer
lsauer / gist:1208350
Created Sep 10, 2011
JavaScript: Simple multi-timer for logging performance of an html page
View gist:1208350
function j2timer(e){
window.tdiff || (window.tdiff = []);
window.tdlog || (window.tdlog = []);
window.fnred || (window.fnred = function(a,b){return a-b;});
//toogle statement
if( (tdiff.length+1) % 2){
tdiff.push( Date.now());
return;
}
@lsauer
lsauer / gist:1209992
Created Sep 11, 2011
OnBlur will not fire when changing onFocus to onKeyUp, onKeyPress, onKeyDown,...
View gist:1209992
The following code will do just what you would expect (a css rule for the element's id is applied).
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" />
However when the onClick is changed to onKeyUp, onKeyPress, onKeyDown it will expand but not retract. This is because the element is not marked focused, or because the event order got messed up (in Chrome >12).
Include this.focus();
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.focus(); this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" />
You can’t perform that action at this time.