Skip to content

Instantly share code, notes, and snippets.

View lorin's full-sized avatar
🤷‍♂️
Nominal

Lorin Hochstein lorin

🤷‍♂️
Nominal
View GitHub Profile
@lorin
lorin / prepare-commit-msg.py
Last active April 7, 2023 19:06
Git prepare-commit-msg hook for using git with pivotal tracker
#!/usr/bin/python
"""
This is a prepare-commit-msg hook for use with Pivotal Tracker.
Copy this file to $GITREPOSITORY/.git/hooks/prepare-commit-msg
and mark it executable.
It will prepend [#<story id>] to your commit message.
See https://www.pivotaltracker.com/help/api?version=v3#scm_post_commit
@lorin
lorin / blog.json
Created July 30, 2012 14:28
Example Mezzanine blog fixtures
[
{
"pk": 1,
"model": "blog.blogpost",
"fields": {
"status": 2,
"expiry_date": null,
"allow_comments": true,
"description": "This is an example of a blog post.",
"title": "example blog post",
@lorin
lorin / json2yaml.py
Created November 16, 2012 02:36
Convert from json to yaml
#!/usr/bin/env python
""" Convert json to YAML
Usage: json2yaml.py [infile]
"""
import args
import json
import sys
@lorin
lorin / gist:4478637
Created January 7, 2013 21:31
Annotate a request object with session. Useful for requests that are generated by the RequestFactory for testing
from django.contrib.sessions.middleware import SessionMiddleware
def add_session_to_request(request):
"""Annotate a request object with a session"""
middleware = SessionMiddleware()
middleware.process_request(request)
request.session.save()
@lorin
lorin / preseed-fragment.seed
Last active November 30, 2022 04:04
Automated partitioning with Ubuntu preseed
# Use LVM for partitioning
d-i partman-auto/method string lvm
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. Preseed this away
d-i partman-lvm/device_remove_lvm boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
@lorin
lorin / iptables-save
Last active December 15, 2015 05:29
iptables-save output on cloud controller (using no-op firewall)
# Generated by iptables-save v1.4.12 on Tue Apr 2 17:30:26 2013
*mangle
:PREROUTING ACCEPT [112473:568900113]
:INPUT ACCEPT [111832:568845149]
:FORWARD ACCEPT [641:54964]
:OUTPUT ACCEPT [97053:983035383]
:POSTROUTING ACCEPT [97694:983090347]
-A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
-A POSTROUTING -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
@lorin
lorin / no-8021q.txt
Last active December 15, 2015 23:09
tcpdump -i eth0 -XX -vv -e on CentOS guest instance, with 8021q module not loaded and loaded
14:29:22.906758 54:78:1a:86:50:c9 (oui Unknown) > Broadcast, ethertype 802.1Q (0x8100), length 64: vlan 0, p 0, ethertype ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.40.0.5 (Broadcast) tell 10.40.0.1, length 46
0x0000: ffff ffff ffff 5478 1a86 50c9 8100 0000 ......Tx..P.....
0x0010: 0806 0001 0800 0604 0001 5478 1a86 50c9 ..........Tx..P.
0x0020: 0a28 0001 ffff ffff ffff 0a28 0005 0000 .(.........(....
0x0030: 0000 0000 0000 0000 0000 0000 dac7 07ed ................
14:29:23.318464 54:78:1a:86:50:cb (oui Unknown) > 0e:fc:00:ff:ff:fe (oui Unknown), ethertype 802.1Q (0x8100), length 180: vlan 0, p 0, ethertype 0x8906,
0x0000: 0efc 00ff fffe 5478 1a86 50cb 8100 0000 ......Tx..P.....
0x0010: 8906 0000 0000 0000 0000 0000 0000 002e ................
0x0020: 22ff fffe 0000 0000 0129 0000 0000 0000 "........)......
0x0030: 1030 ffff 0000 0000 0400 0000 2020 000a .0..............
@lorin
lorin / mkpasswd.py
Created June 5, 2013 19:24
Generate a password hash suitable for /etc/shadow. Warning: Gives incorrect value on OS X.
#!/usr/bin/env python
"""
Generate a password hash, suitable for /etc/shadow
Inspired by this code from OpenStack:
https://github.com/openstack/nova/blob/stable/grizzly/nova/virt/disk/api.py#L549
Usage:
mkpasswd <passwd> [--algo=<hash>]
@lorin
lorin / centos-6.4.ks
Last active December 19, 2015 04:59
Building CentOS 6.4 images that resize on boot, with oz, libguestfs, and Robert Plestenjak's centos-image-resize script
install
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw %ROOTPW%
firewall --disabled
authconfig --enableshadow --enablemd5
@lorin
lorin / click_link.py
Created August 15, 2013 17:52
Illustrate try/except/else