Skip to content

Instantly share code, notes, and snippets.

View jasonhancock's full-sized avatar
meh

Jason Hancock jasonhancock

meh
View GitHub Profile
#!/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
@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');
@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: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 / 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/