Skip to content

Instantly share code, notes, and snippets.

D. Spindel Spindel

Block or report user

Report or block Spindel

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
import abc
import typing
import dataclasses
from functools import singledispatchmethod
class Root:
find . -type f -print0 |xargs -0 filefrag  |awk -F: '{ gsub("extents", "extent", $2); gsub("extent found", "", $2); print( $2,  $1)}' |sort -n

start by calculating ssdeep on files to find similar hashing files
use this to find "close" matches.
apply python:
all close matches get compared against each-other, pairwise

import os
with open(f1, "r+b") as fb1, open(f2, "r+b") as fb2:
      m1 = mmap.mmap(fb1.fileno, 0)
Spindel /
Last active Mar 31, 2019
Delay Maps
#!/usr/bin/env python3
import asyncio
import random
import uuid
import time
class MaxMap:
def __init__(self):
use std::io::Write;
use std::os::unix::io::AsRawFd;
use std::fs::OpenOptions;
extern crate libc;
fn main() {
const I2C_SLAVE: u64 = 0x0703;
const DEVICE: u32 = 0x2a;
const I2C_DATA: [u8;2] = [0x2a, 0x2a];
let mut file = OpenOptions::new().read(false).write(true).create(false).open("/dev/i2c-1").expect("File not found?");
Spindel /
Created Apr 16, 2017
containerised caramel

Caramel setup instructions

This setup assumes dockerized containers, we're using this on CoreOS, but you can use whatever that's using docker.

This setup is more complex than the simplest possible, but it's production ready.

  1. set up a new host, point a DNS name at it
  2. Sets up a http proxy to get a LetsEncrypt cert up
  3. Sets up LetsEncrypt for public infra (https to the CA server)
  4. Sets up caramel server
Spindel /
Last active Feb 22, 2019
Interview question model.
import uuid
import random
from afase.models.meta import Base
from sqlalchemy import (
View pgbackup.bash
#! /bin/bash -e
# Note "-e" above, as that's what prevents removing old dump
# when new dump fails.
TSPEC=$(date "+%F_%T")
Spindel /
Created Dec 9, 2016
Direct IO in Python
#!/bin/env python3
import os
import mmap
import logging
import hashlib
import contextlib
log = logging.getLogger(__name__)
def directio_mmap(filename, readsize, offset):
def listen_forever(handlers):
session = DBSession()
engine = session.get_bind()
conn = engine.connect()
del engine
from sqlalchemy import text
for channel in handlers.keys():
Spindel /
Created Oct 28, 2015
rewrite of a script I came across
from __future__ import print_function
import shelve
def grabfile(filename):
result = []
with open(filename, "rb") as f:
for line in f:
You can’t perform that action at this time.