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 / gist:4086997
Created Nov 16, 2012
mp3 Joiner / Join mp3 files
View gist:4086997
#easy method of joining two mp3's [ 2012 - lo sauer]
#the result is dirty since it contains the mp3 header and ID-tags, but most mp3 libs play these files without a hassle.
#use the resulting mp3 as input for AAC, Opus,.. conversion.
type file1 file2 > outfile
copy /b file1 + file2 + ... file_n outfile
#Linux, Mac
cat file1 file2 > outfile
lsauer / fuzzy-search.sql
Last active Feb 2, 2020
FullText fuzzy searching in SQL / MySQL
View fuzzy-search.sql
#lo sauer, 2013 -
#Note: In MySQL SUBSTRING, the string-index starts at position 1
SELECT * FROM tablename
WHERE SOUNDEX(tablename_field)
LIKE CONCAT('%',SUBSTRING(SOUNDEX('Fuzti serch derm'),2),'%');
lsauer / kill_process_pid_windows_linux_mac.php
Last active Jan 21, 2020
PHP: kill a process by its process-id/pid in a platform- and library-independent manner
View kill_process_pid_windows_linux_mac.php
#, 2012 lo sauer
# desc: kill a process on Linux, MacOS, Windows without a process-control library
# in the php setup or environment
$kill = function($pid){ return stripos(php_uname('s'), 'win')>-1
? exec("taskkill /F /PID $pid") : exec("kill -9 $pid");
echo $kill(19008);
//> "Successfully terminated...."
lsauer / gist:2757250
Last active Jan 20, 2020
JavaScript : within a string, count the number of occurances of a character / character counting and string-position
View gist:2757250
// 2012
//Answer to:
//There are at least four ways. The best option, which should also be the fastest -owing to the native RegEx engine -, is placed at the top. // is currently down, otherwise I would provide you with performance statistics.
("this is foo bar".match(/o/g)||[]).length
"this is foo bar".split("o").length-1
lsauer / gist:1320437
Created Oct 27, 2011
A list of common HTTP header settings
View gist:1320437
// by jonas john, posted by lo sauer /; PUBLIC DOMAIN
// description: common http headers:
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
// Access forbidden:
lsauer / gist:5196979
Last active Dec 27, 2019
JavaScript List of selected MIME types (JSON)
View gist:5196979
// , lo sauer 2013
//JavaScript List of selected MIME types
//A comprehensive MIME List is available here:
var mimeTypes =
'a' : 'application/octet-stream',
'ai' : 'application/postscript',
'aif' : 'audio/x-aiff',
'aifc' : 'audio/x-aiff',
'aiff' : 'audio/x-aiff',
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
/*, 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:
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
//, 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 / left-flexible-right-fixed.css
Created Feb 5, 2015
css: fixed width column to the right and flexible full-width left-column
View left-flexible-right-fixed.css
/*, 2015 */
.left-flexible-right-fixed .container {
height: auto;
overflow: hidden;
.left-flexible-right-fixed .left-inner{
width: 100%;
.left-flexible-right-fixed .right {
width: 180px;
lsauer / InChi.js
Created Oct 25, 2011
Regular Expressions for validating SMILES, InChi, InChiKey
View InChi.js
// International Chemical Identifier Regex, by lo sauer -
// Morphine InchI:
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1"
// applying an organic character-subset
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..)
You can’t perform that action at this time.