Skip to content

Instantly share code, notes, and snippets.

View honzahommer's full-sized avatar
🎯
Focusing

Honza Hommer honzahommer

🎯
Focusing
View GitHub Profile
@kenji4569
kenji4569 / ulid_converter.sql
Last active March 23, 2024 13:48
ULID (26 characters in Crockford's base32) conversion for MySQL function
# Define ULID_DECODE and ULID_ENCODE which convert a ulid string to a binary and vice versa.
delimiter //
DROP FUNCTION IF EXISTS ULID_DECODE//
CREATE FUNCTION ULID_DECODE (s CHAR(26)) RETURNS BINARY(16) DETERMINISTIC
BEGIN
DECLARE s_base32 CHAR(26);
SET s_base32 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(s), 'J', 'I'), 'K', 'J'), 'M', 'K'), 'N', 'L'), 'P', 'M'), 'Q', 'N'), 'R', 'O'), 'S', 'P'), 'T', 'Q'), 'V', 'R'), 'W', 'S'), 'X', 'T'), 'Y', 'U'), 'Z', 'V');
RETURN UNHEX(CONCAT(LPAD(CONV(SUBSTRING(s_base32, 1, 2), 32, 16), 2, '0'), LPAD(CONV(SUBSTRING(s_base32, 3, 12), 32, 16), 15, '0'), LPAD(CONV(SUBSTRING(s_base32, 15, 12), 32, 16), 15, '0')));
END//
@robocoder
robocoder / decode.php
Last active December 2, 2023 04:25
PHP Decoding MySQL's .mylogin.cnf
<?php // tested with PHP 8.0.11
$start = microtime(true);
const LOGIN_KEY_LEN = 20;
const MY_LOGIN_HEADER_LEN = 24;
const MAX_CIPHER_STORE_LEN = 4;
$raw = file_get_contents(__DIR__ . '/mylogin.cnf');
$fp = 4; // skip null bytes
@peterdemartini
peterdemartini / command.sh
Last active April 28, 2024 02:42
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 6, 2024 08:45
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@AlexAvlonitis
AlexAvlonitis / cisco_backup.pl
Last active April 18, 2020 23:46
Auto backup cisco switches
# https://github.com/alexavlonitis
# to use this script run perl cisco_backup.pl "cisco enable password" #
use Net::SSH2;
use Net::Telnet::Cisco;
use warnings;
use strict;
my $user = "username"; #username of your switches
my $password = $ARGV[0]; #argument for the password
@visnup
visnup / listenOnPortOrSocketFile.js
Last active May 17, 2019 11:57
Listen on a TCP port or a UNIX socket file in node.js. Handle EADDRINUSE for the socket file by deleting it and re-listening.
var fs = require('fs')
, net = require('net')
, http = require('http')
, port = process.env.PORT;
var app = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
@dynax60
dynax60 / cisco-backup.pl
Created May 6, 2010 04:24
Cisco backup
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use YAML;
use FindBin qw/$Bin/;
use Net::Telnet::Cisco;
++$|;
umask 012;
$0 =~ s{.*/}{};