Skip to content

Instantly share code, notes, and snippets.

@sherbang
sherbang / insperity_to_guideline_401k.py
Last active Jul 2, 2021
Convert 401k data from Insperity report to Guideline's import format
View insperity_to_guideline_401k.py
#!/usr/bin/env python
import csv
import pathlib
import sys
GUIDELINE_HEADERS = [
"Last Name",
"First Name",
"Traditional (Pre-tax)",
"Employer Contribution",
View exception_to_warning.py
try:
pass
except:
sys.excepthook(*sys.exc_info())
View safename.py
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 / __init__.py
Last active Aug 29, 2015
Find program directory for running python program
View __init__.py
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 Aug 29, 2015
Use incrontab to auto-update vagrant boxes
View refresh_vagrant_box.py
#!/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:
@sherbang
sherbang / vyos.cfg
Created Mar 31, 2015
VyOS on Xen example config
View vyos.cfg
# 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' ]
View keybase.md

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 Aug 29, 2015
Save all running Virtualbox VMs thanks to @lmbrt
View vboxsaveall.sh
#!/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
@sherbang
sherbang / update_scripts.cmd
Last active Dec 14, 2015
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".
View update_scripts.cmd
@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 Dec 14, 2015 — forked from parhammmm/models.py
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers) Depends on pycrypto