Skip to content

Instantly share code, notes, and snippets.

View emptyother's full-sized avatar

Tom A. Vibeto emptyother

View GitHub Profile
@emptyother
emptyother / uuid_to_bin.sql
Created December 13, 2017 11:13
Mysql convert Guid to binary
DELIMITER |
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
END
|
@emptyother
emptyother / Guid.ts
Last active July 4, 2023 21:00
GUID class for Typescript
class Guid {
public static newGuid(): Guid {
return new Guid(crypto.randomUUID());
// Old IE supported way:
/*return new Guid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random() * 16 | 0;
const v = (c == 'x') ? r : (r & 0x3 | 0x8);
return v.toString(16);
}));*/
@emptyother
emptyother / Process-Paths.psm1
Last active November 5, 2017 17:25
Powershell template for functions that takes a list of paths or files
#requires -version 5
<#
.Synopsis
Processes a path
.Description
This is a template for creating Powershell functions that processes paths
.Parameter Path
The path(s) to process
.Inputs
System.IO.DirectoryInfo
@emptyother
emptyother / out-notepad.ps1
Last active July 22, 2017 12:00
Pipe powershell data to notepad
Param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
$InputObject
)
begin {
$tempfile = [System.IO.Path]::GetTempFileName();
$collection = @();
}
process {