Skip to content

Instantly share code, notes, and snippets.

View jessepeterson's full-sized avatar

Jesse Peterson jessepeterson

View GitHub Profile
@jessepeterson
jessepeterson / crl2pkcs7.py
Created February 23, 2016 22:08
Python PKCS#7 degenerate certificates (like `openssl crl2pkcs7`) using ctypes
#!/usr/bin/python
from M2Crypto import X509, BIO, m2
import os
from ctypes import CDLL
from ctypes import *
from ctypes.util import find_library
class PKCS7_SIGNED(Structure):
@jessepeterson
jessepeterson / acllength.py
Created February 3, 2016 04:08
Print files that have a specific length ACL text presentation
#!/usr/bin/python
"""Print files that have a specific length ACL text presentation
Used to debug a backup tool that may have been having problems with files
with this precise ACL representation.
Created by Jesse Peterson on 2/2/16
"""
@jessepeterson
jessepeterson / esxiupload.sh
Created December 22, 2015 20:29
ESXi datastore upload helper (uses curl)
#!/bin/sh
if [ $# -lt 5 ]; then
echo "$0 <host> <user> <datastore> <folder> <filepath>"
echo
echo " examples:"
echo " $0 10.0.0.1 root datastore1 ISOs /tmp/Linux.iso"
exit 1
fi
@jessepeterson
jessepeterson / reponotify.py
Last active August 5, 2019 16:40
reposado update notification: reports changed Apple products between repo_sync runs
#!/usr/bin/python
'''
reposado update notification: reports changed Apple products between repo_sync runs
Checks the current list of updates versus the previous list of updates and
reports on the changes. Run this script after your repo_sync run to see the
changes between syncs. You can then hand this report off in email if you wish.
For example:
@jessepeterson
jessepeterson / makeinstaller.sh
Created July 24, 2014 00:09
Make OS X installer ISO (CDR) from OS Install app
#!/bin/sh
user_id=`id -u`
if [ $user_id -ne 0 ]; then
echo "$0: must be root"
exit 1
fi
if [ $# -lt 2 ]; then
@jessepeterson
jessepeterson / app_map.c
Last active October 23, 2023 07:32
_CFPreferencesCopyApplicationMap example
/* re-implementation of the behaviour that the /usr/bin/defaults application
* uses to read sandboxed preference data */
#include <CoreFoundation/CoreFoundation.h>
#define EX_BUNDLE_ID "com.apple.mail"
#define EX_KEY "JunkMailBehavior"
// undocumented, internal CFPreferences API call
extern CFDictionaryRef _CFPreferencesCopyApplicationMap(CFStringRef userName, CFStringRef hostName);
@jessepeterson
jessepeterson / check_10.9_board_id.sh
Created January 16, 2014 20:08
Check the current Mac board ID against the list provided in the 10.9.0 installer to determine compatibility.
#!/bin/sh
BOARD_ID=`ioreg -p IODeviceTree -r -n / -d 1 | grep board-id | awk '{print $3}' | sed -n 's/\<\"\(Mac-[0-9A-Z]*\)\"\>/\1/p'`
grep $BOARD_ID > /dev/null << EOF
Mac-031B6874CF7F642A
Mac-F2268DC8
Mac-50619A408DB004DA
Mac-F2218EA9
Mac-F42D86A9
@jessepeterson
jessepeterson / github_dlextract.pp
Last active December 19, 2015 02:28
Puppet definition to download a tarball of a Github repo and extract it to a filesystem location.
# example:
#
# github_dlextract { "mxcl/homebrew",
# path => "/my/path/directory",
# rev => "b8c7e203d1", # optional
# }
define github_dlextract ($repo = $title, $path, $rev = 'master') {
file { $path:
@jessepeterson
jessepeterson / remove_ilife_dvd.sh
Created May 23, 2013 03:10
Remove iLife '11 (DVD installer)
#!/bin/sh
# Remove *all* components of iLife '11 as installed by the "DVD" installer
rm -rf \
"/Applications/iWeb.app" \
"/Library/Audio/Apple Loops/Apple/iLife Sound Effects" \
"/Applications/GarageBand.app" \
"/Library/Audio/Apple Loops/Apple/Apple Loops for GarageBand" \
"/Applications/iDVD.app" \
@jessepeterson
jessepeterson / convert-emlx.py
Last active December 15, 2015 01:29
Convert an Apple emlx file to a .eml file (removing the Apple-proprietary parts; leaving a raw message file)
import sys
for i in sys.argv[1:]:
if i.lower().endswith('emlx'):
print 'Processing:', i
else:
print 'Unknown file:', i
sys.exit(1)
emlx = open(i, 'r')