Skip to content

Instantly share code, notes, and snippets.

View ipmb's full-sized avatar

Peter Baumgartner ipmb

View GitHub Profile
@ipmb
ipmb / status.txt
Created June 7, 2018 18:17
Systemd Status exmple
$ sudo systemctl status saltdash@0.9.4.service
● saltdash@0.9.4.service - Saltdash v0.9.4
Loaded: loaded (/etc/systemd/system/saltdash@.service; indirect; vendor preset: enabled)
Active: active (running) since Tue 2018-05-15 23:25:08 UTC; 3 weeks 1 days ago
Main PID: 25580 (python3.6)
Tasks: 5 (limit: 4704)
CGroup: /system.slice/system-saltdash.slice/saltdash@0.9.4.service
└─25580 /usr/bin/python3.6 /srv/saltdash/saltdash-0.9.4.pyz serve
Jun 07 18:15:42 web-prod python3.6[25580]: localhost - - [07/Jun/2018:18:15:42 +0000] "GET /-/alive/ HTTP/1.1" 200 - "-" "Go-http-client/1.1
@ipmb
ipmb / Dockerfile
Created June 6, 2018 16:46
vmods on trusty
FROM ubuntu:14.04
ENV VARNISHVERSION=52 MODSVERSION=0.15.0
RUN apt-get update && \
apt-get -yq install curl gnupg apt-transport-https build-essential pkg-config \
libpcre3-dev automake autogen libtool libreadline6-dev \
libeditline0 libeditline-dev python-docutils
RUN curl -sL https://packagecloud.io/varnishcache/varnish$VARNISHVERSION/gpgkey | apt-key add - && \
printf "deb https://packagecloud.io/varnishcache/varnish$VARNISHVERSION/ubuntu/ trusty main\ndeb-src https://packagecloud.io/varnishcache/varnish$VARNISHVERSION/ubuntu/ trusty main" > /etc/apt/sources.list.d/varnish.list && \
apt-get update && \
@ipmb
ipmb / doh-on-mac.md
Created May 31, 2018 20:28
DNS over HTTP (DOH) on MacOS

Install

brew install dnscrypt-proxy

Configure

Edit /usr/local/etc/dnscrypt-proxy.toml as needed. I added/modified the following lines:

@ipmb
ipmb / run.py
Created May 13, 2018 00:48
uwsgi as lib
# UWSGI_AS_LIB=`pwd`/saltdash/libuwsgi.so pip install uwgi
# via https://gist.github.com/sixninetynine/c5c2c0047ea510d9db6c4f99f09c341e
import sys
import os
import ctypes
try:
from importlib import resources
except ImportError:
import importlib_resources as resources
@ipmb
ipmb / zonefile_to_terraform_dyn.py
Last active April 24, 2018 20:07
DNS zonefile -> terraform dyn
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 April 19, 2018 15:07
Running systemd in docker with Ubuntu 18.04

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

$ 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 March 28, 2018 18:28
Building header vmod for varnish 3 on Trusty
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 && \
@ipmb
ipmb / logs_log
Created January 2, 2018 22:43
\d 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) |
#!/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)