Skip to content

Instantly share code, notes, and snippets.

@opalmer
opalmer / add-encrypted-disk.yml
Created December 17, 2017 23:43
Quick playbook which mounts a device as an encrypted disk.
# DESCRIPTION
# This playbook can be used to add an encrypted a disk to a system to mount
# at boot.
#
# !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
# !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
# !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
# !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!
#
# Improper use of this playbook can result in data loss.
@opalmer
opalmer / encrypt.py
Created December 10, 2015 21:12
GPG Encrypt Directory
from __future__ import print_function
import argparse
import hashlib
import multiprocessing
import os
import random
import string
import subprocess
from errno import EEXIST
@opalmer
opalmer / retry.sh
Created November 16, 2015 02:23
retry.sh
function retry {
local attempt=1
local command="${@}"
while [ $attempt -ne 10 ]; do
echo "(run $attempt/10) running $command"
$command
if [[ $? -eq 0 ]]; then
echo "(success) $command"
break
@opalmer
opalmer / gist:0850879794e81198c3a0
Created April 21, 2015 03:53
Overly simplified version of pyfarm-master's setup/test/teardown steps as if multiple tests are run. Created for https://groups.google.com/forum/#!topic/sqlalchemy/hQppcFNFEGY
import os
os.environ.update(
PYFARM_DATABASE_URI="sqlite:///:memory:"
)
from pyfarm.master.application import db
for i in range(5):
# setUp
from pyfarm.models.agent import Agent
@opalmer
opalmer / run_on_change.py
Last active August 29, 2015 14:16
Monitor a path then run a command on any change.
#!/usr/bin/env python
import subprocess
import sys
from datetime import datetime, timedelta
import pyinotify
class OnWriteHandler(pyinotify.ProcessEvent):
DELAY = timedelta(seconds=5)
@opalmer
opalmer / netifaces_patch
Last active December 23, 2015 01:09
Attempting "pip install -e ." after cloning the netifaces repo on WIndows 7 32-bit results in a compiler error in Python 2.7. Same for "pip install netifaces" and "easy_install netifaces". I did some looking around and found some answers that were less than optimal such as renaming netifaces.c -> netifaces.cpp (which broke the out of the box bui…
diff -r aa1a71e0adf7 netifaces.c
--- a/netifaces.c Tue Jan 31 11:48:23 2012 +0000
+++ b/netifaces.c Fri Sep 13 20:14:12 2013 -0400
@@ -400,11 +400,14 @@
static int
add_to_family (PyObject *result, int family, PyObject *dict)
{
+ PyObject *py_family;
+ PyObject *list;
+
@opalmer
opalmer / gist:90171505d9751523bbdf
Last active December 17, 2015 16:39
stone age render script
#!/bin/bash
function usage {
echo $1
echo "usage: $0 <start> <end> <by> <renderer> <project_root> <scene>"
exit 1
}
START_FRAME=$1
END_FRAME=$2