Skip to content

Instantly share code, notes, and snippets.

@sherbang
sherbang / insperity_to_guideline_401k.py
Last active July 2, 2021 13:28
Convert 401k data from Insperity report to Guideline's import format
#!/usr/bin/env python
import csv
import pathlib
import sys
GUIDELINE_HEADERS = [
"Last Name",
"First Name",
"Traditional (Pre-tax)",
"Employer Contribution",
try:
pass
except:
sys.excepthook(*sys.exc_info())
def safename(filename):
'Convert a string to a safe filename'
keepcharacters = (' ','.','_')
return "".join(c for c in filename if c.isalnum() or c in keepcharacters).rstrip()
@sherbang
sherbang / vyos.cfg
Created March 31, 2015 21:56
VyOS on Xen example config
# This can be defined as just 'pygrub' in newer versions of Xen
bootloader = '/usr/lib/xen-4.1/bin/pygrub'
memory = 512
name = 'vyos'
vcpus = 1
# Xen console doesn't display anything after pygrub, but VNC console does
# VNC virtual display
vfb = [ 'type=vnc' ]
@sherbang
sherbang / update_scripts.cmd
Last active December 14, 2015 13:29
Use this to make files in IronPython\Scripts executable from the windows command prompt. Add IronPython and Scripts folders to PATH then run "update_scripts C:\Program Files\IronPython 2.7\Scripts".
@setlocal enabledelayedexpansion && ipy -x "%~f0" %*& exit /b !ERRORLEVEL!
import os
import sys
scripts_dir = sys.argv[1]
scripts = os.listdir(scripts_dir)
for script in scripts:
if script.endswith('.cmd'):
continue
@sherbang
sherbang / __init__.py
Last active December 14, 2015 08:59 — forked from parhammmm/models.py
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers) Depends on pycrypto
@sherbang
sherbang / __init__.py
Last active August 29, 2015 14:21
Find program directory for running python program
import os
import sys
def get_app_directory():
"""Return the directory that contains the application.
This is the directory of the .py file in most cases, but is the directory
of the .exe file in the case of py2exe.
"""
import imp
@sherbang
sherbang / refresh_vagrant_box.py
Last active August 29, 2015 14:21
Use incrontab to auto-update vagrant boxes
#!/usr/bin/env python3
# Run by incron whenever a file in the vagrant_boxes dir changes.
# Updates the corresponding box in vagrant (vagrant box add -f)
#
# For me, boxes in vagrant_boxes are created on another machine
# and synced over with BTSync. This detects the change for me and
# makes sure my local box is fresh.
#
# Add this to your incrontab:

Keybase proof

I hereby claim:

  • I am sherbang on github.
  • I am sherbang (https://keybase.io/sherbang) on keybase.
  • I have a public key whose fingerprint is 78B1 CD53 327E A787 BD63 40FE 55E7 DE1B CCFC AAAA

To claim this, I am signing this object:

@sherbang
sherbang / vboxsaveall.sh
Last active August 29, 2015 13:57
Save all running Virtualbox VMs thanks to @lmbrt
#!/bin/sh
# Save all running Virtualbox VMs
# Credit: http://lmbrt.com/a/11
vboxmanage list runningvms | sed s/[a-zA-Z[:space:]0-9\"]*// | xargs -i vboxmanage controlvm {} savestate