From caf118f4f6c9d7be971b47740499b5277e3dbbe8 Mon Sep 17 00:00:00 2001 From: vaclavt Date: Tue, 18 Jan 2022 23:47:45 +0100 Subject: [PATCH] changes in tmp dir --- tmp/malformed_program.lsp | 5 ----- tmp/uuid.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) delete mode 100644 tmp/malformed_program.lsp create mode 100644 tmp/uuid.cpp diff --git a/tmp/malformed_program.lsp b/tmp/malformed_program.lsp deleted file mode 100644 index c9fe4f2..0000000 --- a/tmp/malformed_program.lsp +++ /dev/null @@ -1,5 +0,0 @@ -(print -"ahoj" -; this comment is problem -) -(print "lisp") \ No newline at end of file diff --git a/tmp/uuid.cpp b/tmp/uuid.cpp new file mode 100644 index 0000000..1a3cbe0 --- /dev/null +++ b/tmp/uuid.cpp @@ -0,0 +1,34 @@ + +// https://mariusbancila.ro/blog/2018/02/27/stduuid-a-cpp-library-for-universally-unique-identifiers/ + + +// #pragma once + +#include +#include +#include + +std::string get_uuid() { + static std::random_device dev; + static std::mt19937_64 rng(dev()); + + std::uniform_int_distribution dist(0, 15); + const char *v = "0123456789abcdef"; + const bool dash[] = { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0 }; + + std::string res; + res.reserve(40); + for (int i = 0; i < 16; i++) { + if (dash[i]) res += "-"; + res += v[dist(rng)]; + res += v[dist(rng)]; + } + return res; +} + +// g++ uuid_test.cpp +int main() { + auto uuid_str = get_uuid(); + + std::cout << uuid_str << std::endl; +} \ No newline at end of file