Skip to content

Instantly share code, notes, and snippets.

@coderanger
coderanger / README.md
Last active August 1, 2023 17:40
My incident report template

[My company] Incidents

This repository contains incident reports for all [my company] products and services.

How to document an incident?

Copy the template.md file to a new file named YYYY-mm-dd-title-of-incident.md, eg. 2021-09-08-database-outage.md. Make sure the date is correct for UTC rather than your local time zone, for California staff this might mean the incident happened "tomorrow". Then fill in all the fields in the template and create a Pull Request. The [my team] team will review and merge it.

What counts as an incident?

@coderanger
coderanger / craft.py
Created January 9, 2022 03:20
FarmRPG crafting calculator
import math
from typing import Optional
import attr
from frozendict import frozendict
@attr.s(auto_attribs=True, frozen=True)
class Item:
name: str
@coderanger
coderanger / login.py
Created June 5, 2021 22:19
DRF login view.
from typing import Optional
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import AbstractBaseUser
from rest_framework.exceptions import ParseError
from rest_framework.permissions import AllowAny
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.throttling import ScopedRateThrottle
from rest_framework.views import APIView
@coderanger
coderanger / __main__.py
Last active April 26, 2020 10:17
Django on Twisted with Prometheus
"""
Support for running `python -m myapp`.
"""
from myapp.wsgi import main
if __name__ == "__main__":
main()
@coderanger
coderanger / traefik.yaml
Created November 6, 2018 20:12
Traefik quick start
---
apiVersion: v1
kind: Namespace
metadata:
name: traefik
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: traefik
@coderanger
coderanger / Dockerfile
Last active August 17, 2018 00:51
Dockerfile snippet for Caddy build
###################
# Caddy build image
FROM abiosoft/caddy:builder
ARG caddy_version="0.11.0"
ARG caddy_plugins="cors,realip,expires,proxyprotocol,prometheus"
ENV ENABLE_TELEMETRY="false"
# Disable a bunch of standard plugins we don't need.
RUN sed -i "/# build/a sed -Ei '/caddyhttp.(basicauth|browse|fastcgi|markdown|templates|websocket)/d' /go/src/github.com/mholt/caddy/caddyhttp/caddyhttp.go" /usr/bin/builder.sh
@coderanger
coderanger / email.md
Created June 9, 2018 23:19
Crazy good spam

From: 7N5C 7n5corp@gmail.com

Subject: Converstion with you

Noah,

My name is Stella Hughes and I would like to have a conversation with you about a project I have been trying to develop for the past several years.

@coderanger
coderanger / pitch.md
Last active January 6, 2018 04:11
Old clan warfare idea I found

Clan Warfare Revamp Make-A-KoL

Elevator Pitch

Make clan war be a turned-based tower defense minigame. Towers and tower upgrades have an escalating cost so larger clans don't have an advantage. Each player gets one clan attack a day if they are participating and can attack either a random clan for material rewards or a specific clan for bragging rights points (similar to PvP).

@coderanger
coderanger / chef-server.rb
Created April 4, 2017 21:00
ssd's config example for Chef Server external stuffs
fqdn "FQDN"
postgresql['external'] = true
postgresql['vip'] = 'EXTERNAL_PG_IP'
postgresql['db_superuser'] = 'DB_SUPERUSER'
postgresql['db_superuser_password'] = 'DB_SUPERUSER_PASSWORD'
opscode_solr4['external'] = true
opscode_solr4['external_url'] = 'http://EXTERNAL_ES_IP:9200'
opscode_erchef['search_provider'] = 'elasticsearch'
opscode_erchef['search_queue_mode'] = 'batch'
bookshelf['storage_type'] = :sql
@coderanger
coderanger / make_diecut.py
Created September 6, 2016 03:05
Automatically extract diecut paths for an image.
#!/usr/bin/env python2
from __future__ import print_function
import argparse
import re
import sys
import attr
import cv2
import numpy