Skip to content

Instantly share code, notes, and snippets.

Avatar

Rune Kaagaard runekaagaard

  • Copenhagen, Denmark
View GitHub Profile
@runekaagaard
runekaagaard / last-daemon.sh
Last active Apr 26, 2021
Run multiple dev servers in parallel with a single command. Each line has a colored prefix. CTRL+C closes all. Requires GNU parallel.
View last-daemon.sh
#!/bin/bash
# COLOR CODES
# Red 31 41
# Green 32 42
# Yellow 33 43
# Blue 34 44
# Magenta 35 45
# Cyan 36 46
# White 37 47
View tmbabw.py
state = {
"users":
User.mutable.all() > {
"tags": Tag.mutable.up().all(),
},
"movie":
Movie.mutable.get(pk=91) > {
"actors": Actor.mutable.up().all(),
"style": Style.mutable.up().get(),
}
@runekaagaard
runekaagaard / change_monitor.py
Created Nov 2, 2019
POC Python Change Monitor of generic nested data
View change_monitor.py
from collections import namedtuple
ATTR_LOOKUP = 1
ITEM_LOOKUP = 2
Change = namedtuple("Change", "path to")
class Lookup(namedtuple("Lookup", "key lookup_type")):
def __str__(self):
if self.lookup_type == ATTR_LOOKUP:
@runekaagaard
runekaagaard / README.md
Created Sep 13, 2019 — forked from mayorova/README.md
Mutual SSL in NGINX
View README.md

Securing traffic to upstream servers with client certificates

Info: https://www.nginx.com/resources/admin-guide/nginx-https-upstreams/

Creating and Signing Your Certs

Source: http://nategood.com/client-side-certificate-authentication-in-ngi

This is SSL, so you'll need an cert-key pair for you/the server, the api users/the client and a CA pair. You will be the CA in this case (usually a role played by VeriSign, thawte, GoDaddy, etc.), signing your client's certs. There are plenty of tutorials out there on creating and signing certificates, so I'll leave the details on this to someone else and just quickly show a sample here to give a complete tutorial. NOTE: This is just a quick sample of creating certs and not intended for production.

@runekaagaard
runekaagaard / midipad.py
Created May 14, 2017
A midi plugin for a 3x3 pad.
View midipad.py
from rtmidi.midiutil import open_midiport
NOTEON = 144
NOTEOFF = 128
BASE = 65
SCALE = [1, 2, 1, 1, 2, 2, 1, 2]
NOTE = BASE
STEP = 0
TOPBASE = BASE + 24
View neural_net.py
from __future__ import division
from itertools import izip
from math import exp, sqrt
from random import random
from pprint import pprint
"""
Working through http://neuralnetworksanddeeplearning.com and
implementing it in no-library python.
"""
@runekaagaard
runekaagaard / list_all_model_signals.py
Last active Nov 9, 2020 — forked from voldmar/signals.py
List all signals by model and signal type. Tested with Django 1.7.
View list_all_model_signals.py
# coding:utf-8
import gc
import inspect
import ctypes
from collections import defaultdict
from django.core.management.base import BaseCommand
from django.db.models.signals import *
View init.el
;; Bootstrap packages.
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)
(if (not (package-installed-p 'use-package))
(progn
@runekaagaard
runekaagaard / ableton_mencoder.sh
Created Aug 27, 2014
Good ffmpeg options for Ableton playback
View ableton_mencoder.sh
ffmpeg -i [INPUT_FILE] -an -pix_fmt yuv420p -vcodec mjpeg -f mov -y [OUTPUT_NAME].mov
@runekaagaard
runekaagaard / gist:aec4e53de4097f46f797
Created May 28, 2014
manage.py Only print statements
View gist:aec4e53de4097f46f797
stdbuf -o0 python manage.py runserver 127.0.0.1:8001 2>&1 | stdbuf -o0 sed "s/Quit the server with CONTROL-C\./__THETIME__/g" | stdbuf -o0 grep -v -E '("GET )|("POST )|(0 errors found)|(, using settings )|(Development server is running at)|(Validating models\.\.\.)' | awk '{ gsub("__THETIME__", "SERVER RELOADED AT " strftime("%Y-%m-%d %H:%M:%S" "\n======================================") ,$0); print $0; fflush(); }'