Skip to content

Instantly share code, notes, and snippets.

@tzengerink
tzengerink / deploy.sh
Last active December 13, 2016 15:46
Gunicorn Deploy Script
#!/bin/bash -e
#
# GUNICORN DEPLOY SCRIPT
# ----------------------
# Script to deploy your application with Gunicorn. It can be called by your
# process manager (eg. supervisor). Your application should use a virtual
# environment in a subdirectory.
#
# Copyright (c) 2013-2014, T. Zengerink
# Licensed under MIT License.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
BROWSER
-------
Get internet pages, send post requests, inspect HTML using BeautifulSoup
or simply check response codes of an URL.
Example usage:
@tzengerink
tzengerink / firewall.sh
Last active December 16, 2015 23:58
Bash script for setting up your firewall. It supports whitelisting and blacklisting.
#!/bin/bash -e
#
# IPTABLES FIREWALL
# -----------------
# Script for setting your iptables firewall. Configure the variables to your
# liking and start the firewall. Copy the file to `/usr/local/sbin` or the
# directory of your choice.
#
# Usage: `./firewall.sh [restart|start|stop|status]`
#
@tzengerink
tzengerink / application.py
Last active August 29, 2015 13:57
Python web application returning the visitors IP address
#!/usr/bin/env python
"""
IP
~~
Return visitors public IP address.
Copyright (c) 2014 Teun Zengerink
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@tzengerink
tzengerink / OAuthConsumer.md
Last active August 29, 2015 14:01
Consume an API that uses OAuth

OAuth Consumer

Consumes an API that uses OAuth.

Copy the file example.service.cnf to service.cnf and change the configuration variables to your liking, then:

$> python2 oauth-consumer.py [http method] [uri] [data]

For example:

deploy:
git checkout master
aws s3 sync . s3://pace.zengerink.com --cache-control "public, max-age=604800" --exclude ".git/*" --exclude "Makefile"
@tzengerink
tzengerink / application.py
Last active August 29, 2015 14:08
Minimal Flask Application
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def ip():
return request.environ['REMOTE_ADDR'] + '\n'
if __name__ == '__main__':
app.run()
@tzengerink
tzengerink / README.md
Last active August 29, 2015 14:10
Go web application returning the visitors IP address

IP

Go web application returning visitors IP address.

@tzengerink
tzengerink / README.md
Last active August 29, 2015 14:10
Serve files in a public S3 bucket downloadable through a different domain

PUBLIC

Make files in a public S3 bucket downloadable through a different domain.

@tzengerink
tzengerink / reorganize.py
Last active August 29, 2015 14:16
Store each extension in a directory, in a seperate folder within that directory
#!/usr/bin/env python
'''
REORGANIZE
----------
When your directory looks something like this:
/path/to/dir/photo-1.jpg
/path/to/dir/photo-2.JPG
/path/to/dir/video-1.mp4