Skip to content

Instantly share code, notes, and snippets.

Peter Baumgartner ipmb

  • Lincoln Loop
Block or report user

Report or block ipmb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ipmb
ipmb / zonefile_to_terraform_dyn.py
Last active Apr 24, 2018
DNS zonefile -> terraform dyn
View zonefile_to_terraform_dyn.py
from blockstack_zones import parse_zone_file
with open('/path/to/your/zonefile') as f:
full = f.read()
ZONE = 'your-domain.com'
record_template = """
resource "dyn_record" "{slug}" {{
zone = "{zone}"
name = "{name}"
@ipmb
ipmb / notes.md
Created Apr 19, 2018
Running systemd in docker with Ubuntu 18.04
View notes.md

Trying to use kitchen-docker. It works great when passing privileged: true to the driver, but some hosted CI systems won't let you do that for security reasons. After trying a million different incantations, I got very close with:

image: ubuntu:18.04
run_options: --tmpfs=/run --tmpfs=/run/lock -v /sys/fs/cgroup/systemd:/sys/fs/cgroup/systemd --stop-signal=SIGRTMIN+3
run_command: /sbin/init

note: kitchen does some extra things like including -e container=docker

View build and install wheel
$ time python setup.py bdist_wheel > /dev/null
warning: build_py: byte-compiling is disabled, skipping.
warning: install_lib: byte-compiling is disabled, skipping.
real 0m0.922s
user 0m0.664s
sys 0m0.236s
@ipmb
ipmb / Dockerfile
Created Mar 28, 2018
Building header vmod for varnish 3 on Trusty
View Dockerfile
FROM ubuntu:14.04
RUN apt-get update && \
apt-get -yq install varnish libvarnishapi-dev build-essential pkg-config \
libpcre3-dev automake autogen libtool libreadline6-dev \
libeditline0 libeditline-dev python-docutils curl
RUN curl -sLO https://varnish-cache.org/_downloads/varnish-3.0.7.tgz && \
tar xvzf varnish-3.0.7.tgz && cd varnish-3.0.7 && \
./configure && make
RUN curl -sLO https://github.com/varnish/libvmod-header/archive/3.0.tar.gz && \
View logs_log
Table "public.logs_log"
Column | Type | Modifiers
--------------+--------------------------+-------------------------------------------------------
id | integer | not null default nextval('logs_log_id_seq'::regclass)
bot_id | integer |
timestamp | timestamp with time zone | not null
nick | character varying(255) | not null
text | text | not null
action | boolean | not null
command | character varying(50) |
View log_string_formatting.py
#!/usr/bin/env python
"""Example of the speed-up allowed by logging's string handling"""
from __future__ import division
import logging
import string
import time
logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)
View readable_log_formatter.py
from __future__ import unicode_literals
import logging
# built-in attributes on LogRecord. Used to determine what is passed in `extras`
RESERVED_ATTRS = (
'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
'funcName', 'levelname', 'levelno', 'lineno', 'module',
'msecs', 'message', 'msg', 'name', 'pathname', 'process',
'processName', 'relativeCreated', 'stack_info', 'thread', 'threadName')
@ipmb
ipmb / settings.py
Last active Oct 7, 2019
Django logging example
View settings.py
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
@ipmb
ipmb / 0_default_tree.md
Last active May 2, 2019
Django Logging Variations
View 0_default_tree.md

Default Django Logging Tree

app.py

#!/usr/bin/env python
import os

import django
import logging_tree
@ipmb
ipmb / create_test_instance.sls
Last active Jun 13, 2017
Salt orchestration
View create_test_instance.sls
{% set branch = pillar.name.split('.', 1)[0] %}
{{ branch }} db:
salt.function:
- name: state.apply
- tgt: salt.example.local
- arg:
- projects.test.dbs.generate_from_template
- kwarg:
pillar:
You can’t perform that action at this time.