This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Cat your ELB logs into this script | |
$elb_regex = '#^(?<date>.+?) (?<elb>.+?) (?<client_ip>[\d\.]+):(?<client_port>\d+) (?<backend_ip>[\d\.]+):(?<backend_port>\d+) (?<request_processing_time>[\d\.]+) (?<backend_processing_time>[\d\.]+) (?<response_processing_time>[\d\.]+) (?<elb_status_code>\d+) (?<backend_status_code>\d+) (?<received_bytes>\d+) (?<sent_bytes>\d+) "(?<method>[A-Z]+) (?<https>https?)://(?<http_host>.+?):(?<port>\d+)(?<uri>/.*?) (?<protocol>HTTP/[\d\.]+)" "(?<http_user_agent>.+?)" (?<ssl_cipher>.+?) (?<ssl_protocol>.+?)$#'; | |
while ($line = fgets(STDIN)) { | |
if (!preg_match($elb_regex, $line, $data)) { | |
continue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper functions for dealing with Docker containers | |
# Returns "missing", "stopped" or "running" | |
get_container_state() { | |
local CONTAINER_NAME=$1 | |
# Faster check to see if the container *might* exist | |
CONTAINER_MISSING=$(container_does_not_exist "$CONTAINER_NAME") | |
if [[ $CONTAINER_MISSING = "true" ]]; then | |
echo -n "missing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* libwurfl_version.c | |
* Compile with: | |
* gcc -o libwurfl_version libwurfl_version.c -lwurfl | |
*/ | |
#include <stdio.h> | |
#include <wurfl/wurfl.h> | |
int main(int argc, char **argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Put this file in /usr/local/bin and use 'curl-timing' in place of 'curl' | |
# to get a detailed timing report with the response. | |
# You can customize the report below. For older versions of curl, some | |
# of the fields below will not be available. | |
TIMING_FORMAT=$(cat <<EOL | |
url_effective: %{url_effective} | |
remote_ip: %{remote_ip} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php namespace kamermans\ImageMagick; | |
/** | |
* Parser for the ImageMagick "identify" utility that takes "identify -verbose <file>" | |
* output on STDIN and outputs JSON on STDOUT. | |
* | |
* Example: | |
* identify -verbose foo.jpg | ./parse_identify.php | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://foo.com/path with spaces/index.php?something=something else#foo-29 32'; | |
$reencode_url = function ($url) { | |
$url_parts = parse_url($url); | |
// Add scheme | |
$scheme = array_key_exists('scheme', $url_parts)? $url_parts['scheme']: 'http'; | |
$new_url = "$scheme://"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Direct port of the Python 2.7 fnmatch::translate(pat) function. | |
* Converts a shell-expansion pattern to a regular expression. | |
* | |
* by Steve Kamerman | |
* | |
* @see https://hg.python.org/cpython/file/2.7/Lib/fnmatch.py | |
*/ | |
function pythonFnmatchTranslate($pat, $delimiter=null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<zabbix_export> | |
<date>2017-03-24T18:03:00Z</date> | |
<graphs> | |
<graph> | |
<graph_items> | |
<graph_item> | |
<calc_fnc>2</calc_fnc> | |
<color>157419</color> | |
<drawtype>1</drawtype> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Parses the output of storcli: | |
# storcli /c0 show all J | |
import sys | |
import json | |
output_dir = "." | |
data = json.load(sys.stdin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Start this script before you start NGINX, so it is ready and waiting for log data. | |
# You should start it in the background with & or run it from supervisord or something. | |
# If the port is above 1024, you can run this script as a non-root user (recommended). | |
# | |
# It listens for raw Syslog data over UDP, parses is, aggregates it, and writes | |
# it to a file every flush_interval seconds. The output file format looks like this: | |
# key<TAB>value | |
# Here is an example (note that the delimiter is actually TAB, not a space): |