Skip to content

Instantly share code, notes, and snippets.

@erlingpaulsen
erlingpaulsen / generateThreadIndex.py
Last active October 8, 2019 10:20
Seeded thread index generator for grouping Microsoft Outlook emails into converations
import uuid
import random
import base64
def generateThreadIndex(seed):
# Generates a Microsoft Outlook thread index based on a seed.
# Add the thread index with the 'Thread-Index' header when sending an email to group the emails into conversations
rd = random.Random()
rd.seed(seed)
@erlingpaulsen
erlingpaulsen / coinbase_profit_loss.py
Created January 15, 2021 12:18
Python script for connecting to your Coinbase account through the API. Used to compute and plot the balance and cost per wallet and in total, in addition to calculate the total profit/loss. Will calculate to your native currency.
import json, hmac, hashlib, time, requests
import numpy as np
from requests.auth import AuthBase
import matplotlib.pyplot as plt
# Name of account holder (only for displaying)
USER = 'My name'
# API key and secret. Create these in your Coinbase account with all read permissions selected for all accounts
API_KEY = 'xxx'
@erlingpaulsen
erlingpaulsen / storj_disk_check.sh
Last active June 14, 2021 10:32
Bash script for checking disk health for a Storj Storagenode. The disk is automatically remounted if the error "Transport endpoint is not connected" is encountered. Then the Storj Storagenode docker service is checked and started after the disk is mounted.
#!/bin/bash
# Add to crontab for periodic check:
# Storj disk check every 4 hours - remounts and restarts storagenode if disk is unavailable
# 0 */4 * * * /bin/bash /root/scripts/storj_disk_check.sh
# Variables
SCRIPT_NAME=`basename "$0"`
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
LOG_FILE="$SCRIPT_DIR/$(echo $SCRIPT_NAME | cut -d'.' -f1).log"
@erlingpaulsen
erlingpaulsen / powershell-python.py
Last active February 1, 2022 11:15
Running PowerShell commands in Python - Three simple examples
import subprocess
import datetime
# PARAMETERS
powershell_exe = 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe'
def custom_print(severity, message):
print('{0} - [{1}] - {2}'.format(datetime.datetime.now(), severity, message))
def createFolder(path, name):