Skip to content

Instantly share code, notes, and snippets.

# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This file autogenerated by Chef
# Do not edit; changes will be overridden.
# Instead, edit node["keystone"]["configuration"]
<%=
content = ''
# Normally sort isn't safe on hashes, as symbols do not sort.
# In this case, we know that the content has been converted two and from json
# and will have only string keys.
@config.sort.each do |name, subconfig|
@willkelly
willkelly / gist:5785268
Created June 14, 2013 21:06
Simple fio config
[global]
size=1G
numjobs=4
[SSD workload 65/35 - 1KB]
description=1K 65/35 rw
new_group
rw=randrw
bs=1k
ioengine=libaio
@willkelly
willkelly / ido-config.el
Last active December 19, 2015 15:49
ido config
; These are my minor ido tweaks
(ido-mode t)
(define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil)
(unless (fboundp 'sixth)
(defun sixth (l) "returns the sixth element of a list"
(nth 5 l)))
;configure ido
(setq ido-enable-prefix nil
ido-enable-flex-matching t
@willkelly
willkelly / dumbparser
Last active December 20, 2015 10:49
An extraordinarily stupid parser, probably full of bugs.
#!/usr/bin/python
states = ["START", "RESOURCE", "ACTION", "PROPERTY", "SUBRESOURCE", "SUBRESOURCE_END", "END"]
transitions = {
"START": ["RESOURCE"],
"RESOURCE": ["ACTION"],
"ACTION": ["SUBRESOURCE", "PROPERTY"],
"PROPERTY": ["SUBRESOURCE", "PROPERTY", "SUBRESOURCE_END", "END"],
"SUBRESOURCE": ["PROPERTY", "SUBRESOURCE"],
commands = """
def p = "sudo ip a".execute()
p.waitFor()
print p.in.text
print p.err.text
"""
//def commands = "print \"Hello world!\""
println "AUGH: ${hudson.model.Hudson.instance.slaves}"
for (slave in hudson.model.Hudson.instance.slaves) {
@willkelly
willkelly / gist:a2722dfb0aa435acacee
Last active August 29, 2015 14:01
Make threads that return values in python
import threading
class ThreadFunction(threading.Thread):
def __init__(self, group=None, target=None, name=None,
args=(), kwargs={}, Verbose=None):
self._return = None
super(ThreadFunction, self).__init__(group, self._wrap(target),
name, args, kwargs, Verbose)
def zebra_execute(json, endpoint, token):
return requests.post(
endpoint,
headers={
"X-Auth-Token": token,
"Content-Type": "application/json",
"X-ZeroVM-Execute": "1.0"},
data=json).content
import sqlite3
con = sqlite3.connect("/dev/input")
cursor = con.cursor()
cursor.execute("Select name from object")
print "\n".join([item[0] for item in cursor.fetchall()])