Skip to content

Instantly share code, notes, and snippets.

View jeffbyrnes's full-sized avatar

Jeff Byrnes jeffbyrnes

View GitHub Profile
@technovangelist
technovangelist / datadog-nginx
Last active April 25, 2017 20:35 — forked from gane5h/datadog-nginx
Nginx log parsing with datadog
"""
Thanks to gane5h for the original script. this is a small kludgy tweak to that one.
Custom parser for nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g "/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format time_log '$time_local "$request" S=$status $bytes_sent T=$request_time R=$http_x_forwarded_for';
when starting dd-agent, you can find the collector.log and check if the dogstream initialized successfully
@blalor
blalor / consul_handler.rb
Created July 2, 2015 14:03
Chef report handler for Consul
## chef report handler for Consul
## depends on a chef-client check being registered with the agent
## • pings TTL-style check with ok/warning status on chef run pass/fail
## • stores run report and node attributes in chef/reports/<datacenter>/<consul_node_name>
require "chef/handler"
require "rest_client"
class ConsulHandler < Chef::Handler
attr_reader :config
@angstwad
angstwad / dict_merge.py
Last active March 1, 2024 23:53
Recursive dictionary merge in Python
# Copyright 2016-2022 Paul Durivage
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@fjallstrom
fjallstrom / gist:4f238b15a4d54187f742
Last active August 3, 2016 20:24
slacklastfmthingie
<?php
date_default_timezone_set("Europe/Stockholm");
require 'vendor/autoload.php';
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
$client = new Client();
KV_KEY = 'forecast-alert-datapoint'
module.exports = (robot) ->
postWeatherAlert = (json, callback) ->
postMessage = callback
now = new Date()
# This function posts an alert about the current forecast data always. It
# doesn't determine if the alert should be posted.
@mgreensmith
mgreensmith / Slack_solarized_themes
Last active December 21, 2023 19:29
Solarized themes for Slack
Solarized
#FDF6E3,#EEE8D5,#93A1A1,#FDF6E3,#EEE8D5,#657B83,#2AA198,#DC322F
Solarized Dark
#073642,#002B36,#B58900,#FDF6E3,#CB4B16,#FDF6E3,#2AA198,#DC322F
@dperrera
dperrera / gulpfile.js
Last active January 3, 2016 22:19
My gulpfile.js
// ==================================================
// Gulp Variables
// ==================================================
var gulp = require('gulp'),
gutil = require('gulp-util');
// Compass
var compass = require('gulp-compass');
@sarim
sarim / repairsqlite.sh
Created September 6, 2013 08:14
Sqlite db repair script
#!/bin/bash
DBSTATUS=$(sqlite3 "$1" "PRAGMA integrity_check")
if [ "$DBSTATUS" == "ok" ] ; then
echo DB ALREADY OK
else
echo FIXING CORRUPT DB
TMPDB=$(mktemp -t sarim)
echo ".mode insert
.dump" | sqlite3 "$1" > $TMPDB
@dysinger
dysinger / easy-ubuntu-openvpn.sh
Created August 28, 2013 18:22
Create a VPN on EC2 in 30 seconds
#!/bin/sh
# linux firewall/forwarding
modprobe iptable_nat
echo 1 | tee /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.10.10.1/2 -o eth0 -j MASQUERADE
# install openvpn
apt-get update && apt-get install -y openvpn
cd /etc/openvpn/
INSTANCE=$(curl http://169.254.169.254/latest/meta-data/public-hostname)
openvpn --genkey --secret ${INSTANCE}.key
@notasausage
notasausage / get_twitter_avatar.php
Last active December 20, 2015 10:30 — forked from banksy89/gist:3334259
Return the profile image (avatar) of a Twitter user using their RSS feed (no API call necessary).
<?php
function getTwitterAvatar( $username, $size = "normal" ) {
// mini = 24px, normal = 48px, bigger = 73px
$sizes = array( "mini", "normal", "bigger" );
// Check for size, default to normal
if( in_array( $size, $sizes ) ) {
$variant = $size;
} else {
$variant = "normal";