Skip to content

Instantly share code, notes, and snippets.

View pmalmgren's full-sized avatar

Peter Malmgren pmalmgren

View GitHub Profile
@pmalmgren
pmalmgren / up.sql
Created September 16, 2021 19:20
gating migrations in SQL
CREATE OR REPLACE FUNCTION raise_notice(text)
RETURNS void AS $$
BEGIN
RAISE NOTICE '%', $1;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION acquire_lock(bigint)
RETURNS bool AS $$
BEGIN
@pmalmgren
pmalmgren / Dockerfile
Last active November 6, 2020 12:44
Orphan Process Handling in Docker
FROM python:3.9-alpine
COPY parent.py .
COPY child.py .
ENTRYPOINT ["python", "parent.py"]
@pmalmgren
pmalmgren / launch.json
Created December 4, 2017 18:42
Debug Jest from vscode
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Tests",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"-i"
@pmalmgren
pmalmgren / parse_pytest.py
Last active March 29, 2017 19:23
Splits the output of a pytest file into the format: filename.py 5 failures
import re
import sys
start = re.compile('collected [0-9]+ items')
end = re.compile('=+ FAILURES =+')
fail = re.compile('F')
error = re.compile('E')
def split_failures(file_name):
with open(file_name) as file_handler:
@pmalmgren
pmalmgren / LICENSE
Last active January 13, 2024 16:05
Go proc connector example, detects when a process exits
Copyright 2022 Peter Malmgren
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OT
<snippet>
<content><![CDATA[
assert ${1:expected} == ${2:actual}, "expected {} received {}".format(
${1:expected}, ${2:actual}
)
]]></content>
<description>Custom Assert</description>
<tabTrigger>assert</tabTrigger>
<scope>source.python</scope>
</snippet>