Skip to content

Instantly share code, notes, and snippets.

View caevyn's full-sized avatar

Matt Murphy caevyn

  • Newcastle, Australia
View GitHub Profile
@caevyn
caevyn / ApiOperationDescriptionAttribute.cs
Created August 6, 2015 04:11
web api description filter
public class ApiOperationDescriptionAttribute : Attribute
{
public string Description { get; set; }
public ApiOperationDescriptionAttribute(string description)
{
Description = description;
}
}
public class LookupOperationFilter : IOperationFilter
@caevyn
caevyn / nginx
Last active August 29, 2015 14:22 — forked from vdel26/nginx
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@caevyn
caevyn / cf.json
Last active August 29, 2015 14:22
empty vpc
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation demo thingy",
"Parameters": {
"Environment": {
"Description": "Environment",
"Type": "String",
"MinLength": "3",
"MaxLength": "4",
"Default": "DEV",
@caevyn
caevyn / gist:0d4e096655430a528c5e
Created May 27, 2015 03:45
nginx packer file
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "ap-southeast-2",
@caevyn
caevyn / cloud_formation_test.json
Last active August 29, 2015 14:15
messing with cloud formation
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation demo thingy",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the Elastic Beanstalk hosts",
"Type": "AWS::EC2::KeyPair::KeyName",
@caevyn
caevyn / gatlingindex.js
Created July 2, 2014 02:07
node app to render an index for gatling reports
var express = require('express'),
finder = require('finder-on-steroids');
var app = express();
app.use(express.static('../results'));
app.listen(9085);
app.get('/', function(req, res, next) {
finder('../results').files().depth(2).name('index.html').find().then(function(files) {
@caevyn
caevyn / dodgylogparsing.rb
Last active August 29, 2015 13:58
From weird log format to hash. (for logstash filter)
log = "DateTime: 23/04/1998\r\nI'm just a message\r\nKey: value\r\nIm a url: http://cats.com\r\nError Description: I'm an error here is my stacktrace\r\n at stuff\r\n at more stuff\r\n\key with no value: \r\nI'm another random message line\r\n--------------------------------------------"
rows = log.split(/\r\n/).partition{|x| x.start_with?('Error Description: ',' at')}
event = {'Error'=>rows[0].join($/).sub('Error Description: ','')}
remove = []
rows[1].each do |i|
i.scan(/(.+): (.*)/) do |x,y|
event[x.delete(' ')] = y
remove.push(i)
end
@caevyn
caevyn / app.conf
Last active August 29, 2015 13:58
logstash conf
input {
stdin { type => example }
file {
#any line not starting with a tleast 10 dashes belongs with the previous line
codec => multiline {
pattern => "^-{10,}"
negate => true
what => next
}
path => "C:/applogs/*.log"
@caevyn
caevyn / JsonLayoutRenderer
Last active August 29, 2015 13:57
Json layout renderer for nlog + rabbitMQ target + logstash
using System.Globalization;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using NLog.LayoutRenderers;
namespace Cats.Middleware.Logging
{
[LayoutRenderer("json")]
@caevyn
caevyn / Web.config
Last active August 29, 2015 13:56
Separate encrypted app settings section
<configuration>
<configSections>
<section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<secureAppSettings>
<add key="encryptMe" value="ImSuperSecret" />
</secureAppSettings>
</configuration>