Last active
February 8, 2018 22:35
-
-
Save jweaver/70f42c91b00f20b5b31bee2828ccef2c to your computer and use it in GitHub Desktop.
Emacs function to insert a random UUID on-demand.From http://ergoemacs.org/emacs/elisp_generate_uuid.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(random t) | |
(defun insert-random-uuid () | |
"Insert a random UUID. | |
Example of a UUID: 1df63142-a513-c850-31a3-535fc3520c3d | |
WARNING: this is a simple implementation. The chance of generating the same UUID is much higher than a robust algorithm.." | |
(interactive) | |
(insert | |
(format "%04x%04x-%04x-%04x-%04x-%06x%06x" | |
(random (expt 16 4)) | |
(random (expt 16 4)) | |
(random (expt 16 4)) | |
(random (expt 16 4)) | |
(random (expt 16 4)) | |
(random (expt 16 6)) | |
(random (expt 16 6)) ) ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment