Skip to content

Instantly share code, notes, and snippets.

View runekaagaard's full-sized avatar

Rune Kaagaard runekaagaard

  • Copenhagen, Denmark
View GitHub Profile
#!/usr/bin/env python
# encoding=utf-8
import sys
import os
from pprint import pprint
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "qa.settings")
from django.contrib.contenttypes.models import ContentType
# Output utf-8 on the command line, why is this buggy on my box?
reload(sys)
@runekaagaard
runekaagaard / celerybeat
Created March 27, 2013 13:57
An /etc/init.d/celerybeat script modified from https://raw.github.com/ask/celery/master/contrib/generic-init.d/celeryd to support a status command using the standard lsb functions.
#!/bin/bash
# =========================================================
# celerybeat - Starts the Celery periodic task scheduler.
# =========================================================
#
# :Usage: /etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status}
# :Configuration file: /etc/default/celerybeat or /etc/default/celeryd
#
# See http://docs.celeryq.org/en/latest/cookbook/daemonizing.html#init-script-celerybeat
@runekaagaard
runekaagaard / pgx.rst
Last active September 18, 2018 14:09
Bash scripts for extracting individual databases from a sql file dumped using pg_dumpall

Postgresql Xtra commands

  • pgx_list_dbs: Lists the names of databases in an .sql file dumped using pg_dumpall.
  • pgx_extract_db: Extracts a single database from a sql file dumped with pg_dumpall and outputs its content to stdout.

Installation

@runekaagaard
runekaagaard / gist:aec4e53de4097f46f797
Created May 28, 2014 11:31
manage.py Only print statements
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(); }'
@runekaagaard
runekaagaard / ableton_mencoder.sh
Created August 27, 2014 06:51
Good ffmpeg options for Ableton playback
ffmpeg -i [INPUT_FILE] -an -pix_fmt yuv420p -vcodec mjpeg -f mov -y [OUTPUT_NAME].mov
;; 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 / list_all_model_signals.py
Last active July 4, 2022 15:41 — forked from voldmar/signals.py
List all signals by model and signal type. Tested with Django 1.7.
# 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 *
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 / midipad.py
Created May 14, 2017 09:15
A midi plugin for a 3x3 pad.
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
@runekaagaard
runekaagaard / README.md
Created September 13, 2019 17:55 — forked from mayorova/README.md
Mutual SSL in NGINX

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.