Skip to content

Instantly share code, notes, and snippets.

@anentropic
anentropic / reflection.json
Created April 24, 2021 09:42
GraalVM native-image reflection config for Log4J
[
{
"name" : "org.apache.log4j.Category",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
},
@anentropic
anentropic / morelia.py
Last active June 24, 2019 15:04
Per-scenario test methods in Morelia
import os
import re
import unicodedata
from django.conf import settings
from morelia import run
from morelia.grammar import Scenario
from morelia.parser import Parser
@anentropic
anentropic / SketchSystems.spec
Last active June 23, 2020 17:00
CHECKOUT FLOW
CHECKOUT FLOW
View bag*
checkout -> Checkout summary
Checkout summary
buy -> Reserve stock
Reserve stock
Lock product*
locked -> Insert purchase record
failed -> Error
Insert purchase record
@anentropic
anentropic / show_locks.sql
Last active January 24, 2020 14:30
(Postgres) Function to preview locks acquired by a schema change
-- Usage:
-- ---------------------------
-- BEGIN;
-- <statements to analyze: ALTER TABLE ...whatever...;>
-- SELECT * FROM show_locks();
-- ROLLBACK;
-- ---------------------------
CREATE OR REPLACE FUNCTION show_locks()
RETURNS TABLE (
"lock_type" VARCHAR,
@anentropic
anentropic / test_pyparsing_indented.py
Last active November 27, 2017 15:13
Test cases for my attempted pyparsing 'docstring' grammar
from collections import namedtuple
from functools import partial
import re
import pyparsing as pp
import pytest
def _flatten(tokens):
# type: (pp.ParseResults) -> pp.ParseResults
@anentropic
anentropic / test_pyparsing_grammar.py
Last active November 25, 2017 22:38
pyparsing grammar tests
from collections import namedtuple
import re
import pytest
from myproject import grammar
EXAMPLES = (
pytest.param(
@anentropic
anentropic / hyper.js
Created August 15, 2017 14:41
hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
class CustomQuerySetManager(Manager):
"""
A re-usable Manager to access a custom QuerySet
"""
def __getattr__(self, attr, *args):
try:
return getattr(self.__class__, attr, *args)
except AttributeError:
# don't delegate internal methods to queryset
# NOTE: without this, Manager._copy_to_model will end up calling
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: git getpull <SHA>"
exit 1
elif [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then
echo "Not in a git directory"
exit 1
else
repo_details=( \
@anentropic
anentropic / retry.py
Last active August 29, 2015 14:18
retry context manager
import time
from logging import getLogger
class RetryContextInvalidResult(Exception):
pass
class RetryContext(object):