Skip to content

Instantly share code, notes, and snippets.

@anentropic
anentropic / reflection.json
Created Apr 24, 2021
GraalVM native-image reflection config for Log4J
View reflection.json
[
{
"name" : "org.apache.log4j.Category",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
},
@anentropic
anentropic / morelia.py
Last active Jun 24, 2019
Per-scenario test methods in Morelia
View morelia.py
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
View SketchSystems.spec
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 Jan 24, 2020
(Postgres) Function to preview locks acquired by a schema change
View show_locks.sql
-- 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 Nov 27, 2017
Test cases for my attempted pyparsing 'docstring' grammar
View test_pyparsing_indented.py
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 Nov 25, 2017
pyparsing grammar tests
View test_pyparsing_grammar.py
from collections import namedtuple
import re
import pytest
from myproject import grammar
EXAMPLES = (
pytest.param(
View 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
View django_custom_manager.py
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
View git-getpull
#!/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 Aug 29, 2015
retry context manager
View retry.py
import time
from logging import getLogger
class RetryContextInvalidResult(Exception):
pass
class RetryContext(object):