Skip to content

Instantly share code, notes, and snippets.

View audiolion's full-sized avatar
⌨️
coding

Ryan Castner audiolion

⌨️
coding
View GitHub Profile
@grantmcconnaughey
grantmcconnaughey / pdf.py
Last active February 8, 2021 21:50 — forked from zyegfryed/pdf.py
Outputting PDFs with Django 1.8 and FDFgen
# -*- coding: utf-8 -*-
import codecs
import subprocess
from fdfgen import forge_fdf
from django.core.exceptions import ImproperlyConfigured
from django.template import engines
from django.template.backends.base import BaseEngine
from django.template.engine import Engine, _dirs_undefined
@vasanthk
vasanthk / System Design.md
Last active April 30, 2024 12:30
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
from django.conf import settings
from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.views import generic
from dal import autocomplete
from hashids import Hashids
from . import forms
@lededje
lededje / gist:44aeddf1dc2a5e6064e3b29dc35a7a2d
Last active May 29, 2018 10:42
Jest Mocking Moment to *always* be utc for tests
jest.mock('moment', () => {
const moment = require.requireActual('moment');
return moment.utc;
});
@crucialfelix
crucialfelix / graphql_auth.py
Created August 4, 2017 19:03
django-graphene auth decorator
from decorator import decorator
def _check_auth(args, pred):
_, _, context, _ = args
if not pred(context):
raise Exception("Unauthorized")
@decorator
def is_user(fn, *args, **kwargs):
@androiddrew
androiddrew / apistar_util.py
Last active August 14, 2019 17:16
Apistar 0.4 Extended JSON Response, SQLAlchemy Component, and SQLAlchemy Hook
import datetime as dt
import decimal
import typing
from apistar import types
from apistar.http import JSONResponse, Response
from apistar.server.components import Component
from sqlalchemy.engine import Engine
from sqlalchemy.orm import sessionmaker, Session, scoped_session
@danigosa
danigosa / sentry_error_handler.py
Created May 4, 2018 11:48
Sentry Logger Event Hook for Python API Star 0.5+ (tested on 0.5.10)
import sys
from os import environ
import logging
from apistar import http
from raven import Client
from apistar import App
from apistar.test import TestClient
from apistar import Route
settings = {
// UPDATE: don't use this. when it re-partitions the list when time moves forward, it does not correctly keep hashes
// Use a real merkle tree instead: https://gist.github.com/jlongster/f431b6d75ef29c1a2ed000715aef9c8c
import Timestamp from './timestamp';
// This is a compact data structure that keeps track of a list of
// hashes (representing messages) over a range of time in order to
// figure out what has changed between clients, kinda like a Merkle
// tree. It creates "buckets" that represent different time ranges,
// and divides time into smaller buckets the more recent they are. The