Skip to content

Instantly share code, notes, and snippets.

Alex Johnstone alexjj

View GitHub Profile
@alexjj
alexjj / docker-compose.yml
Created Nov 29, 2019
Sample docker-compose with Traefik v2.0 and Lets Encrypt
View docker-compose.yml
version: "3.7"
services:
bitwarden:
image: bitwardenrs/server:latest
container_name: bitwarden
volumes:
- /home/alex/docker/bitwarden:/data
restart: unless-stopped
environment:
@alexjj
alexjj / fetch_stock_prices_for_gnucash.py
Created Jan 7, 2019 — forked from rgreen13/fetch_stock_prices_for_gnucash.py
Python script to fetch stock prices for gnucash using http://alphavantage.co/ api. Since Quotes::Finance fetching from Yahoo finance no longer works, it is an alternative.
View fetch_stock_prices_for_gnucash.py
# INSTALL DEPENDENCIES BEFORE RUNNING: pandas, sqlite3, sqlalchemy, requests
# There is one thing you have to do though: gnucash needs to know the price's currency and it needs a guid (unique identifier)
# for this. This guid is unique for each installation, so you need to find yours and assign it to CURRENCY_GUID.
# OR: you can just leave it, and the script will fetch the currency from the last price added
import pandas as pd
import sqlite3
import sqlalchemy
from sqlalchemy import create_engine
import time
View passwordbreakerexcel.vba
Sub PasswordBreaker()
'Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
@alexjj
alexjj / jail.sh
Created Sep 10, 2017 — forked from paulc/jail.conf
FreeBSD ZFS Jail
View jail.sh
#!/bin/sh
[ -z "${DEBUG}" ] || set -x
ZPOOL=${ZPOOL:-zroot}
JAIL_ROOT=${JAIL_ROOT:-/jail}
JAIL_RELEASE=${JAIL_RELEASE:-$(sysctl -n kern.osrelease | sed -e 's/-p[0-9]*$//')}
JAIL_ARCH=${JAIL_ARCH:-$(sysctl -n hw.machine_arch)}
JAIL_DIST=${JAIL_ROOT}/dist/${JAIL_RELEASE}
JAIL_TEMPLATE=${JAIL_ROOT}/template/${JAIL_RELEASE}/root
@alexjj
alexjj / Swap sign in qif
Last active Aug 14, 2016
Switch sign in bank qifs to fix import errors with YNAB
View Swap sign in qif
import sys
def main(argv):
for inFilename in argv:
if not inFilename.endswith('.qif'):
print "Error: expected QIF file"
raw_input("Press enter to get outa here...")
return 1
outFilename = inFilename.replace('.qif', '.negated.qif')
@alexjj
alexjj / bean-report.md
Created Mar 11, 2016
Help output of bean-report
View bean-report.md

Reports

Generated with bean-report FILENAME.beancount {report name}

Reports:

balances,bal,trial:
    Print out the trial balance of accounts matching an expression.
balsheet:
    Print out a balance sheet.
@alexjj
alexjj / convert.sh
Last active Dec 21, 2015
HandbrakeCLI a folder
View convert.sh
#!/bin/bash
#
# Change this to specify a different handbrake preset. You can list them by running: "HandBrakeCLI --preset-list"
#
PRESET="AppleTV 3"
if [ -z "$1" ] ; then
TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
@alexjj
alexjj / ushsbc2ynab.py
Last active Nov 13, 2015
HSBC US .csv to YNAB
View ushsbc2ynab.py
# A simple script to convert csv from us.hsbc.com Money Management Tools website to be readable by YNAB.
# YNAB wants: Date,Payee,Category,Memo,Outflow,Inflow
__author__ = "Alex Johnstone <alexjj@gmail.com>"
#Input file from HSBC US
import_csv = 'ExportData.csv'
#Drop any transaction prior to this date
cutoffdate = '2015-09-01'
View useful_pandas_snippets.py
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@alexjj
alexjj / portsupdate.sh
Created Jul 28, 2015
FreeBSD Ports update check script
View portsupdate.sh
#!/bin/sh
/usr/sbin/portsnap fetch update && \
/usr/local/sbin/portmaster -L --index-only | egrep '(ew|ort) version|total install'
echo -n "Last update: "
date -r `pkg query %t | sort | tail -n1` "+%Y%m%d"
You can’t perform that action at this time.