7 ms·
Show HN: Givemeguid.com – CLI/curl friendly GUIDs
- GoblinSlayer 6y agoI will just leave it here: https://www.uuidgenerator.net/api https://www.uuidgenerator.net/api
- huhtenberg 6y agoAnd why would you do that?
- pricechild 6y agoIt looks very relevant and has more features?
- huhtenberg 6y agoWell, yeah, of course. The link itself is fine, it's the remark next to it that I find to be in poor taste and uncalled for.
- deweyair 6y agoInstructions are in the headers. Query string params for returning multiple GUIDs, and optionally returning JSON.
- nonoesp 6y ago- https://www.givemeguid.com/?json=1 https://www.givemeguid.com/?json=1 - https://www.givemeguid.com/?number=5 https://www.givemeguid.com/?number=5
- tkfu 6y agoI'm having trouble imagining who would want to use this. What's the environment where you would have curl and a need for generating UUIDs, but wouldn't have access to uuidgen or similar?
- p4bl0 6y agoThis, and also, are GUID that pose a problem with CLI/curl really a thing?
- MrGilbert 6y agoMaybe a JS App which is made completely out of third party APIs, without anything self-hosted? Not discussing wether this is a good idea or not, though... I was surprised to see that there is no "built-in" mechanism in JS to generate a GUID. As a C# dev, I'm used to Guid.NewGuid()
- hombre_fatal 6y agoWhy would you make an http request if you can just google a 3-line JS solution? You're just generating a large random number and formatting it as a UUID. https://gist.github.com/jed/982883 https://gist.github.com/jed/982883 If you google "generate uuid javascript" you can find approaches from Math.random to node/browser `crypto` module to shelling out OS random. One of the main benefits of guid generation is that you don't need to synchronize with anything to generate a unique ID, so it's weird to incur an http request, especially to someone else's service. At that point you might as well just phone home to your own service.
- sk0g 6y agoUUIDs also have a hashed namespace in them, don't they? Not sure if that version implements them.
- hombre_fatal 6y agoOnly uuid v3/v5. Anything is possible if that's what you want. But 128 (or 122) bits of random are usually what you want when you think of guid. Most people format 128-bit random numbers into a UUID just so it's obvious at a glance what it is: a guid. Even if it's not technically a UUIDv4 because it doesn't have the magic bits.
- tatersolid 6y ago
- redact207 6y agoThanks I'll probably use this. I often want to get a static uuid - usually for adding as static data in a test.
- speedgoose 6y agoIf you use Linux: cat /proc/sys/kernel/random/uuid
- aranw 6y agoThis doesn't work on macOS :( cat: /proc/sys/kernel/random/uuid: No such file or directory
- deleted 6y ago[deleted]
- speedgoose 6y agoI edited, it's a Linux feature.
- shean_massey 6y agoTIL something new, thanks!
- thinkingkong 6y agoIf you need a unique identifier on the command line there are a few ways to do it. uuidgen is one. My personal favorite is this snippet. $ id=$(openssl rand 1000 | openssl sha1) && printf "%s${id:0:8}\n"
- mormegil 6y agoWhy would you want to hash random bytes? The only thing you could theoretically achieve by that would be decreasing entropy. Just do openssl rand -hex 20 (or any other number of bytes as needed, or -base64 for another encoding).
- aranw 6y agoNice! I think this will still have a use and is a nice addition to add another alternative way to generate uuids I use the following alias to generate uuids function uuid() { uuidgen | tr "[:upper:]" "[:lower:]" | tr -d "\n\r" } I then pair it with pbcopy on the mac uuidgen | pbcopy
- jcelerier 6y agoone of my most used non-trivial shell commands must be uuidgen | awk '{ printf "\"" $1 "\"" }' | xclip -selection clipboard
- politelemon 6y agoI remember several years ago using https://newguid.com https://newguid.com which was pretty much the same thing - no page furniture, just the new guid. Sadly the domain seems to be on sale now! There's also https://www.newguid.org/ https://www.newguid.org/
- berkes 6y ago> Sadly the domain seems to be on sale now! Which is a perfect example why it is bad to rely on a service like this to generate your IDs. What if I bought it and started emitting predictable IDs? Or non-unique IDs?
- queuep 6y agoThis is what I use to generate guids with autohotkey: ::;guid:: guid := GUID() StringLower, guid, guid Clipboard := guid SendInput,^v return GUID() { format = %A_FormatInteger% ; save original integer format SetFormat Integer, Hex ; for converting bytes to hex VarSetCapacity(A,16) DllCall("rpcrt4\UuidCreate","Str",A) Address := &A Loop 16 { x := 256 + *Address ; get byte in hex, set 17th bit StringTrimLeft x, x, 3 ; remove 0x1 h = %x%%h% ; in memory: LS byte first Address++ } SetFormat Integer, %format% ; restore original format h := SubStr(h,1,8) . "-" . SubStr(h,9,4) . "-" . SubStr(h,13,4) . "-" . SubStr(h,17,4) . "-" . SubStr(h,21,12) return h }
- antiufo 6y agoOr from PowerShell: [Guid]::NewGuid()
- aloisdg 6y agoI made one for fun (and as a QA exercise for my GF): https://aloisdegouvello.gitlab.io/guid/ https://aloisdegouvello.gitlab.io/guid/ GUID as a service. What a time to be alive :)
- patricjansson 6y agoUsage information in response headers, me like :)
- deweyair 6y agoThanks!
- raxxorrax 6y agoIs this just a "random" UUID or does it meet specs of RFC 4122? I have seen countless times when it was just generated as {8}-{4}-{4}-{4}-{12} with complete random numbers. Well, works for most applications...
- plasma 6y agoIf you use Visual Studio, typing the word (with quotes) “nguid” in the code IDE generates one for you.
- deweyair 6y agoI spend a fair amount of my day in Visual Studio and didn't know this, thanks!
- deleted 6y ago[deleted]
- santiagobasulto 6y agoI have uuidgen in my Mac, but also have a tiny alias: alias uuid='python -c "import uuid;print(str(uuid.uuid4()))"'
- deleted 6y ago[deleted]