Skip to content

Instantly share code, notes, and snippets.

View pabloogc's full-sized avatar

Pablo Orgaz pabloogc

  • Toledo, Spain
View GitHub Profile
#IfWinActive, ahk_class POEWindowClass
active:=true
`::
active:=!active
return
$2::
if(!active) {
send, 2
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@pabloogc
pabloogc / uuid7.ts
Last active May 9, 2022 19:40
Function for generating uuid v7 on Postgres as defined in the RFC https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format#section-5.2
export function uuid7(): UUID {
// Simple implementation using built in gen_random_uuid()
// gen_random_uuid(): '4047541d-a7bf-4d8a-87c2-585cab7ef52e'
// strip random head and version: '_______________d8a-87c2-585cab7ef52e'
// concatenate epoch and version 7: 'xxxxxxxx-xxxx-7d8a-87c2-585cab7ef52e
const v4 = uuid.v4().slice(8 + 4 + 2 + 1, 36);
const date = Date.now().toString(16).padStart(12, '0');
return date.slice(0, 8) + '-' + date.slice(8, 8 + 5) + '-7' + v4;
}