Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
set -o errexit
kernel_release=$(uname -r)
private_key_file="private_key.pem"
public_key_file="public_key.der"
find /lib/modules/"${kernel_release}" -name 'vbox*.ko' | while read -r module_path; do
module_name=$(basename -s .ko ${module_path})
echo "Signing ${module_name} ..."
@bjorndown
bjorndown / Dockerfile
Created March 2, 2019 16:23
cryptography pip multi stage build on alpine
FROM python:3-alpine as builder
RUN apk add --no-cache gcc python3-dev libffi-dev openssl-dev build-base
RUN pip3 install cryptography
FROM python:3-alpine as release
COPY --from=builder /root/.cache /root/.cache
@bjorndown
bjorndown / enum_display.rs
Created February 28, 2016 13:20
Rust: Implement fmt::Display for enum
use std::fmt;
#[derive(Copy,Clone)]
enum CellState { Dead, Alive }
impl fmt::Display for CellState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let printable = match *self {
CellState::Alive => 'x',
CellState::Dead => ' ',
@bjorndown
bjorndown / refcol.py
Created December 2, 2013 07:22
Recursively scans a directory for text files and finds those files not mentioned by name in any file within this tree.
import os
import re
import sys
class ReferenceCollector:
def __init__(self, pattern, ignored_files):
self.files = {}
self.ignored_files = ignored_files
self.PATTERN = pattern
@bjorndown
bjorndown / http_echo_server.py
Created October 31, 2013 11:40
http echo server with python
from http.server import BaseHTTPRequestHandler
class PostHandler(BaseHTTPRequestHandler):
def do_POST(self):
self.answer()
self.print_delimiter()
self.print_request_header()
self.print_request_body()
@bjorndown
bjorndown / sql_insert2csv.py
Last active December 26, 2015 18:29
Tries to transform a bunch of INSERT statements into a CSV file.
import re
import sys
PATTERN = re.compile("INSERT INTO ([\w_\.]+) \(([\w,\"]+)\) VALUES \(([\w ,:'\.\(\)]+)\);$", flags=re.IGNORECASE)
TO_DATE_PATTERN = "to_date\(('[0-9 :\.]+'),'DD.MM.RR HH24:MI:SS'\)"
def convert(filename):
with open(filename) as source_file:
output = None
current_table_name = None
@bjorndown
bjorndown / Steps
Last active December 14, 2015 05:09
Steps for setting up Archlinux with LVM over LUKS (no keyfile), syslinux with GPT
cgdisk /dev/sda
-----------------
sda1 512M EF00
sda2 200M 8300
sda3 rest 8300
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot
pvcreate /dev/mapper/cryptroot
vgcreate vg /dev/mapper/cryptroot