Skip to content

Instantly share code, notes, and snippets.

View adamcharnock's full-sized avatar

Adam Charnock adamcharnock

View GitHub Profile
@adamcharnock
adamcharnock / howto.md
Last active June 18, 2020 01:48
Kubernetes install on Ubuntu 17.10 via kubeadm

Kubernetes install on Ubuntu 17.10 via kubeadm

Initial setup

apt-get update
apt-get upgrade
apt-get install curl

# Check VXLAN exists
@adamcharnock
adamcharnock / example.js
Last active March 2, 2018 00:59
Extracting a json scheme from Python 3 typing hinting (examples)
// Source: https://github.com/adamcharnock/lightbus/blob/master/experiments/types_to_jsonschema.py
// $ python experiments/types_to_jsonschema.py
// Example:
// def check_password(username: str, password: str) -> bool: pass
// Parameter schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
@adamcharnock
adamcharnock / move_issues.py
Created April 24, 2018 11:26
Python script to move all GitLab issues from one project to another
#!/usr/bin/env python3
import os
import gitlab
GITLAB_API_TOKEN = os.environ['GITLAB_API_TOKEN']
def main():
print("Logging into gitlab and fetching a list of projects...")
@adamcharnock
adamcharnock / pretty_request.py
Created December 13, 2018 12:51 — forked from defrex/pretty_request.py
A simple function to print a Django request the way requests are meant to be printed.
def pretty_request(request):
headers = ''
for header, value in request.META.items():
if not header.startswith('HTTP'):
continue
header = '-'.join([h.capitalize() for h in header[5:].lower().split('_')])
headers += '{}: {}\n'.format(header, value)
return (
679.056883 MainThread [NOLOOP ] Bus is opening
680.058956 MainThread [task 4399429288] Awaiting calls on the call queue
680.910110 MainThread [task 4399649656] -> One started
681.442022 dispatch_0 [NOLOOP ] --> Two started
683.099985 dispatch_0 [task 4399651832] ---> Three started
683.208942 dispatch_0 [task 4399651832] ----> Four started
683.764935 dispatch_1 [NOLOOP ] -----> Five started
683.855057 dispatch_1 [NOLOOP ] Adding callable to queue
684.042931 dispatch_1 [NOLOOP ] Awaiting execution completion
685.514927 MainThread [task 4399429288] Call received, executing