Skip to content

Instantly share code, notes, and snippets.

View SEJeff's full-sized avatar

Jeff Schroeder SEJeff

View GitHub Profile
2021/04/09 11:52:11 INFO fsmsupport.go:252 - *** Entering state SET_KERNELCONFIG after getting event: salt_finished (Src: SALT_COMPUTE_RUNNING)
fatal error: sync: RUnlock of unlocked RWMutex
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x11f6601]
goroutine 1 [running]:
runtime.throw(0x14ed190, 0x21)
/jump/software/rhel7/golang-1.16/src/runtime/panic.go:1117 +0x72 fp=0xc00001b478 sp=0xc00001b448 pc=0x4447f2
sync.throw(0x14ed190, 0x21)
/jump/software/rhel7/golang-1.16/src/runtime/panic.go:1103 +0x35 fp=0xc00001b498 sp=0xc00001b478 pc=0x4758b5
sync.(*RWMutex).rUnlockSlow(0xc0004fc5d8, 0xffffffff)
@SEJeff
SEJeff / foo.py
Last active March 11, 2021 20:18
Python question
def append_one(data=[]):
data.append(1)
return data
### What does this function return for
1. `append_one()`
2. `append_one(data=[2])`
3. `append_one()`
@SEJeff
SEJeff / gist:2999174
Created June 26, 2012 21:22
Sending eth0's ip as a variable to a salt template file
/var/www/myip.html:
file.managed:
- source: salt://roles/wordpress/files/myip.html.jinja
- user: root
- group: root
- mode: 640
- template: jinja
- context:
hostname: {{ grains['fqdn'] }}
ip: {{ salt['network.interfaces']()['eth0']['ipaddr'] }}
@SEJeff
SEJeff / gist:7310830
Last active January 16, 2020 09:07
Apache config to load balance across a cluster of elasticsearch instances on 2 different servers, "es-cluster-1", and "es-cluster-2".
<VirtualHost *:80>
ServerName balancer.local
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Location /balancer-manager>
ProxyPass !
SetHandler balancer-manager
#Require host example.com
Require host localhost
</Location>
{% macro postconf(key, value) -%}
postconf-{{ key }}:
cmd:
- run
- name:
- postconf -e {{ key }}='{{ value }}'
- unless: test "x$(postconf -h {{ key }} )" = 'x{{ value }}'
- require:
- pkg: postfix
@SEJeff
SEJeff / print_imports.py
Last active April 11, 2019 12:33
Print every python import for debugging import issues
# Courtesy of https://github.com/wimglenn
import sys
try:
import builtins
except ImportError:
# py2
import __builtin__ as builtins
@SEJeff
SEJeff / debug_middleware.py
Created April 8, 2011 17:41
Django debug middleware for displaying extra information when the request includes the "debug" query string.
# Originally based on: http://djangosnippets.org/snippets/1872/
# Requires sqlparse: http://pypi.python.org/pypi/sqlparse
import time
from django.test.signals import template_rendered
from django.conf import settings
from django.db import connection
from django.utils.encoding import force_unicode
from django.utils.safestring import mark_safe
TEMPLATE = """
@SEJeff
SEJeff / settings_ldap.py
Created July 8, 2011 22:27
Example django_auth_ldap configuration
############################## django-auth-ldap ##############################
import ldap
from django_auth_ldap.config import LDAPSearch, PosixGroupType
# django-auth-ldap configuration starts here
AUTH_LDAP_SERVER_URI = "ldap://ldap.els03.loc ldap://ldap.zbw03.loc ldap://ldap.cvg03.loc"
#AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=People,o=loc"
# JW is in ou=Admin,o=loc so we search over o=loc to find him
AUTH_LDAP_USER_SEARCH = LDAPSearch("o=loc",
@SEJeff
SEJeff / which.py
Created May 2, 2012 14:35
Implementation of Unix's which command in python
def which(exe=None):
'''
Python clone of POSIX's /usr/bin/which
'''
if exe:
(path, name) = os.path.split(exe)
if os.access(exe, os.X_OK):
return exe
for path in os.environ.get('PATH').split(os.pathsep):
full_path = os.path.join(path, exe)