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 / tasseo.spec
Created August 2, 2012 22:40
.spec file for building Tasseo into an RPM
%define githash 46d8a8f
Name: tasseo
Summary: A lightweight, easily configurable, real-time dashboard for Graphite events.
Version: 0.0.1
Release: 1%{?dist}
License: 3-clause BSD
Group: Applications/System
URL: https://github.com/obfuscurity/tasseo
Source0: obfuscurity-tasseo-%{githash}.tar.gz
@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 / 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 / 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 <[email protected]>
#
# 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 / 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 / VersionAssetManager.php
Created March 3, 2013 00:42
An asset manager for the Yii PHP framework to publish static assets with a hash that's load-balancer and development environment friendly.
<?php
/**
* CAssetManager class file.
*
* @author Jason Hancock <[email protected]>
* @copyright Copyright &copy; 2013 Jason Hancock
* @license http://www.yiiframework.com/license/
*/
@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 protected]'
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"
)