Skip to content

Instantly share code, notes, and snippets.

View anys.py
import re
class AnyDict(dict):
"""
>>> AnyDict(foo=1) == {"foo": 1, "bar": 2}
True
>>> AnyDict(foo=2) == {"foo": 1, "bar": 2}
False
"""
View safe.py
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 Sep 5, 2019
A simple host based step for github actions to post to slack, no docker needed
View github-action-step-post-slack.yaml
- 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*' \
View a-MAZE-ing.txt
$ python maze.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## # # # # ####### # ### # ### # # # # # # ### # # # ### ### ### ##### ### # ### # ##### ### ########### # # # # # # ###
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## # # ### # # # ##### # # # # # ##### ### # ### ##### # # ### ##### ##### ####### # # # # # ### ### # # # # # ### # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## ##### # ### # ### # ### ##### # # ##### # # # ##### ### # ####### # # ##### # # ############# # ##### ##### #########
# # # # # # # # # # # #
View dungeon.txt
########################## #############################################################################################
########################## ################# ############################## ########### ################################
### ####### ############# ############### ########### ########### ################### #########
# ### ### # # ############# ############### ########### #### ## ############# #########
### ### ######### ############## #### ########### #### #### ############# #########
### ### ######### ############## #### ########### #### ### ############# ### #
#### ###### ######### ############## #### ########### #### ### ############# ### #
#### ############## #### ########### #### #
#### ###### ## ###### ##############
@mdellavo
mdellavo / buildbot-slack.py
Created Feb 13, 2019
Buildbot plugin to post build notifications to slack
View buildbot-slack.py
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
View sortable_none.py
from functools import total_ordering
@total_ordering
class SortableNone(object):
def __eq__(self, other):
return self is other
def __le__(self, other):
return True
@mdellavo
mdellavo / InspIRCd-README.md
Last active Jan 11, 2019
Basic setup of an InspIRCd IRC server instance for Ubuntu
View InspIRCd-README.md

Basic InspIRCd Setup

  • SSL only
  • valid Let's Encrypt cert.
  • unbound for upstream dns queries
  • simplified admin config for small team
# install ircd
sudo apt-get install inspircd unbound
View gist:1445a367a0b8ce88f57daae648261f7d
('Module',
{'body': [('FunctionDef',
{'args': ('arguments',
{'args': [],
'defaults': [],
'kw_defaults': [],
'kwarg': None,
'kwonlyargs': [],
'vararg': None},
{}),
View safe_string.md

SafeString

A subclass of string that protects from unauthorized representation, returning a masked value.

class BasicChecker(object):
    def __init__(self, allowed):
        self.allowed = allowed

    def check_can_show(self):