Skip to content

Instantly share code, notes, and snippets.

View adamcharnock's full-sized avatar

Adam Charnock adamcharnock

View GitHub Profile
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
@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 (
@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 / 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 / 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

Checklist

  • Celery report:
$ celery -A celery_tasks report

software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:3.6.1
            billiard:3.5.0.2 py-amqp:2.1.4
platform -> system:Darwin arch:64bit imp:CPython
0.000 2016-08-22 19:50:18; Factorio 0.13.17 (build 23946, mac, steam)
0.000 Operating system: Mac OS X 10.11.5
0.000 Program arguments: "/Users/adam/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app"
0.000 Read data path: /Users/adam/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/data
0.000 Write data path: /Users/adam/Library/Application Support/factorio
0.000 Binaries path: /Users/adam/Library/Application Support/Steam/steamapps/common
0.017 Graphics options: [FullScreen: true] [VSync: true] [UIScale: 100%] [MultiSampling: OFF] [Graphics quality: normal] [Video memory usage: high] [Light scale: 100%] [Screen: 255] [DXT: false]
0.017 Available display adapters: 1
0.017 [0]: resolution 1440x900px at [0,0]
0.017 Create display on adapter 0. Size 1280x720 at position [70, 72].
$ flynn run locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
import React from 'react';
import Relay from 'react-relay';
export default class ${NAME} extends React.Component {
static propTypes = {};
static defaultProps = {};
render() {
return (
from django import forms
from django.forms import fields
from singledispatch import singledispatch
from graphene.core.types.scalars import ID, Boolean, Float, Int, String
from graphene.contrib.django.fields import ConnectionOrListField, DjangoModelField
try:
UUIDField = forms.UUIDField
except AttributeError: