Skip to content

Instantly share code, notes, and snippets.

View runekaagaard's full-sized avatar

Rune Kaagaard runekaagaard

  • Copenhagen, Denmark
View GitHub Profile
@runekaagaard
runekaagaard / mysql-5.7-install.sh
Last active November 8, 2024 15:04
Unattended install of mysql 5.7.42 (latest ubuntu deb packages) on Ubuntu 22.04. Change ROOT_PASSWORD. Choose gdal support.
#!/bin/bash
set -e
# Pre-configure root password
export DEBIAN_FRONTEND=noninteractive
ROOT_PASSWORD="your_password_here"
debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $ROOT_PASSWORD"
debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $ROOT_PASSWORD"
mkdir -p /tmp/mysql-install
@runekaagaard
runekaagaard / minecraft-start
Last active September 1, 2024 14:18
Linux script to start java minecraft with a custom username directly without running the launcher
#!/usr/bin/env bash
# Function to display help message
show_help() {
cat << EOF
Usage: minecraft-start [options] <username>
Launch Minecraft with the specified username.
Arguments:
@runekaagaard
runekaagaard / tails.py
Last active April 8, 2022 05:53
Runs and outputs multiple bash commands in one terminal. Each command gets a color. "pip install termcolor" is needed.
import fcntl, os, re, sys, signal
from subprocess import Popen, PIPE
from termcolor import colored
from itertools import cycle
RE = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
CLEARLN = "\033[2K\r"
def escape_ansi(s):
return RE.sub('', s)
@runekaagaard
runekaagaard / python_pipes.py
Last active February 26, 2022 13:18
pipe operator in python.
from functools import wraps
class Ror:
def __init__(self, func, args, kwargs):
self.func = func
self.args = args
self.kwargs = kwargs
def __ror__(self, arg):
return self.func(arg, *self.args, **self.kwargs)
@runekaagaard
runekaagaard / last-daemon.sh
Last active April 26, 2021 14:17
Run multiple dev servers in parallel with a single command. Each line has a colored prefix. CTRL+C closes all. Requires GNU parallel.
#!/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
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 November 2, 2019 12:53
POC Python Change Monitor of generic nested data
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 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.

@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
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.
"""