Skip to content

Instantly share code, notes, and snippets.

View techdragon's full-sized avatar

Samuel Bishop techdragon

View GitHub Profile
@cam8001
cam8001 / jq-aws.bash
Created February 18, 2021 01:26
AWS ip-ranges.json parsing with JQ examples
# Use jq to parse the published AWS IP ranges.
# Use the file from here: https://ip-ranges.amazonaws.com/ip-ranges.json
# Select all Cloudfront nodes homed to Sydney
jq .prefixes[] | select(.service == "CLOUDFRONT") | select(.network_border_group=="ap-southeast-2")
# Find s3 endpoints in Oregon
jq -r '.prefixes[] | select(.region=="us-east-2") | select(.service=="S3") | .ip_prefix' < ip-ranges.json
@psviderski
psviderski / settings.py
Created June 25, 2018 13:52
Python structlog with Sentry and Logstash integration
# This list contains all the attributes listed in
# http://docs.python.org/library/logging.html#logrecord-attributes
LOG_RECORD_ATTRIBUTES = {
'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
'funcName', 'levelname', 'levelno', 'lineno', 'message', 'module',
'msecs', 'msg', 'name', 'pathname', 'process', 'processName',
'relativeCreated', 'stack_info', 'thread', 'threadName',
}
BASIC_TYPES = (str, bool, int, float, type(None))
@stephanh42
stephanh42 / compose.py
Created October 26, 2017 11:42
Attempt at efficient funciton composition on Python
from functools import lru_cache
def identity(x):
return x
@lru_cache(None)
def _make_compose(n):
if n == 0:
return lambda: identity
elif n == 1:
"""Script for PyCharm so it's Django shell acts like
django-extesion's shell_plus
"""
# pycharm stuff
import sys;
print('Python %s on %s' % (sys.version, sys.platform))
import django;
print('Django %s' % django.get_version())

CockroachDB + Django ORM

cockroachdb/sqlalchemy-cockroachdb#14

TODO

  1. fork django/contrib/postgres driver
  2. patch blocking postgres compatibility issues
  3. review with cockroachdb team to see if any issues can be fixed by cockroach
  4. review with django team
  5. merge adapter as separate cockroachdb adapter
  6. write docs, any admin work, etc.
@dnmellen
dnmellen / models.py
Last active October 3, 2021 04:14
DynamoDB mixin for Django models: Mix Django fields and DynamoDB fields in your models!
import uuid
import boto3
from decimal import Decimal
from functools import partial
from django.db import models
from django.conf import settings
class UUIDModel(models.Model):
"""
@omz
omz / touchid.py
Last active November 16, 2025 11:15 — forked from alessaba/TouchID.py
TouchID.py
# coding: utf-8
from objc_util import *
import threading
NSBundle = ObjCClass('NSBundle')
LocalAuthentication = NSBundle.bundleWithPath_('/System/Library/Frameworks/LocalAuthentication.framework')
LocalAuthentication.load()
LAContext = ObjCClass('LAContext')
# authenticate() will raise one of these exceptions when authentication
@omz
omz / Pythonista Theme Editor.py
Last active November 16, 2025 10:49
Pythonista Theme Editor.py
# coding: utf-8
'''
Basic theme editor for Pythonista 1.6 (beta)
WARNING: Use at your own risk! User themes aren't "officially" supported, and
this may break in future versions. If you enter invalid JSON or anything else
that the app can't deal with, it *will* crash -- your input is not validated
in any way.
'''
@jsomers
jsomers / a-wotd-custom-word-list.md
Last active March 15, 2026 16:59
How to use a custom word list with OS X's "Word of the Day" screensaver

OS X's "Word of the Day" screensaver is a great way to passively learn words:

But I've always thought that its word list kind of stunk—it was full of obscure words that I could never really see myself using. I'd prefer something like Norman Schur's 1000 Most Important Words. What if you could plug your own word list into the screensaver?

On a rather obscure comment thread, someone explained where you might find the word list that Apple uses to power the screensaver. It is at /System/Library/Graphics/Quartz\ Composer\ Plug-Ins/WOTD.plugin/Contents/Resources/NOAD_wotd_list.txt. The file looks like this:

m_en_us1282510	quinsy
@cvrebert
cvrebert / css_regression_testing.md
Last active March 3, 2026 22:52
Survey of screenshot-based CSS testing tools

Currently considering https://github.com/webdriverio/webdrivercss


Core Goals:

  • Can test in up-to-date versions of all major browsers
  • Can test on up-to-date versions of all major OSes
  • Can test in IE9 (because Bootstrap v4 will support IE9+)
  • Don't want to have to setup/maintain our own cluster of VMs running all the necessary OSes (and all the versions of Windows)
  • Workflow for management of reference/baseline/norm screenshots