Skip to content

Instantly share code, notes, and snippets.

Andy Stanton andystanton

Block or report user

Report or block andystanton

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
@andystanton
andystanton / Simple Python 3 HTTP 1.1 Server.md
Last active May 1, 2019
Simple Python 3 HTTP/1.1 Server
View Simple Python 3 HTTP 1.1 Server.md

What?

This is a Python 3 HTTP/1.1 server bound to 127.0.0.1 on port 8000 using only the standard library.

Why?

I wanted to start a simple Python 3 web server using HTTP 1.1 that is capable of responding with an arbitrary message and depends only on Python and standard library modules.

The BaseHTTPRequestHandler docs did not provide a working example that meets these requirements, and examples that I found on the web used the default of HTTP 1.0 which does not require the Content-Length header to be set on the response.

@andystanton
andystanton / JVM DNS TTL Policy.md
Last active Aug 20, 2019
A script that inspects the DNS TTL for a JVM in a supplied Docker image.
View JVM DNS TTL Policy.md

A script that inspects the DNS TTL for a JVM in a supplied Docker image. The image must also contain a JDK.

It does this by generating a Docker image containing a Java program that outputs the JVM's DNS TTL and executing this, then cleaning up the container, image and temporary files.

Usage

$ ./jvm-dns-ttl-policy.sh openjdk:8
@andystanton
andystanton / Start up local Docker Machine on OSX automatically.md
Last active Dec 16, 2019
Start up local Docker Machine on OSX automatically.
View Start up local Docker Machine on OSX automatically.md

Notice

This script is no longer required with Docker for Mac which includes an option to run Docker at startup and doesn't use docker-machine to administer the local Docker engine.

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).
View lightbox.rb
# A Liquid tag for Jekyll sites that allows embedding Lightbox images.
#
# Adapted to work with http://lokeshdhakar.com/projects/lightbox2/
# as well as allowing remote image urls and commas in image titles.
#
# original author: kyoendo
# modified by: andystanton
#
# original Source URL: https://gist.github.com/4035604
# modified Source URL: https://gist.github.com/andystanton/6629cca760df386a0726
@andystanton
andystanton / ghost2jekyll.py
Last active Jul 30, 2017
Ghost2Jekyll: Converts ghost 0.4.2 sqlite db posts to jekyll 2.3.0 markdown posts.
View ghost2jekyll.py
#!/usr/bin/env python3
# This script is provided to show how I migrated from Ghost 0.4.2
# to Jekyll 2.3.0 and is used at your own risk. Back up your blog
# before trying it out.
def getPostTemplate():
with open('post-template.md', 'r') as f:
posttemplate = f.read()
f.closed
You can’t perform that action at this time.