Skip to content

Instantly share code, notes, and snippets.

import os
import getpass
import boto3
os.environ['AWS_ACCESS_KEY_ID'] = ... # your accounts access key
os.environ['AWS_SECRET_ACCESS_KEY'] = ... # your accounts secret
client = boto3.client("sts")
token = getpass.getpass("Enter MFA token -> ")
# Exchange permanent key/secret for temporary ones
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.ssl_ import create_urllib3_context
# https://gist.github.com/mtigas/952344
# https://github.com/requests/requests/issues/2118
# https://github.com/requests/requests/issues/3774#issuecomment-267871876
class ClientCertificateAdapter(HTTPAdapter):
def init_poolmanager(self, *args, **kwargs):
tree ./node_modules/phantomjs-prebuilt
./node_modules/phantomjs-prebuilt
├── LICENSE.txt
├── bin
│   └── phantomjs
├── install.js
├── lib
│   ├── location.js
│   ├── phantom
│   │   ├── ChangeLog
@rectalogic
rectalogic / pwned.py
Created February 24, 2018 15:25
Simple python pwned password checker for https://haveibeenpwned.com/API/v2#PwnedPasswords
from __future__ import print_function
import getpass
import hashlib
import urllib2
def check_password(password):
sha = hashlib.sha1(password).hexdigest().upper()
sha_prefix = sha[:5]
sha_suffix = sha[5:]
try:
raise Exception("source")
finally:
print "in finally"
try:
raise Exception("in finally")
except Exception:
print "handling exception in finally"
#!/usr/bin/env python
#
# $ cat ~/.bash_history | bash-history-to-zsh-history.py >> ~/.zsh_history
import sys
import time
def main():
timestamp = int(time.time())
class Model(AttrDict):
read_preference = read_preferences.PRIMARY
...
@contextmanager
def read_preference(pref):
try:
prev_pref = Model.read_preference
Model.read_preference = pref
#!/bin/bash
# Copies an entire mongodb collection into an RDS table, skipping existing rows.
MONGOHOST=""
RDS=""
TABLE=""
DB="cureatr"
COLLECTION=""
import gc
from threading import Thread
import boto3
import botocore
def client():
boto3.Session().client("s3")