Skip to content

Instantly share code, notes, and snippets.

View bpartridge's full-sized avatar

Brenton Partridge bpartridge

View GitHub Profile
@bpartridge
bpartridge / patch_geos.py
Created December 19, 2021 04:08
Django GEOS patch for macOS arm64
def patch_geos_signatures():
"""
Patch GEOS to function on macOS arm64 and presumably
other odd architectures by ensuring that call signatures
are explicit, and that Django 4 bugfixes are backported.
Should work on Django 2.2+, minimally tested, caveat emptor.
"""
import logging
@bpartridge
bpartridge / requests_proxy_headers_3.py
Last active November 10, 2019 21:25
requests patch/adapter to capture CONNECT response headers (Python 3)
# https://stackoverflow.com/questions/39068998/reading-connect-headers
# updated for Python 3
# WARNING: barely tested
import socket
import requests
from urllib3.connection import HTTPSConnection
from urllib3.connectionpool import HTTPSConnectionPool
from urllib3.poolmanager import ProxyManager
@bpartridge
bpartridge / clubhouse-userscript-contents.js
Last active May 15, 2019 19:13
Clubhouse.io Userscript
$(function() {
$('<style>').text(`
/* HIDE STORY IDS */
.story-badges .story-id .badge-text {
font-size: 0 !important;
width: 0;
line-height: 0;
margin-left: -1px;
margin-right: -3px;
}
@bpartridge
bpartridge / hooks.md
Last active June 10, 2022 09:29
React Hooks as Python decorators

So Hooks finally started to "click" for me when I realized they're very similar to Python decorators. In fact, they're essentially Python-like decorators, curried against the renderer, in an alternate syntax that reduces duplicate typing.

To be clear: I'm NOT advocating for Hooks moving towards decorator syntax, and I agree with the reasons why this suggestion isn't the right direction to move. But I think that the comparison with decorators is useful nonetheless, and perhaps could guide some of the ways in which we introduce Hooks to skeptical stakeholders.

Consider, for a moment, that Python almost adopted this syntax: https://www.python.org/dev/peps/pep-0318/#community-consensus ...

using:
    classmethod
 synchronized(lock)
<svg width='813px'
height='386.9994px'
viewBox='0 0 813 386.9994'
xmlns='http://www.w3.org/2000/svg'
xmlns:xlink="http://www.w3.org/1999/xlink">
<style type='text/css'>
.keycap .border { stroke: black; stroke-width: 2; }
.keycap .inner.border { stroke: rgba(0,0,0,.1); }

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

# This file extends and overrides parts of the ActiveAdmin DSL and internals
# in order to provide support for automatically displaying and editing images,
# which in our infrastructure are stored as URLs whose column names end in "img".
# Since this file will be reloaded frequently in the development environment,
# all operations done at load time (class_eval's, etc.) MUST be idempotent.
ActiveAdmin::Views::TableFor.class_eval do
def img_column(col_sym=:img, title="Image")
column title, sortable: false do |obj|
@bpartridge
bpartridge / Makefile
Created January 31, 2014 00:21
Python and Numpy for Xeon Phi
PY_VER = 2.7.3
SRC = $(shell readlink -f python)
MIC_PY_HOME = $(SRC)/_install
MIC_PY_PATH = $(MIC_PY_HOME)/lib/python2.7
CTYPES = $(SRC)/Modules/_ctypes
all: $(MIC_PY_PATH)/_ctypes
install:
@echo "To install, copy $(MIC_PY_HOME) where it can be accessed from the MIC card."
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bpartridge
bpartridge / LICENSE.txt
Created July 8, 2012 06:30 — forked from p01/LICENSE.txt
Music SoftSynth
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri http://www.p01.org/releases/
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE