Skip to content

Instantly share code, notes, and snippets.

@mdellavo
mdellavo / fdb-mapper.py
Last active January 16, 2024 15:45
WIP: Document mapper for FoundationDB
import dataclasses
import datetime
import itertools
import struct
from typing import TypeVar, Optional, Any, Type, TypedDict
import fdb
from fdb.impl import Transaction
from fdb.subspace_impl import Subspace
eval "$(pyenv init --path 2>/dev/null)"
eval "$(pyenv init - 2>/dev/null)"
eval "$(pyenv virtualenv-init - 2>/dev/null)"
export PS1='($(pyenv version-name)) '$PS1
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWCOLORHINTS=true
if [ -f /usr/local/etc/bash_completion.d/git-prompt.sh ]; then
source /usr/local/etc/bash_completion.d/git-prompt.sh
@mdellavo
mdellavo / arch-aarch64-install-raspberry-pi.md
Last active December 16, 2021 01:51
Prepare an ArchLinux Image for a Raspberry Pi
import abc
from enum import unique
import json
import datetime
import dataclasses
from typing import Optional
from sqlalchemy import Column, Integer, String, DateTime, JSON, Index, select, create_engine, and_
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import registry, sessionmaker
import re
class AnyDict(dict):
"""
>>> AnyDict(foo=1) == {"foo": 1, "bar": 2}
True
>>> AnyDict(foo=2) == {"foo": 1, "bar": 2}
False
"""
SAFE = True
MASK = "*"
def mask(val):
return MASK * len(val)
def value(val):
return mask(val) if SAFE else val
@mdellavo
mdellavo / github-action-step-post-slack.yaml
Last active September 5, 2019 17:20
A simple host based step for github actions to post to slack, no docker needed
- name: Build failure
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL: ...
run: |
curl -X POST \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-d channel=$SLACK_CHANNEL \
-d text='[${{ github.repository }}] ${{ github.event.ref }} *FAILED*' \
$ python maze.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## # # # # ####### # ### # ### # # # # # # ### # # # ### ### ### ##### ### # ### # ##### ### ########### # # # # # # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## # # ### # # # ##### # # # # # ##### ### # ### ##### # # ### ##### ##### ####### # # # # # ### ### # # # # # ### # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## ##### # ### # ### # ### ##### # # ##### # # # ##### ### # ####### # # ##### # # ############# # ##### ##### #########
# # # # # # # # # # # #
########################## #############################################################################################
########################## ################# ############################## ########### ################################
### ####### ############# ############### ########### ########### ################### #########
# ### ### # # ############# ############### ########### #### ## ############# #########
### ### ######### ############## #### ########### #### #### ############# #########
### ### ######### ############## #### ########### #### ### ############# ### #
#### ###### ######### ############## #### ########### #### ### ############# ### #
#### ############## #### ########### #### #
#### ###### ## ###### ##############
@mdellavo
mdellavo / buildbot-slack.py
Created February 13, 2019 16:45
Buildbot plugin to post build notifications to slack
class SlackStatusBot(NotifierBase):
name = "SlackStatusBot"
def __init__(self, webhook_url):
super(SlackStatusBot, self).__init__(mode="all", watchedWorkers="all")
self.webhook_url = webhook_url
def isWorkerMessageNeeded(self, worker):
return True