Skip to content

Instantly share code, notes, and snippets.

View jasonhancock's full-sized avatar
meh

Jason Hancock jasonhancock

meh
View GitHub Profile
@jasonhancock
jasonhancock / php-pear-AWSSDKforPHP.spec
Created July 20, 2012 15:28
A .spec file for the AWS PHP SDK
%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
%define pear_name AWSSDKforPHP
Name: php-pear-AWSSDKforPHP
Version: 1.5.10
Release: 1%{?dist}
Summary: AWS SDK for PHP
Group: Development/Libraries
License: Apache-2.0
URL: http://aws.amazon.com/sdkforphp/
@jasonhancock
jasonhancock / gist:3382454
Created August 17, 2012 20:44
Inerting/selecting GUIDs into/from MySQL
mysql>CREATE TABLE jive (uuid CHAR(16) BINARY);
Query OK, 0 rows affected (0.02 sec)
mysql> select UUID();
+--------------------------------------+
| UUID() |
+--------------------------------------+
| 519718a1-e8ab-11e1-8803-080027e1c419 |
+--------------------------------------+
1 row in set (0.00 sec)
@jasonhancock
jasonhancock / gist:4675588
Last active December 11, 2015 23:18
stupid quick and dirty script to parse apache combined log format
#!/usr/bin/perl
use strict;
use warnings;
my $file = $ARGV[0] or die("No file passed");
open IN, "<$file" or die("Can't open file $file");
while(my $line=<IN>) {
@jasonhancock
jasonhancock / gist:5445430
Created April 23, 2013 17:01
Ordering IP ranges in CIDR notation stored in a SQL DB correctly

Imagine you're storing IP ranges in CIDR notation in a database table like this:

CREATE TABLE ranges (
    block VARCHAR(50)
);

INSERT INTO ranges(block) VALUES ('192.168.2.0/24'),('192.168.10.0/24');
#!/bin/bash
ADDR='email@example.com'
PRODUCT_ID=2885
TMP_FILE=/tmp/adafruit.tmp
wget -O $TMP_FILE -q https://www.adafruit.com/product/$PRODUCT_ID > /dev/null 2>&1
package main
import (
"bufio"
"fmt"
"github.com/Azure/azure-sdk-for-go/storage"
"io"
"log"
"os"
)
@jasonhancock
jasonhancock / puppet apache log analyzer
Created August 23, 2012 18:09
Analyze puppet's apache logs.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $file = $ARGV[0] or die('Must pass an apache access logfile');
open IN, "<$file" or die("Can't open $file");
@jasonhancock
jasonhancock / main.go
Created August 30, 2017 20:44
simple udp server to debug statsd stuff
package main
import (
"fmt"
"log"
"net"
)
func handleUDPConnection(conn *net.UDPConn) {
@jasonhancock
jasonhancock / redis_loading
Last active October 5, 2017 23:38
A script to generate a progress bar tracking Redis' progress loading the data files on startup
#!/usr/bin/perl
# Copyright (c) 2012 Jason Hancock <jsnbyh@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is furnished
# to do so, subject to the following conditions:
@jasonhancock
jasonhancock / README.md
Last active December 14, 2017 14:45
jenkins to statsd

A cheap way to get build events from jenkins into graphite via statsd:

/usr/local/bin/buildstats

#!/bin/bash
. /etc/default/buildstats
echo "$BUILD_PREFIX.$JOB_NAME:1|c" | nc -w 1 -u $STATSD_SERVER $STATSD_PORT

/etc/default/buildstats: