Skip to content

Instantly share code, notes, and snippets.

View singingwolfboy's full-sized avatar
Available for contract work

David Baumgold singingwolfboy

Available for contract work
View GitHub Profile
@singingwolfboy
singingwolfboy / flask_csrf_test_client.py
Last active April 4, 2024 12:26
Want to run your Flask tests with CSRF protections turned on, to make sure that CSRF works properly in production as well? Here's an excellent way to do it!
# Want to run your Flask tests with CSRF protections turned on, to make sure
# that CSRF works properly in production as well? Here's an excellent way
# to do it!
# First some imports. I'm assuming you're using Flask-WTF for CSRF protection.
import flask
from flask.testing import FlaskClient as BaseFlaskClient
from flask_wtf.csrf import generate_csrf
# Flask's assumptions about an incoming request don't quite match up with
@singingwolfboy
singingwolfboy / audiveris.rb
Last active April 29, 2023 11:36
Work-in-progress Homebrew formula for installing Audiveris
class Audiveris < Formula
desc "Optical Music Recognition"
homepage "https://audiveris.github.io/audiveris/"
url "https://github.com/Audiveris/audiveris.git",
# tag: "development",
revision: "f29f417386e3d9c68b3a4103cfaf48239769ac58"
version "5.3-beta"
license "AGPL-3.0"
depends_on "gradle" => :build
@singingwolfboy
singingwolfboy / error.log
Last active February 16, 2023 13:03
Failing build for torchaudio
[ 43%] Building CXX object torchaudio/csrc/CMakeFiles/_torchaudio_ffmpeg.dir/ffmpeg/pybind/pybind.cpp.o
cd /tmp/torchaudio-20230216-95817-nuezt6/build/torchaudio/csrc && /opt/homebrew/Library/Homebrew/shims/mac/super/clang++ -DUSE_C10D_GLOO -DUSE_DISTRIBUTED -DUSE_RPC -DUSE_TENSORPIPE -D_torchaudio_ffmpeg_EXPORTS -I/tmp/torchaudio-20230216-95817-nuezt6 -isystem /opt/homebrew/include/torch/csrc/api/include -Wall -O3 -DNDEBUG -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -fPIC -std=gnu++14 -MD -MT torchaudio/csrc/CMakeFiles/_torchaudio_ffmpeg.dir/ffmpeg/pybind/pybind.cpp.o -MF CMakeFiles/_torchaudio_ffmpeg.dir/ffmpeg/pybind/pybind.cpp.o.d -o CMakeFiles/_torchaudio_ffmpeg.dir/ffmpeg/pybind/pybind.cpp.o -c /tmp/torchaudio-20230216-95817-nuezt6/torchaudio/csrc/ffmpeg/pybind/pybind.cpp
In file included from /tmp/torchaudio-20230216-95817-nuezt6/torchaudio/csrc/ffmpeg/pybind/pybind.cpp:1:
In file included from /opt/homebrew/include/pybind11/stl.h:12:
In file included from /opt/homebrew

Hello everyone! The edX team has been hard at work upgrading Open edX to use Django 1.8 instead of 1.4. This change just landed on edx.org, and since things seem to be stable there, we're going to merge the change back to master today. Here's what you need to know.

  • If you are using an Open edX release, this change will NOT affect you until you upgrade to Dogwood. You can stop reading now. (Dogwood will be the next Open edX release after Cypress, and it has not been cut yet.)
  • Django 1.8 does some things differently from Django 1.4. If you are doing any development on the Open edX platform, please review the upgrade release notes that the edX team has put together: https://openedx.atlassian.net/wiki/display/TNL/Django+1.8+Upgrade+Release+Notes
  • The edX team has put a lot of effort into researching the best way to upgrade everyone's devstacks, and has found that the best way forward is to build a new devstack. A new image has been built to support both Django 1.8 and python 2.7.10. Today we will merge Dja
{
"title": "JSONPgSmartTags",
"type": "object",
"properties": {
"version": {
"type": "number",
"minimum": 1
},
"config": {
"type": "object",
@singingwolfboy
singingwolfboy / PgTypesLibphonenumberPlugin.ts
Last active February 14, 2020 17:55
A plugin for Postgraphile that provides support for the "phone_number" type from pg_libphonenumber: https://github.com/blm768/pg-libphonenumber Note that this support requires installing libphonenumber-js on the Postgraphile server: https://github.com/catamphetamine/libphonenumber-js
import { Plugin, Build, ScopeGraphQLScalarType } from "graphile-build";
import { PhoneNumber, parsePhoneNumber } from "libphonenumber-js";
declare module "graphile-build" {
interface ScopeGraphQLScalarType {
isPhoneNumberScalar: boolean;
}
}
export default (function PgTypesLibphonenumberPlugin(builder) {
@singingwolfboy
singingwolfboy / 1-schema.sql
Last active September 22, 2019 14:28
I want to create a `@relationTargetColumn` smart comment, for making relationships that target only a single column in a table instead of an entire object. Ideally, other columns on the relationship should appear in the edge data. This is an example of what I want to create, but I'm not sure what's the best way to get started...
drop schema if exists sh cascade;
create schema sh;
create table sh.hero (
id serial primary key,
species text
);
create table sh.hero_name (
id serial primary key,
@singingwolfboy
singingwolfboy / PgEnhancedManyToManyRelationPlugin.js
Created August 27, 2019 11:12
Based on https://github.com/graphile-contrib/pg-many-to-many, but generates two connections/edges per many-to-many relation so that values on the junction table can be exposed on the connection edges. Not fully functional.
// Given a `leftTable`, trace through the foreign key relations
// and identify a `junctionTable` and `rightTable`.
// Returns a list of data objects for these many-to-many relations.
function manyToManyRelations(leftTable, build) {
const {
pgIntrospectionResultsByKind: introspectionResultsByKind,
pgOmit: omit,
} = build;
return leftTable.foreignConstraints
@singingwolfboy
singingwolfboy / PgManyToManyRelationArgConditionPlugin.js
Created July 23, 2019 14:52
I'm trying to build a PostGraphile plugin that works with the PgManyToManyRelationPlugin (https://github.com/graphile-contrib/pg-many-to-many) but adds a `condition` argument, inspired by the built-in PgConnectionArgCondition plugin, that allows filtering the junction table. I think I'm almost there, but the structure of the query in PgManyToMan…
const flatten = require("lodash/flatten");
module.exports = (function PgManyToManyRelationArgCondition(builder) {
builder.hook(
"init",
(_, build) => {
const {
newWithHooks,
pgIntrospectionResultsByKind: introspectionResultsByKind,
pgGetGqlInputTypeByTypeIdAndModifier,
@singingwolfboy
singingwolfboy / pg-libphonenumber.rb
Created July 15, 2019 17:43
[pg-libphonenumber](https://github.com/blm768/pg-libphonenumber) formula for [Homebrew](https://brew.sh/). Still needs a released version before it can be merged to [homebrew-core](https://github.com/Homebrew/homebrew-core).
class PgLibphonenumber < Formula
desc "libphonenumber extension for Postgres"
homepage "https://github.com/blm768/pg-libphonenumber"
url "https://github.com/blm768/pg-libphonenumber/archive/master.zip"
version "0.1.0"
sha256 "5b29e96e96eba790e856e0624724a548bba82dfd0a3dc314eafd2ac3ace92e0f"
depends_on "libphonenumber"
depends_on "postgresql"
def install