Skip to content

Instantly share code, notes, and snippets.

Avatar
🎱
¯\_(ツ)_/¯

Sander van de Graaf svdgraaf

🎱
¯\_(ツ)_/¯
View GitHub Profile
@svdgraaf
svdgraaf / build
Created Sep 20, 2010
nginx + geo ip + secure download
View build
$ ./configure --add-module=/home/svdgraaf/tmp/nginx/ngx_http_bytes_filter_module-57365655ee44 --with-http_geoip_module --add-module=/home/svdgraaf/tmp/nginx/ngx_secure_download
@svdgraaf
svdgraaf / vcr.py
Created Oct 1, 2019
vcrpy example
View vcr.py
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,
path_transformer=vcr.VCR.ensure_suffix(".yml"),
@svdgraaf
svdgraaf / cards.json
Last active Nov 4, 2018
Raspi RFID scanner
View cards.json
{
"170038E91C": "1003729691",
"17003F5A1D": "1004151834"
}
@svdgraaf
svdgraaf / parse.py
Last active Jun 27, 2018
Embed lambda functions in cloudformation
View parse.py
# pip install pyminifier
# pip install yaml
import subprocess
import os
import sys
current_dir = os.path.dirname(os.path.abspath(__file__))
import yaml
View plusplus-karma-sync.py
#!/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
svdgraaf / nginx byte range on proxy request
Created Sep 20, 2010
nginx byte request on proxied file
View nginx byte range on proxy request
server {
listen *:80;
location = /crossdomain.xml {
root /var/www/html/;
}
location = /test.html {
root /var/www/html/;
}
@svdgraaf
svdgraaf / bitmovr.lua
Created Oct 4, 2010
nginx+lua+mod_cache+mod_proxy+RANGE
View bitmovr.lua
--
-- bitmovr.lua
-- simple lua webserver which starts to listen on a socket, and
-- forwards all GET calls it receives to a backend server
-- this is extremely lightweight, as it will move the bits from one
-- socket to another, without any disk i/o
--
-- Depends on md5, io, LuaSockets and Memcached.lua
--
-- Application flow:
@svdgraaf
svdgraaf / buildspec.yaml
Created Jan 6, 2017
AWS CodePipeline CloudFormation template length workaround
View buildspec.yaml
version: 0.1
phases:
pre_build:
commands:
- pip install awscli
build:
commands:
post_build:
commands:
@svdgraaf
svdgraaf / update_hosts_file.py
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.
View update_hosts_file.py
#!/usr/bin/env python
import boto3
import requests
ec2 = boto3.resource('ec2')
# fetch the instance id
response = requests.get('http://169.254.169.254/latest/meta-data/instance-id')
instance_id = response.text
View keybase.md

Keybase proof

I hereby claim:

  • I am svdgraaf on github.
  • I am svdgraaf (https://keybase.io/svdgraaf) on keybase.
  • I have a public key ASCNRi7ZhWzZoXGXEv3E6dxE6R62g1x_e5w_22l1u0ZrJgo

To claim this, I am signing this object: