Skip to content

Instantly share code, notes, and snippets.

View caevyn's full-sized avatar

Matt Murphy caevyn

  • Newcastle, Australia
View GitHub Profile
import boto3
import json
import csv
import io
def lambda_handler(event, context):
s3 = boto3.resource('s3')
content_object = s3.Object('src-bucket', 'src-file.json')
file_content = content_object.get()['Body'].read().decode('utf-8')
lines = file_content.splitlines()
@caevyn
caevyn / ecs.json
Last active June 28, 2017 02:00
ecs definition
{
"taskDefinitionArn": "arn:aws:ecs:us-west-2:<scc number>:task-definition/build-blog:3",
"revision": 3,
"containerDefinitions": [
{
"volumesFrom": [],
"portMappings": [],
"command": [],
"environment": [
{
#include <NewPing.h>
const int greenPin = 2;
const int redPin = 4;
const int bluePin = 3;
const int trigPin = 11;
const int echoPin = 12;
enum color {
red,
@caevyn
caevyn / ecs.json
Created November 17, 2015 10:38
ecs cloudformation
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Parameters" : {
"KeyName": {
"Type": "AWS::EC2::KeyPair::KeyName",
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the ECS instances"
},
"SubnetID": {
"Type": "List<AWS::EC2::Subnet::Id>",
"Description": "List of an existing subnet IDs to use for the load balancer and auto scaling group"
@caevyn
caevyn / ElmahSensitiveDataFilter.cs
Created January 16, 2014 05:38
Filter out sensitive info before it ends up in ELMAH
public static class ElmahSensitiveDataFilter
{
public static void Apply(ExceptionFilterEventArgs e, HttpContext ctx)
{
var sensitiveFormData = ctx.Request.Form.AllKeys.GetSensitiveFormData();
if (sensitiveFormData.Count == 0)
{
return;
}
var error = new Error(e.Exception, ctx);
@caevyn
caevyn / gist:6051595
Created July 22, 2013 06:01
ServiceStack AppHost Configure for metrics.
public override void Configure(Funq.Container container)
{
const string statsdPrefix = "Qas.Web";
//common config shared with tests
Config.Configure();
container.Register<IStatsd>(c => new Statsd(new StatsdUDP("localhost", 8125)));
Plugins.Add(new MetricsFeature(container.Resolve<IStatsd>(), statsdPrefix));
@caevyn
caevyn / gist:5772914
Created June 13, 2013 11:06
from davepermen.net i can now do this: http://localhost:7820/route/BlogModule and get back this [ "GET /", "GET /list/{pageId}", "GET /article/{id}", "GET /newArticle" ]
public class RouteModule : NancyModule
{
public RouteModule(IRouteCacheProvider routeCache)
{
Get["/routes/all"] = _ => routeCache.GetCache().Select(entry => new
{
Module = entry.Key.Name,
Routes = entry.Value.Select(route => route.Item2.Method + " " + route.Item2.Path)
});
Get["/route/{moduleName}"] = _ =>
@caevyn
caevyn / gist:5133306
Last active December 14, 2015 18:59
Exclude sensitive form data from elmah logs
//in global.asax
void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
var ctx = e.Context as HttpContext;
if(ctx == null)
{
return;
}
ElmahSensitiveDataFilter.Apply(e, ctx);
}
@caevyn
caevyn / Dockerfile
Last active October 20, 2015 04:00
docker openresty
# Dockerfile for openresty
FROM centos:7
MAINTAINER matt murphy
ENV http_proxy http://10.0.2.2:3128/
ENV https_proxy https://10.0.2.2:3128/
ENV PKG ngx_openresty-${openresty_version:-"1.7.10.1"}
RUN yum install -y readline-devel pcre-devel openssl-devel gcc wget perl make
RUN wget http://openresty.org/download/${PKG}.tar.gz \
set nocompatible
filetype off
set rtp+=%USERPROFILE%/_vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'kien/ctrlp.vim'
call vundle#end()