Skip to content

Instantly share code, notes, and snippets.

@aaronhurt
aaronhurt / pure-php-uuid.php
Created June 4, 2013 19:33
uuid generation in pure php
<?php
/* generate rfc compliant v3,v4 and v5 uuids
* http://www.php.net/manual/en/function.uniqid.php#94959
* $type -> uuid version to generate (3, 4 or 5)
* $namespace -> namespace for v3 and v5 uuids
* $name -> string for v3 and v5 uuids
*/
function generate_uuid($type, $namespace = null, $name = null) {
switch($type) {
<?php
/**
* Array to Text Table Generation Class
*
* @author Tony Landis <tony@tonylandis.com>
* @link http://www.tonylandis.com/
* @copyright Copyright (C) 2006-2009 Tony Landis
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class ArrayToTextTable
<?php
/**
* Generate rfc compliant v3, v4 and v5 uuids
* @see http://www.php.net/manual/en/function.uniqid.php#94959
* @param int $type uuid version to generate (3, 4 or 5)
* @param string $namespace namespace for v3 and v5 uuids (default null)
* @param string $name name string for v3 and v5 uuids (default null)
* @return string|false generated uuid or false on failure
* @internal
<?php
if (php_sapi_name() !== 'cli') {
die('This script may only be run from the command line.' . "\n");
}
if ($argc < 2) {
die('Usage: ' . $argv[0] . ' <encryption key>' . "\n");
}
<?php
/**
* CIDR.php
*
* Utility Functions for IPv4 ip addresses.
* Supports PHP 5.3+ (32 & 64 bit)
* @author Jonavon Wilcox <jowilcox@vt.edu>
* @revision Carlos Guimarães <cvsguimaraes@gmail.com>
* @version Wed Mar 12 13:00:00 EDT 2014
*/
@aaronhurt
aaronhurt / cymru-lookup.php
Last active April 22, 2017 21:50
testing the cymru netcat access
<?php
/* test host list */
$hostlist = array(
'96.4.1.22',
'207.191.191.90',
'8.8.8.8'
);
/* do the lookup */
<?php
/**
* Example with all methods and default keys:
*
* $crypt = new phpCrypt;
*
* $crypt->cipher = "blowfish";
* printf("crypted == %s\ndecrypted == %s\n\n", ($crypted = $crypt->encrypt("hello world")), $crypt->decrypt($crypted));
*
* $crypt->cipher = "xor";
@aaronhurt
aaronhurt / curltest.c
Last active November 26, 2023 10:29
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* License:
*
* This code is licensed under MIT license
* https://opensource.org/licenses/MIT
*
@aaronhurt
aaronhurt / gist:9494e5e7831fa927803e
Created December 9, 2014 20:34
swagger and go-restful
// registration function
func (ml mlResource) register(container *restful.Container) {
// new service object
ws := new(restful.WebService)
// set the path
ws.Path(path.Join(ml.Config.Service.BasePath, "/rules")).
Doc("Get managed LAN rule set documents").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
// list available configuration data
@aaronhurt
aaronhurt / haproxy-multi-dc.ctmpl
Last active November 25, 2016 08:36
HAProxy configuration generated from consul via consul-template to generate frontend/backend services across multiple datacenters
##
## NOTE: Configuration generated by consul-template
## local changes will be overwritten.
##{{$myDc := key "env/dc"}}
## lb/haproxy/global
global{{range ls "lb/haproxy/global"}}{{if ne .Key "rawText"}}
{{.Key}} {{.Value}}
{{- end}}{{end -}}
{{range $key, $pairs := tree "lb/haproxy/global" | byKey}}{{range $pair := $pairs}}