Skip to content

Instantly share code, notes, and snippets.

@mattupstate
mattupstate / oat.py
Last active August 29, 2015 13:55
Naive attempt at porting Oat (https://github.com/ismasan/oat) to Python
import warnings
from collections import OrderedDict
from itertools import chain
from inflection import pluralize
class Adapter(object):
input {
file {
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
start_position => "beginning"
}
}
output {
elasticsearch_http {
host => "elasticsearch.company.internal"
@mattupstate
mattupstate / docker-regsitry.conf
Created November 6, 2014 14:54
An example Nginx config for a private Docker registry to enable unauthenticated, read-only access on non-volatile HTTP methods
upstream docker-registry {
leastconn;
server hostname1:port;
server hostname2:port;
}
server {
listen 80;
server_name docker.your.domain;
rewrite ^ https://$server_name$request_uri? permanent;
@mattupstate
mattupstate / nginx_status_decoder.lua
Last active August 29, 2015 14:09
heka Nginx status decoder and filter
--[[
Parses a payload containing the contents of the output from the Nginx `stub_status`
module. See: http://nginx.org/en/docs/http/ngx_http_stub_status_module.html
Config:
- payload_keep (bool, optional, default false)
Always preserve the original log line in the message payload.
@mattupstate
mattupstate / linux_netstats.lua
Created November 13, 2014 00:40
A heka decoder for data available in /proc/net/dev
--[[
Parses a payload containing the contents of a `cat /proc/net/dev | tail -n +3` call into a Heka
message.
Config:
- payload_keep (bool, optional, default false)
Always preserve the original log line in the message payload.
@mattupstate
mattupstate / output.rst
Created May 19, 2015 23:14
uWSGI heka.statmetric message
Timestamp

2015-05-19 23:11:38.372266224 +0000 UTC

Type

heka.statmetric

Hostname

machine1

Pid

18895

Uuid

f58719a6-999f-465b-8790-13fae230c0ca

Logger

users-frontend-stat-accum

Payload

users-frontend-machine1.counters.uwsgi.worker.1.delta_requests.rate 0.000000 1432077098

users-frontend-machine1.counters.uwsgi.worker.1.delta_requests.count 0 1432077098 users-frontend-machine1.counters.uwsgi.worker.2.delta_requests.rate 0.000000 1432077098 users-frontend-machine1.counters.uwsgi.worker.2.delta_requests.count 0 1432077098

/**
* Converts the amount of milliseconds into a string based time code.
* @param milliseconds
* @param delimiter
* @param withHours
* @return The time code as a string.
*/
function getTimeCode( milliseconds:Number, delimeter:String = ":", withHours:Boolean = false ):String
{
var posHours:Number = Math.floor( milliseconds / 1000 / 60 / 60 );
function run( buildFile:File, targetName:String, parameters:Array = null ):void
{
var file:File = new File( "C:/windows/system32/cmd.exe" );
var args:Vector.<String> = new Vector.<String>();
args.push( "/c" );
args.push( "ant" );
if( parameters )
{
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
public class CenteredImage extends Sprite
{
private var _image:Bitmap;
public function CenteredImage( image:Bitmap )
<target name="compile">
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${basedir}/src/Project.swf" />
<arg value="-output=${basedir}/bin/Project.swf" />
<arg value="-source-path=${basedir}/src" />
<arg value="-library-path+=${basedir}/lib" />
</java>
</target>