Skip to content

Instantly share code, notes, and snippets.

Avatar

Rich Jones Miserlou

View GitHub Profile
@apetresc
apetresc / AWSDemo.java
Created December 31, 2010 08:30
A modified version of the AWS SDK for Android sample code which fetches credentials from awskeyserver.
View AWSDemo.java
package com.amazon.aws.demo;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLConnection;
@cspanring
cspanring / pagination.html
Created November 8, 2011 02:53
linaro django pagination template for Bootstrap framework
View pagination.html
{# use in combination with https://github.com/zyga/django-pagination #}
{# and http://twitter.github.com/bootstrap/ #}
{# project-dir/templates/pagination/pagination.html #}
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% block previouslink %}
{% if page_obj.has_previous %}
@mboersma
mboersma / DockerMacClient.md
Last active May 26, 2017 06:43
Build Docker on Mac OS X and run it as a client connected to a Linux VM running the docker daemon.
View DockerMacClient.md

Run Docker client on Mac OS X connected to a Linux VM

Official Mac Docker Binary!

None of this is really necessary now that the Docker team is releasing official Mac OS X binary builds. Please see moby/moby#3337 for details.

@Doerge
Doerge / test_app.py
Last active July 5, 2017 18:03
Basic app for testing flask-zappa functionality.
View test_app.py
# -*- coding: utf-8 -*-
from flask import Flask, request, redirect, url_for, session, abort, current_app, json
app = Flask(__name__)
# This is the very unsecret key from the Flask-docs
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
@app.route('/')
@tobsn
tobsn / info.txt
Last active November 24, 2017 13:06 — forked from rpgreen/master.vm
API Gateway "Send Everything" Mapping Template
View info.txt
https://rpgreen.wordpress.com/2016/02/23/a-mapping-template-to-send-everything-to-your-backend-integration/
location/cookie headers:
https://stackoverflow.com/questions/35595672/aws-api-gateway-use-302-redirect-and-set-cookie-header
https://blog.hiramsoftware.com/blog/day-one-aws-api-gateway/
@dhimmel
dhimmel / bitcoin-random-outcomes.ipynb
Last active January 29, 2018 19:14
Using Bitcoin to randomly determine a future outcome involving untrusted parties
View bitcoin-random-outcomes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bjinwright
bjinwright / custom_storages.py
Created December 7, 2016 22:50
Custon S3 Django-Storages backend made for use with CloudFront with multiple origins
View custom_storages.py
from django.conf import settings
from django.utils.encoding import filepath_to_uri
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
location = settings.STATICFILES_LOCATION
def url(self, name, headers=None, response_headers=None, expire=None):
return '{}{}'.format(settings.STATIC_URL,filepath_to_uri(name))
@iepathos
iepathos / sorting_example_by_subdict_key
Last active May 4, 2018 15:11
Explicitly sorting a dictionary by a sub-dictionary subkey into an ordered list.
View sorting_example_by_subdict_key
# Dictionaries are inherently orderless, but lists are ordered!
import collections
d = { '123': { 'key1': 3, 'key2': 11, 'key3': 3 },
'124': { 'key1': 6, 'key2': 56, 'key3': 6 },
'125': { 'key1': 7, 'key2': 44, 'key3': 9 } }
results_list = []
sort_by_dict = {}
@nkrumm
nkrumm / aspera_to_s3.sh
Created December 23, 2013 07:14
DIY Direct-to-S3 Aspera solution. This snipped monitors a directory for new files (uploaded via aspera, for example) and then starts a background s3cmd job to upload those files Using the --partial-file-suffix=.part for the ascp command ensures that inotifywait only gets trigger when the file is finished uploading.
View aspera_to_s3.sh
inotifywait -m -e moved_to $BASE | while read line
do
F=$(echo $line | cut -f3 -d" ")
echo "Now uploading $F"
s3cmd --force --no-progress put $F s3://mybucket/ &
done
@peterhurford
peterhurford / ec2_price_discovery.py
Last active August 24, 2018 18:46
Find the best deals in AWS spot instances across all availability zones and multiple instance types
View ec2_price_discovery.py
# For every AWS availability zone and instance I care about, check the spot
# price for the last ninety days and generate stats about which spot instance
# gives the best deal.
import boto
import boto.ec2
from vowpal_platypus.utils import mean
REGIONS = {'us-east-1': ['us-east-1a', 'us-east-1b', 'us-east-1c', 'us-east-1e'],