Skip to content

Instantly share code, notes, and snippets.

View nickovs's full-sized avatar

Nicko van Someren nickovs

  • Absolute Software
  • Boulder, CO, USA
View GitHub Profile
@nickovs
nickovs / aws-session.py
Created November 28, 2018 23:47
Easy sessions credentials for Amazon Web Services when multi-factor authentication is required.
#!/usr/bin/env python3
"""Fetch and print temporary session credentials with MFA
To use this tool first put the ARN of your MFA access token into a
file called .aws_token_id in your home directory and ensure that the
tool is on your path. Then execute the command:
eval `aws-session`
You will be promoted to enter your current MFA token value. After this
@nickovs
nickovs / pathprefix.py
Created April 4, 2018 00:45
Easier handling of file paths in Python
# A Python (3) class for more compact path handling.
#
# If you find yourself calling os.path.join() with the same first parameter
# over and over again it can get rather tedious. Instead you can now go:
#
# path = PathPrefix("/some/path")
# file1 = path / "file1"
# sub_file = path / "subdir" / "file2"
class PathPrefix(str):