Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# provide semi-automatic dns to docker container
# just call this script
DNSMASQ_CONF_DIR=/etc/dnsmasq.d
PRIMARY_DOMAIN=ms.foo
@diefans
diefans / execution.py
Created March 10, 2016 18:19
Popen stdout/stderr generator by means of select.select
import shlex
import subprocess
import select
class stdout(str):
"""A string representation from stdout."""
@diefans
diefans / arch-linux-uefi-encrypted-install
Created October 5, 2017 07:57 — forked from thacoon/arch-linux-uefi-encrypted-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Based on https://gist.github.com/mattiaslundberg/8620837
# And based on https://wiki.archlinux.de/title/Anleitung_f%C3%BCr_Einsteiger
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
@diefans
diefans / arch-linux-install
Created October 5, 2017 07:59 — forked from softmoth/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and EFI on 8,2 MacBook.
# The official installation guide contains a more verbose description:
# https://wiki.archlinux.org/index.php/Installation_Guide
# Resize "Macintosh HD" to make room for Linux. This works live, including with
# whole-disk encryption (WDE, FileVault). Ensure backups are current, of course,
# before proceeding
diskutil list
diskutil cs list
# Ensure all data will fit in 250G, with some to spare!
@diefans
diefans / Arch-ZFSRoot-on-dm-crypt-UEFI
Created October 5, 2017 08:01
ZFSRoot installation over a dm-crypt volume for Arch Linux (UEFI)
# arch uefi dm-crypt zfsroot install (archiso)
# partition disk
# start at 1MB (sector 2048)
512Mib EFI
512Mib Boot
Rest ZFS
#setup encrypted partition
cryptsetup luksFormat -l 512 -c aes-xts-plain64 -h sha512 /dev/disk/by-partuuid/<uid>
@diefans
diefans / cors.py
Created October 12, 2017 22:04 — forked from mmerickel/cors.py
cors in pyramid
from pyramid.security import NO_PERMISSION_REQUIRED
def includeme(config):
config.add_directive(
'add_cors_preflight_handler', add_cors_preflight_handler)
config.add_route_predicate('cors_preflight', CorsPreflightPredicate)
config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse')
class CorsPreflightPredicate(object):
@diefans
diefans / sqlalchemy_conftest.py
Created October 23, 2017 21:09 — forked from kissgyorgy/sqlalchemy_conftest.py
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope='session')
def engine():
return create_engine('postgresql://localhost/test_database)
@diefans
diefans / pytest_flask_fixtures.py
Created March 27, 2018 09:38 — forked from qodot/pytest_flask_fixtures.py
Pytest Fixtures (Flask, SQLAlchemy, Alembic)
import sys
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from alembic.command import upgrade as alembic_upgrade
from alembic.config import Config as AlembicConfig
from wsgi import create_app
from config import config
@diefans
diefans / aiohttp_injections.py
Created August 13, 2018 13:15 — forked from jettify/aiohttp_injections.py
aiohttp dependency injection example
import asyncio
import injections
import aiopg.sa
from aiohttp import web
@injections.has
class SiteHandler:
# this is only place holder, actual connection
@diefans
diefans / zipapp.md
Created August 21, 2018 19:30 — forked from lukassup/zipapp.md
Python zipapp

Python zipapp web apps

What's a zipapp?

This concept is very much like .jar or .war archives in Java.

NOTE: The built .pyz zipapp can run on both Python 2 & 3 but you can only build .pyz zipapps with Python 3.5 or later.

Initial setup