Skip to content

Instantly share code, notes, and snippets.

#!/bin/ruby
##
# Take a credit card number and determine the type of card
#
# @param [String] card the card number
# @return [String] the card type.
#
def card_type(card)
if card =~ /^3[47]\d+$/ && card.length == 15
import keystoneclient
import novaclient
# Simple
auth = keystoneclient.PasswordAuth(username='jamie', password='cool')
s = keystoneclient.Session(cacert='ca.pem', cert='client.pem', key='key.pem',
auth=auth)
# will send an authenticated request to a full url
@jamielennox
jamielennox / gist:7816497
Created December 6, 2013 00:11
Wrapping a class function by a decorator example.
class MyClass(object):
def __repr__(self):
return "<MyClass>"
def my_hello(self):
print "hello from", self
#!/bin/bash
# create an associative array of all the changes
declare -A MERGED
for commit in `git log master | grep Change-Id | cut -d : -f 2`; do
MERGED["$commit"]=1
done
for branch in `git branch | grep -v master`; do
found=1
@jamielennox
jamielennox / test-conf.py
Created February 17, 2015 02:11
Load an auth plugin and session from options in a config file.
import sys
from keystoneclient import auth
from keystoneclient import session
from oslo.config import cfg
cfg.CONF(sys.argv[1:])
auth.register_conf_options(cfg.CONF, 'somegroup')
session.Session.register_conf_options(cfg.CONF, 'somegroup')
@jamielennox
jamielennox / test-cli.py
Created February 17, 2015 02:52
Load an auth plugin and session from options on the command line.
import argparse
import sys
from keystoneclient import auth
from keystoneclient import session
parser = argparse.ArgumentParser('myapp')
auth.register_argparse_arguments(parser, sys.argv[1:])
session.Session.register_cli_options(parser)
@jamielennox
jamielennox / list-plugins.py
Created February 17, 2015 05:55
List all the plugins found on the system and print their options.
import stevedore
mgr = stevedore.ExtensionManager(namespace='keystoneclient.auth.plugin',
invoke_on_load=False)
def print_plugin(ext):
print "%s:" % ext.entry_point.name
for opt in ext.plugin.get_options():
print " %s: %s" % (opt.name, opt.help)
@jamielennox
jamielennox / create-oauth.py
Created May 10, 2016 04:39
Create an OAuth Delegation to yourself, Create the delegation then test the oauth plugin against it.
# source devstack/accrc/admin/admin credentials
import argparse
import pprint
import sys
from keystoneclient import v3
from keystoneauth1 import loading
from keystoneauth1.extras import oauth1

Keybase proof

I hereby claim:

  • I am jamielennox on github.
  • I am jamielennox (https://keybase.io/jamielennox) on keybase.
  • I have a public key ASDhrFG-nUs_MVzzMuWWKbSyE-INeA5qZRGMhNRtT04oXgo

To claim this, I am signing this object:

import array
import timeit
import numpy
import sys
mask = [0x71, 0x45, 0x54, 0x82]
mask_str = ''.join(chr(m) for m in mask)
def time_numpy(data):