Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Last active June 10, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgriffs/40400ed27ae2f5c365f5 to your computer and use it in GitHub Desktop.
Save kgriffs/40400ed27ae2f5c365f5 to your computer and use it in GitHub Desktop.
A better uuidgen (python)
#!/usr/bin/env python
import sys
import uuid
result = str(uuid.uuid4())
if sys.stdout.isatty():
print(result)
else:
sys.stdout.write(result)
@kgriffs
Copy link
Author

kgriffs commented Jun 10, 2016

Save as /usr/local/bin/uuid4 and make executable.

@kgriffs
Copy link
Author

kgriffs commented Jun 10, 2016

Forces uuid v4 and also handles piping nicely (doesn't output a newline in that case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment