Skip to content

Instantly share code, notes, and snippets.


Sander van de Graaf svdgraaf

Block or report user

Report or block svdgraaf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
svdgraaf /
Created Oct 1, 2019
vcrpy example
import os
import requests
import unittest
import vcr
dir_path = os.path.dirname(os.path.realpath(__file__))
dd_vcr = vcr.VCR(
cassette_library_dir="%s/cassettes" % dir_path,
#!/usr/bin/env python
import os
import time
from slackclient import SlackClient
slack_token = os.environ["SLACK_API_TOKEN"]
sc = SlackClient(slack_token)
stuff = {
"<@U8Q1UCGPM>": 243, # This is the slack user id
"@whatever": 2, # Regular stuff also works
svdgraaf /
Last active Jun 27, 2018
Embed lambda functions in cloudformation
# pip install pyminifier
# pip install yaml
import subprocess
import os
import sys
current_dir = os.path.dirname(os.path.abspath(__file__))
import yaml
svdgraaf /
Last active Mar 22, 2017
Update AWS instance hosts file with all internal dns names for VPC members. Useful when dns discovery is not useable/available.
#!/usr/bin/env python
import boto3
import requests
ec2 = boto3.resource('ec2')
# fetch the instance id
response = requests.get('')
instance_id = response.text
svdgraaf / buildspec.yaml
Created Jan 6, 2017
AWS CodePipeline CloudFormation template length workaround
View buildspec.yaml
version: 0.1
- pip install awscli

Keybase proof

I hereby claim:

  • I am svdgraaf on github.
  • I am svdgraaf ( on keybase.
  • I have a public key ASCNRi7ZhWzZoXGXEv3E6dxE6R62g1x_e5w_22l1u0ZrJgo

To claim this, I am signing this object:

import pygraphviz as pgv
class MachineGraph(object):
def get_graph(self, title=None):
"""Generate a DOT graph with pygraphviz."""
state_attrs = {
'shape': 'circle',
'height': '1.2',
svdgraaf /
Created Nov 17, 2013
Simple ImageMagick Copyright and timestamp bar to any image
convert [inputfilename.jpg] -gravity north -background black -extent [width]x[height] +repage -box black -fill white -pointsize 12 -gravity southwest -annotate +3+3 '(c)Unicorns and magic sparkledust inc.' -gravity southeast -annotate +3+3 "`date +%H:%I`" -quality 99% output.png
svdgraaf / cards.json
Last active Nov 4, 2018
Raspi RFID scanner
View cards.json
"170038E91C": "1003729691",
"17003F5A1D": "1004151834"
svdgraaf / abtest.vcl
Last active Dec 26, 2015
AB testing with Varnish (and Django)
View abtest.vcl
# import the abtesting vmod
import abtest;
sub vcl_deliver {
# only continue, if the config file with all the rules can be loaded
if (abtest.load_config("/etc/varnish/abtest-rules.cfg") == 0) {
# if there isn't a named cookie 'ab' in the request, we can add one
if (req.http.Cookie !~ "ab=") {
You can’t perform that action at this time.