Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of the document</title>
</head>
<body>
<table>
<thead>
<tr>
@gabrielhurley
gabrielhurley / keystone_api_test.py
Created January 26, 2012 23:32
This tests itself.
def test_tenant_create(self):
kwargs = {'id': TEST_TENANT_ID,
'description': 'aDescription',
"enabled": True}
tenant = keystoneclient_tenants.Tenant(self.request, kwargs)
keystoneclient = self.stub_keystoneclient()
keystoneclient.tenants = self.mox.CreateMockAnything()
keystoneclient.tenants.create(*kwargs.values()).AndReturn(tenant)
self.mox.ReplayAll()
@gabrielhurley
gabrielhurley / response_example.py
Created January 10, 2012 02:31
Example for cleaner multi-object response messages.
class DeleteGroup(tables.Action):
name = "delete"
verbose_name = _("Delete")
verbose_name_plural = _("Delete Security Groups")
classes = ('danger',)
def allowed(self, request, security_group=None):
if not security_group:
return True
return security_group.name != 'default'
@gabrielhurley
gabrielhurley / litany.rst
Created January 4, 2012 09:30
Litany, by Billy Collins

Litany, by Billy Collins

You are the bread and the knife, The crystal goblet and the wine...

-- Jacques Crickillon

:

@gabrielhurley
gabrielhurley / gerrit_review_process.rst
Created December 27, 2011 21:07
How to send changes to gerrit for review

How to send changes to gerrit for review

This is an opinionated step-by-step guide for how to not screw up working with Gerrit as a code review tool.

This presumes a setup where you're working on a forked copy of the repository and have created an "upstream" remote repository which points to the original.

@gabrielhurley
gabrielhurley / data_table_api.py
Created November 28, 2011 22:59
Sample API for programmatic table generation
from horizon import api
from horizon.dashboards.nova.keypairs import forms as keypair_forms
from nebula_dashboard.utils import tables
def DeleteKeyPairs(tables.TableAction):
name = "delete"
def handle(self, data_table, request, object_ids):
@gabrielhurley
gabrielhurley / utils.py
Created November 26, 2011 03:21
Django Convenience Utility Functions
# Copyright 2011 Gabriel Hurley <gabriel@strikeawe.com>
#
# Licensed under the OSI-approved Fair License:
#
# Usage of this work is permitted provided that this
# instrument is retained with the work, so that any
# entity that uses the work is notified of this instrument.
#
# DISCLAIMER: THIS WORK IS WITHOUT WARRANTY.
@gabrielhurley
gabrielhurley / horizon_gerrit_setup.rst
Created November 9, 2011 20:01
Concise instructions for manually setting up gerrit review for OpenStack Dashboard (Horizon)

How to set up Gerrit and Git Review for OpenStack Dashboard (Horizon)

Step one:

cat <<EOF >>~/.gitconfig
[alias]
    review = !sh \`git rev-parse --show-toplevel\`/tools/rfc.sh
EOF
@gabrielhurley
gabrielhurley / assignment_tag.py
Created November 9, 2011 06:46
Assignment tag backport
"""
Backports the ``register.assignment_tag`` functionality from Django 1.4 to
Django 1.3.
This code is almost entirely reproduced from
https://code.djangoproject.com/browser/django/trunk/django/template/base.py
and is the work of Django's authors:
https://code.djangoproject.com/browser/django/trunk/AUTHORS
It is licensed under Django's BSD license, available here:
@gabrielhurley
gabrielhurley / modal.html
Created November 2, 2011 21:44
Quick bootstrap modal demo
<div id='new_comment' class='fade modal'>
<form class='form-stacked' action="{% comment_form_target %}" method="POST">{% csrf_token %}
<div class='modal-header'>
<a href="#" class="close">x</a>
<h3>Discuss Activity</h3>
</div>
<div class='modal-body'>
<p>Have a question? Need more information? Add a new comment to the discussion using the form below:</p>
{{ comment_form.as_custom }}
<input type='hidden' name='name' value='{{ profile }}'/>