Skip to content

Instantly share code, notes, and snippets.

Avatar
meh

Jason Hancock jasonhancock

meh
View GitHub Profile
@jasonhancock
jasonhancock / main.go
Created Nov 29, 2018
bcrypt time cost at various difficulty factors
View main.go
package main
import (
"fmt"
"log"
"time"
"golang.org/x/crypto/bcrypt"
)
@jasonhancock
jasonhancock / harvest_one_item.md
Created Apr 30, 2018
Harvesting a single item from s3 via the GrayMeta Platform API
View harvest_one_item.md

How to initiate a harvest of a single asset in s3 that has not been previously indexed into the GrayMeta Platform

NOTE: my endpoint is http://localhost:7000. Your endpoint will be different.

Step 1:

You must know the name of the s3 bucket and the s3 key (the path within the bucket) to the asset.

For our example today, I want to harvest the key 5aba86635fc9cbec3a81839abc0fc2a9.jpg inside the hancocktest bucket in s3.

@jasonhancock
jasonhancock / main.go
Created Aug 30, 2017
simple udp server to debug statsd stuff
View main.go
package main
import (
"fmt"
"log"
"net"
)
func handleUDPConnection(conn *net.UDPConn) {
@jasonhancock
jasonhancock / README.md
Last active Dec 14, 2017
jenkins to statsd
View README.md

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:

View gist:620ebeefa7b9f6654ae1bdee067b8c7d
package main
import (
"bufio"
"fmt"
"github.com/Azure/azure-sdk-for-go/storage"
"io"
"log"
"os"
)
View gist:961c4cd5029332a1728e
#!/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 Apr 23, 2013
Ordering IP ranges in CIDR notation stored in a SQL DB correctly
View gist:5445430

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 / VersionAssetManager.php
Created Mar 3, 2013
An asset manager for the Yii PHP framework to publish static assets with a hash that's load-balancer and development environment friendly.
View VersionAssetManager.php
<?php
/**
* CAssetManager class file.
*
* @author Jason Hancock <jsnbyh@gmail.com>
* @copyright Copyright &copy; 2013 Jason Hancock
* @license http://www.yiiframework.com/license/
*/
@jasonhancock
jasonhancock / gist:4675588
Last active Dec 11, 2015
stupid quick and dirty script to parse apache combined log format
View gist:4675588
#!/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 / redis_loading
Last active Oct 5, 2017
A script to generate a progress bar tracking Redis' progress loading the data files on startup
View redis_loading
#!/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: