Skip to content

Instantly share code, notes, and snippets.

@shauns
shauns / implicit_rpc.py
Created November 8, 2014 09:49
Implicit RPC
# Implicit
result = self.make_rpc_call() # implicit switch here
@shauns
shauns / explicit_rpc.py
Last active August 29, 2015 14:08
Explicit RPC
# Explicit
result = yield from self.make_rpc_call()
@shauns
shauns / implicit_orm.py
Created November 8, 2014 09:51
Implicit ORM
# Implicit
query = self.session.query(Book)
book = query.get(1) # implicit switch here
@shauns
shauns / explicit_orm.py
Created November 8, 2014 09:52
Explicit ORM
# Explicit
query = self.session.query(Book)
book = yield from query.get(1)
@shauns
shauns / one_to_many_orm.py
Created November 8, 2014 09:55
One to many ORM
chapters = book.chapters
do_something(chapters)
@shauns
shauns / one_to_many_explicit_orm.py
Created November 8, 2014 09:57
One to Many, Explicit ORM
yield from fill_lazy_attribute(book.chapters)
chapters = book.chapters
do_something(chapters)
##
## schema file for OpenLDAP 2.x
## Schema for storing Samba user accounts and group maps in LDAP
## OIDs are owned by the Samba Team
##
## Prerequisite schemas - uid (cosine.schema)
## - displayName (inetorgperson.schema)
## - gidNumber (nis.schema)
##
## 1.3.6.1.4.1.7165.2.1.x - attributetypes
@shauns
shauns / sqlalchemy.diff
Created April 7, 2015 09:14
Diff to remove SQLAlchemy Sphinx errors
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 8d6fe5a..e064b84 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -159,6 +159,9 @@ def %(name)s(%(args)s):
fn.__func__.__doc__ = doc
else:
fn.__doc__ = doc
+
+ decorated.__module__ = fn.__module__
@shauns
shauns / github_visualise.py
Created April 8, 2015 17:21
Visual GitHub pull requests
from __future__ import unicode_literals
from collections import defaultdict
import random
import requests
from graphviz import Digraph
USERNAME = 'shauns'
PASSWORD = '****'
@shauns
shauns / sqlalchemy.py
Created April 20, 2015 14:39
Examples using SQLAlchemy for reference
from sqlalchemy import Column, Integer, Text, String, ForeignKey, \
UniqueConstraint, Table, inspect
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.orderinglist import ordering_list
from sqlalchemy.orm import relationship, backref, was_deleted
from conftest import Base, Session
def _unique(session, cls, hashfunc, queryfunc, constructor, arg, kw):