Skip to content

Instantly share code, notes, and snippets.

View technosophos's full-sized avatar

Matt Butcher technosophos

View GitHub Profile
@technosophos
technosophos / gist:4453518
Created January 4, 2013 15:36
SPLObjectStorage vs. PHP Arrays
<?php
/**
* Object hashing tests.
*/
$sos = new SplObjectStorage();
$docs = array();
$iterations = 100000;
for ($i = 0; $i < $iterations; ++$i) {
@technosophos
technosophos / kibana.conf
Last active January 11, 2020 21:41
An upstart (Ubuntu 12.04) script for starting Kibana as a service. The file goes in /etc/init/. This goes with the Upstart script for Logstash (http://cookbook.logstash.net/recipes/using-upstart/)
# kibana.conf# kibana - log viewer
#
description "Kibana logstash viewer"
start on virtual-filesystems
stop on runlevel [06]
respawn
respawn limit 5 30
@technosophos
technosophos / gist:5258706
Last active December 15, 2015 12:09 — forked from AeroNotix/gist:5247096
One way of making it easy to construct new service instances, hide the implementation details, but separate the services. One big advantage in doing things this way is that you could pretty easily create tools to deal with multiple azs, regions, and geos. E.g. you could copy objects from USWest to USEast.
/* hpcloud */
import "hpcloud/objectstorage"
type Account struct {
// Stuff
}
func (a Account) ObjectStorage(region) {
/* Look up the endpoints and stuff...
#cloud-config
# Automatically update all of the packages
package_upgrade: true
package_reboot_if_required: true
# Install the LAMP stack for me
packages:
- apache2
- mysql-server
@technosophos
technosophos / gist:5650812
Created May 25, 2013 21:14
Test case for #112
$xml = '<?xml version="1.0"?>
<root>
<Document name="A" title="A" >
<Document name="B" title="B" >
<Document name="C" title="C" >
<Section title="1" position="" >
Section ABDFD
</Section>
</Document>
</Document>
@technosophos
technosophos / fabfile.py
Created May 29, 2013 01:13
Example fabfile for creating a new HP Cloud server instance. This uses the `hpcloud` CLI.
from fabric.api import *
import re
@task
def create_server(name):
"""Create a new HP Cloud server."""
image = 81078 # Ubuntu 12.04 in AZ-1
flavor = 100 # extra-small
security_group = 'Web'
key = 'hpcompute'
@technosophos
technosophos / fabfile.py
Created May 29, 2013 14:13
A simple Fabfile for creating and installing a LAMP server on HP Cloud.
from fabric.api import *
# Keyfile for SSH. Use this if you're not
# using SSH Agent.
env.key_filename = "~/.ssh/hpcompute.pem"
@task
def hello():
puts("Hello")
# Meme++: A Langugae For The Moment
## Control Structures
### iDontOften/butWhenIDo
Evaluates BLOCK when CONDITION is TRUE
```
iDontOften BOOLEAN_CONDITION
package main
import (
"github.com/Masterminds/cookoo"
"github.com/Masterminds/cookoo/web"
"html/template"
)
func main() {
@technosophos
technosophos / issue-133.php
Created March 3, 2014 02:06
QueryPath issue #133: Attempt to reproduce.
<?php
require_once "vendor/autoload.php";
$HTML = <<<EOL
<html>
<head>
<title>Foo</title>
</head>
<body>
<p>foo</p>