Skip to content

Instantly share code, notes, and snippets.

View acdha's full-sized avatar

Chris Adams acdha

View GitHub Profile
acdha / Podman as a Docker Desktop
Last active July 13, 2024 06:05
Instructions for using Podman as a replacement on MacOS

Podman as a Docker Desktop alternative


  1. Install Homebrew from

Install Podman

$ brew install podman
acdha /
Created June 12, 2015 22:32
Ways to get the name of a Unicode block for a character in Python
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import requests
acdha /
Last active July 11, 2024 02:36
Python 3: serve the current directory as HTTP while setting CORS headers for XHR debugging
#!/usr/bin/env python3
# encoding: utf-8
"""Use instead of `python3 -m http.server` when you need CORS"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
acdha / pre-commit
Last active April 18, 2024 02:22
Git pre-commit hook which runs various code linters. Install this to .git/hooks/pre-commit inside your favorite repos
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
"""Git pre-commit hook which lints Python, JavaScript, SASS and CSS"""
from __future__ import absolute_import, print_function, unicode_literals
import os
import subprocess
import sys
acdha /
Created February 26, 2014 21:19
Example of how to filter or apply custom formatting using Python's logging library
#!/usr/bin/env python
# encoding: utf-8
from pprint import pformat, pprint
import logging
class PasswordMaskingFilter(logging.Filter):
"""Demonstrate how to filter sensitive data:"""
acdha /
Last active May 28, 2023 07:12
Ensure that AWS security groups have a list of the current Cloudflare CIDR ranges
#!/usr/bin/env python3
Ensure that every security group tagged with 'AllowCloudflareIngress' has
an ingress rule allowing HTTPS in from every public Cloudflare edge IPv4 and
IPv6 CIDR block.
Note that HTTP is intentionally not enabled: use the always-HTTPS page rule for
that to avoid potential security problems.
acdha / newsblur.opml
Created May 15, 2023 14:08
Tech-related NewsBlur subscriptions
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.1">
<!--Generated by NewsBlur ->
<title>NewsBlur Feeds</title>
<dateCreated>2023-05-15 14:04:44.095425</dateCreated>
<dateModified>2023-05-15 14:04:44.095425</dateModified>
<outline text="Web" title="Web">
acdha /
Last active February 20, 2023 14:39
Django Haystack backend support for Solr's Collapsing query parser and Expand component
# encoding: utf-8
Experimental SearchQuerySet exposing Solr's Collapse filter and Expand component
sqs = sqs.collapse('item_grouping', sort='"score DESC, wdl_id ASC"')
sqs = sqs.expand(rows=2, fq='django_ct:core.file')
acdha /
Last active January 21, 2023 01:33
Example of how to exclude Nones from JSON-encoded output, optionally destructively
#!/usr/bin/env python3
Example of how to non-destructively remove None values from an object before
JSON serialization
import json
def filter_nones(obj):
"plugins": [
"extends": "stylelint-config-standard",
"rules": {
"indentation": 4,
"function-comma-newline-after": "always-multi-line",
"function-comma-space-after": "always",
"function-parentheses-newline-inside": "always-multi-line",