This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Parse the output of lnstat(8) into something perhaps slightly | |
# human-readable. | |
# | |
# Can take input from a file or on stdin. | |
import sys | |
lnstat_output = open(sys.argv[1]) if len(sys.argv) >= 2 else sys.stdin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursive expansion attack (aka "billion laughs") on a YAML parser | |
# | |
# See http://en.wikipedia.org/wiki/Billion_laughs | |
# | |
# Want to quadruple the result size? Just add another section. | |
--- | |
s1: &s1 | |
a: | |
- 1 | |
- 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proxy | |
NameVirtualHost *:8080 | |
Listen 8080 | |
<VirtualHost *:8080> | |
ServerName proxy-server | |
LimitRequestBody 5368709122 | |
WSGIDaemonProcess proxy-server processes=5 threads=1 | |
WSGIProcessGroup proxy-server | |
WSGIScriptAlias / /var/www/swift/proxy-server.wsgi | |
LimitRequestFields 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from collections import defaultdict | |
import calendar | |
import datetime | |
import json | |
import operator | |
import optparse | |
import paramiko | |
from pprint import pprint | |
from tabulate import tabulate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Brute-force MD5 cycle-finder. Good for keeping your laptop warm, but not | |
# much else. | |
import hashlib | |
import random | |
def h(s): | |
return hashlib.md5(s).hexdigest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_account_info(app, req, account): | |
return get_info(app, req, account) | |
def get_container_info(app, req, account, container): | |
if not container: | |
raise ValueError("container must be specified, but was %r" % container) | |
return get_info(app, req, account, container) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's examine how the account and container caching works for a simple | |
middleware like container_quotas. | |
Abbreviations used: | |
s.c.m --> swift.common.middleware | |
s.c.p.a --> swift.controllers.proxy.account | |
s.c.p.b --> swift.controllers.proxy.base | |
s.c.p.c --> swift.controllers.proxy.container | |
s.c.p.o --> swift.controllers.proxy.object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py | |
index c672928..4ffb98e 100644 | |
--- a/swift/obj/auditor.py | |
+++ b/swift/obj/auditor.py | |
@@ -158,7 +158,8 @@ class AuditorWorker(object): | |
:param partition: the partition the path is on | |
""" | |
try: | |
- assert isinstance(path, basestring) | |
+ if not path: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import json | |
import simplejson | |
data = {'hello': 'world', u'ok': u'✓', | |
'nested': {'array': [1, 2, 3, {'potato': 'potato', | |
'tomato': 'tomato'}], | |
"that's": 'Numberwäng!'}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
# -*- coding: utf-8 -*- | |
# | |
# Benchmark the relative performance of stdlib's json, simplejson, and a | |
# wrapped simplejson that gives the same API as stdlib's json. | |
import benchmark | |
import hashlib | |
import json as stdjson | |
import simplejson |