Skip to content

Instantly share code, notes, and snippets.

View Spindel's full-sized avatar
👷‍♂️
For hire

Spindel Ljungmark Spindel

👷‍♂️
For hire
  • https://www.modio.se/ @ModioAB
  • Sweden
  • 14:28 (UTC +02:00)
View GitHub Profile
@Spindel
Spindel / IoT colo
Created February 7, 2015 11:54
The Internet of Things, A co-location in your home
# Internet of Things
## A co-location in your home.
### A real co-location
In a normal co-location (colo for short) a provider has a data hall, where they install servers of various kinds for their customers. The colo stands for power and connectivity, and some level of out-of-band monitoring to do billing or capping.
The monitoring is usually on the network level, from switches and packet flows, and not internal to your server ("what is running now") and is used to prevent customers from interfering with others, and to alert customers in case of their servers failing.
### The home co-location
@Spindel
Spindel / IoT-colo.md
Last active August 29, 2015 14:14
The Internet of Things, A co-location in your home

Internet of Things

A co-location in your home.

A real co-location

In a normal co-location (colo for short) a provider has a data hall, where they install servers of various kinds for their customers. The colo stands for power and connectivity, and some level of out-of-band monitoring to do billing or capping.

The monitoring is usually on the network level, from switches and packet flows, and not internal to your server ("what is running now") and is used to prevent customers from interfering with others, and to alert customers in case of their servers failing.

The home co-location

@Spindel
Spindel / encodings.py
Last active August 29, 2015 14:23
Python3 locale inconsistencies
#!/bin/env python
# vim: ts=4 sts=4 sw=4 ft=python expandtab fileencoding=utf8 :
""" Python2 and Python3 differ on how they handle input and output
files depending on the current locale.
Python2: behaves consistently(but badly), reading and writing utf8
as if it was ascii. Successfully giving back the same byte sequence
as was put in. (Aka. The same string)
@Spindel
Spindel / postall-curl.py
Last active August 29, 2015 14:25
Post all Certificate Requests
#!/bin/env python3
# vim: expandtab shiftwidth=4 softtabstop=4 tabstop=17 filetype=python :
"""
Upload a set of .csr files to a caramel endpoint. Used for some minor
benchmarking and to populate things
The PyCurl version
"""
import threading
import hashlib
@Spindel
Spindel / autosign.py
Created July 24, 2015 18:30
Temp copy-paste of the caramel autosign
import threading
import argparse
import datetime
import logging
import time
import uuid
import queue
import sys
import gc
@Spindel
Spindel / .SQL
Last active August 29, 2015 14:25
SQl playing
SELECT (c).csr_id, (c).not_before, (c).not_after FROM (SELECT (SELECT c FROM certificate c WHERE c.csr_id=csr.id ORDER BY c.not_after DESC LIMIT 1) AS c FROM csr offset 0) s;
@Spindel
Spindel / restorellnndump.py
Created October 28, 2015 12:38
rewrite of a script I came across
#!/usr/bin/python
from __future__ import print_function
import shelve
def grabfile(filename):
result = []
with open(filename, "rb") as f:
for line in f:
@Spindel
Spindel / gist:7896135
Created December 10, 2013 19:01
PyPy does strange things
def min_max_native(indata):
def _minmax(data):
_value = itemgetter(2)
low = min(data, key=_value)
high = max(data, key=_value)
return (_value(low), _value(high))
copy = indata[:]
minmax = _minmax(copy)
def listen_forever(handlers):
session = DBSession()
engine = session.get_bind()
conn = engine.connect()
del engine
conn.detach()
session.close()
from sqlalchemy import text
for channel in handlers.keys():
@Spindel
Spindel / flock demo
Last active April 25, 2016 09:58
Using flock for SSL key generation
#!/bin/bash
set -eu
set -o pipefail
MY_CRT=temp.crt
MY_KEY=temp.key
MY_CSR=temp.csr
CLIENTID=`sed -e 's/://g' /sys/class/net/eth0/address`
SUBJECT="/C=XX/ST=TESTING/L=Testing/O=Test Inc/OU=Test Dept/CN=$CLIENTID"