Skip to content

Instantly share code, notes, and snippets.

View adhorn's full-sized avatar

Adrian Hornsby adhorn

View GitHub Profile
#!/usr/bin/env python
import optparse
import sys
from boto.s3.connection import S3Connection
def sign(bucket, path, access_key, secret_key, https, expiry):
c = S3Connection(access_key, secret_key)
return c.generate_url(
expires_in=long(expiry),
@adhorn
adhorn / autoscale_sample
Created December 3, 2012 21:50 — forked from liamf/autoscale_sample
Demonstrates using patched boto to create an autoscaling group of servers, scaled up/down by CPU Utilisation
#################################################################################
# Import modules
#################################################################################
import os
import time
import sys
import socket
import string
@adhorn
adhorn / gitconfig
Last active November 4, 2015 12:26
Configuration file for GIT awesomness
[user]
name = Foo
email = foo@bar.com
[core]
excludesfile = /home/foobar/.gitignore_global
# color {{{
[color]
branch = auto
@adhorn
adhorn / ssim-tests.py
Created August 4, 2017 15:24 — forked from ranman/ssim-tests.py
ssim-tests
import io
import os
import pprint
import boto3
import cv2
import numpy as np
from PIL import Image, ImageOps
from skimage import img_as_float
from skimage.measure import compare_ssim as ssim
@adhorn
adhorn / gist:0cad81d5fa394b98824e1c540bc24588
Created April 24, 2018 07:20
Test DynamoDB Global Tables
aws dynamodb put-item \
--table-name MyGlobalTable \
--item '{"item_id": {"S":"foobar"}}' \
--region eu-west-1
# then you can test by fetching the item created from tthe other region enabled.
aws dynamodb get-item \
--table-name MyGlobalTable \
--key '{"item_id": {"S":"foobar"}}' \
--region eu-central-1
@adhorn
adhorn / gist:a2f5a29a3ad3c20bc3dd21f61cca5861
Created April 24, 2018 11:51
Deploying using the serverless framework
# Deploy in the eu-west-1 region
serverless deploy --region eu-west-1
# Deploy in the eu-central-1 region
serverless deploy --region eu-central-1
(I am using the httpie https://httpie.org/ commandline tool)
http https://<YOUR API>.execute-api.eu-central-1.amazonaws.com/dev/get/foobar  ✔  14:49:30
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 112
Content-Type: application/json
Date: Tue, 24 Apr 2018 12:01:50 GMT
X-Amzn-Trace-Id: sampled=0;root=1-5adf1cae-c2edf25c6a7545c3e172478f
x-amz-apigw-id: F2FrSHB0liAFo4Q=
http POST https://<YOUR API>.execute-api.eu-west-1.amazonaws.com/dev/create "item_id"="barfoo"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Date: Tue, 24 Apr 2018 12:04:38 GMT
X-Amzn-Trace-Id: sampled=0;root=1-5adf1d55-50b949696dfd3547bb7f9f28
x-amz-apigw-id: F2GFbE1WDoEFuGA=
x-amzn-RequestId: a94e2c6f-47b7-11e8-8354-892b5fef891a
http https://globe.adhorn.me/get/foobar
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 112
Content-Type: application/json
Date: Tue, 24 Apr 2018 14:26:10 GMT
X-Amzn-Trace-Id: sampled=0;root=1-5adf3e82-30d3c630cf5b16ebbdceaf04
x-amz-apigw-id: F2a0YEk6FiAFWUw=
x-amzn-RequestId: 6f3a6121-47cb-11e8-8f1d-618431149814