Skip to content

Instantly share code, notes, and snippets.

View BrianLeishman's full-sized avatar
🐢

Brian Leishman BrianLeishman

🐢
  • Stumpyinc
  • Orlando
View GitHub Profile
@BrianLeishman
BrianLeishman / bid.c
Last active December 20, 2017 14:45
BID for MySQL (9-byte, time based ID generator)
/*
* Copyright (c) 2017, Brian Leishman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@BrianLeishman
BrianLeishman / unhex_sha3.c
Last active February 27, 2018 20:26
MySQL UDF for generating SHA3 hashes without hex encoding (much faster)
/*
* Copyright (c) 2018, brian
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
@BrianLeishman
BrianLeishman / sha3.c
Last active February 27, 2018 20:27
MySQL UDF for sha3 hash generation
/*
* Copyright (c) 2018, brian
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
@BrianLeishman
BrianLeishman / imap.php
Last active March 1, 2018 22:53
Pure PHP, basic IMAP implementation
<?php
/*
* Copyright (c) 2018, brian
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
@BrianLeishman
BrianLeishman / b64u.c
Last active July 3, 2018 20:52
Base64 encoding (URL style, with "-_" instead of "+/" and no "=") as a MySQL UDF
/*
* Copyright (c) 2017, Brian Leishman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@BrianLeishman
BrianLeishman / bid2.c
Last active July 12, 2018 15:40
MySQL UDF for an 8-byte time & environment based ID
/*
* Copyright (c) 2018, Brian Leishman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
@BrianLeishman
BrianLeishman / udf.go
Created April 16, 2018 22:18
MySQL UDF written in Go (Golang) instead of C
package main
// #include <stdio.h>
// #include <sys/types.h>
// #include <sys/stat.h>
// #include <stdlib.h>
// #include <string.h>
// #include <mysql.h>
// #cgo CFLAGS: -D ENVIRONMENT=0 -I/usr/include/mysql -fno-omit-frame-pointer
import "C"
@BrianLeishman
BrianLeishman / unhtml.c
Created February 4, 2018 16:37
MySQL `unhtml` UDF for converting HTML to plain text, removing tags and converting HTML entities
/*
* Copyright (c) 2018, brian
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,