Skip to content

Instantly share code, notes, and snippets.

View SEJeff's full-sized avatar

Jeff Schroeder SEJeff

View GitHub Profile
[MASTER]
profile=no
persistent=yes
ignore=migrations
cache-size=500
[BASIC]
# Regular expression which should only match correct module names
module-rgx=([a-z][a-z0-9_]*)$
@SEJeff
SEJeff / init.sls
Last active August 29, 2015 14:04
States for reproducing salt bug #14497. They are all under services/httpd/ in the states tree
{% from "services/httpd/map.jinja" import httpd with context %}
{% set ltsv_conf = httpd.modconfdir + "/00-ltsv-log-format.conf" %}
httpd:
pkg:
- installed
- name: {{ httpd.pkg }}
service:
- running
- name: {{ httpd.service }}
@SEJeff
SEJeff / hashlib_test.py
Created August 15, 2014 09:01
Hexdigest on python 2.6 and 2.7
############################################################################################
>>> sys.version
'2.7.3 (default, Aug 9 2012, 17:23:57) \n[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)]'
>>> for algo in hashlib.algorithms:
... print '{algo} has hexdigest()'.format(instance=getattr(hashlib, algo)(), algo=algo)
...
md5 has hexdigest()
sha1 has hexdigest()
sha224 has hexdigest()
@SEJeff
SEJeff / demonstrate_py26_bug.py
Last active August 29, 2015 14:12
Python 2.6 bug with IOError in a context manager
#!/usr/bin/env python
from __future__ import print_function
class Context(object):
def __enter__(self):
yield
def __exit__(self, type, value, tracebck):
print("type: {0}".format(str(type(value))))
print("repr: {0}".format(repr(value)))
print("istuple: {0}, isioerror: {1}".format(isinstance(value, tuple), isinstance(value, IOError)))

The mustache gotcha

When using “bound” objects in an .aurora file it is an absolute that you do not have spaces in the “mustaches”.

Examples:

  • Bad: {{ profile.my_var }}
  • Good: {{profile.my_var}}

Mesos Slave Constraints

When scheduling a task on aurora with Production=True, the 0.7-incubating scheduler will set a default constraint preventing more than one instance of the task on the same rack.

@SEJeff
SEJeff / debugdjango_function.sh
Created November 4, 2010 19:25
This is the shell function I use to catch snowy tracebacks when a tomboy sync fails
debugdjango() {
action=${1:-traceback}
port=${2:-8000}
interface=${3:-lo}
TCPDUMP="tcpdump -i${interface} -A port ${port}"
case $action in
all)
echo "INFO: Running tcpdump on interface $interface and port $port" >&2
sudo $TCPDUMP
;;
@SEJeff
SEJeff / cdpy.sh
Created April 9, 2011 17:05
Shell function for automatically cd-ing into the source directory of any python module much like how you cd in the shell
# Put this in /etc/profile.d/cdpy.sh or copy the function into ~/.bashrc
# Change to the source directory of just about any python module to RTFS
#
# (c) 2011 Jeff Schroeder <jeffschroeder@computer.org> released as GPLv2
cdpy() {
module="$1"
[ -z "$module" ] && return 1
dir=$(python -c "
import os
try:
@SEJeff
SEJeff / atom_feed_gen.py
Created April 14, 2011 19:48
Atom feed generator
# Copied from the django source but added feed_url so the write actually works.
import sys
from django.utils import feedgenerator
feed = feedgenerator.Atom1Feed(
title=u"Poynter E-Media Tidbits",
link=u"http://www.poynter.org/column.asp?id=31",
feed_url=u"http://rss.feed_url/",
description=u"A group weblog by the sharpest minds in online media/journalism/publishing.",
language=u"en",
@SEJeff
SEJeff / apt.patch
Created July 7, 2011 04:11
API fix for apt.list_pkgs
jeff@desktopmonster:~/src/git/salt/salt/modules (misc-fixes)$ gdi apt.py
diff --git a/salt/modules/apt.py b/salt/modules/apt.py
index f3b0cd8..75751a4 100644
--- a/salt/modules/apt.py
+++ b/salt/modules/apt.py
@@ -196,7 +196,7 @@ def upgrade(refresh=True):
return ret_pkgs
-def list_pkgs(regex_string=""):