Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/python | |
# This requires rados.py to be at least as recent as | |
# https://raw.github.com/chrisglass/ceph/expose_cluster_stats_to_python/src/pybind/rados.py | |
import rados | |
stats = {} | |
with rados.Rados(conffile='/etc/ceph/ceph.conf') as cluster: | |
stats = cluster.get_cluster_stats() | |
print stats |
☭ ~ $ revel new src/sweet_app | |
☭ ~ $ cd src/sweet_app/ | |
☭ ~/sweet_app $ git init | |
☭ ~/sweet_app (master)$ cat > .godir | |
sweet_app | |
^C | |
☭ ~/sweet_app (master)$ git add .godir * | |
☭ ~/sweet_app (master)$ git ci -m"Initial" | |
☭ ~/sweet_app (master)$ heroku create --buildpack https://github.com/traviscline/heroku-buildpack-go-revel.git | |
☭ ~/sweet_app (master)$ git push heroku master |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
def acquire(name): | |
tries = 0 | |
while True: | |
tries += 1 | |
if tries >= 30: | |
raise Exception("Couldn't acquire lock on mutex "+name) | |
try: | |
n = r.incr("lock-"+name) | |
if n == 1: | |
return True |
# generate super secret private key | |
# (not really, this key and the certificate are "throwaway" items) | |
openssl genrsa -des3 -out ssl.key 1024 | |
# generate the self-signed certificate | |
openssl req -new -x509 -nodes -sha1 -days 365 -key ssl.key -out ssl.crt | |
# create decrypted version of key so that nginx can be started without a passphrase | |
openssl rsa -in ssl.key -out ssl.key.insecure | |
chmod 600 ssl.key.insecure |
1. Knowledge is Power. | |
2. Time is Money. | |
As every engineer knows: | |
Power = Work / Time | |
Since: | |
Knowledge = Power | |
Time = Money |
<ionelmc> single currency, mail shiping for start - however there's need for some various discounting schemes for products and some fancy category scheme i think | |
<ionelmc> so the Product.get_specific implementation is going to be replaced by djnago-polymorphic ? | |
<Tribaal> ionelmc, I'll keep the polymorphic branhc around, I think it's really elegan | |
<Tribaal> so I'll test more before I make a decision | |
<ionelmc> if i need to manage stock i have to build my own models for that right? | |
<Tribaal> but generally I thin kit's the right way to go, yeah | |
<Tribaal> ionelmc, yes, for the time being | |
<Tribaal> for stock I think there should be a new type of plugin almost (like a transaction plugin) | |
<Tribaal> it would be useful for vouchers too, for instance | |
<Tribaal> for the time being the stock needs to be handled in your own models, however |
from django.core.urlresolvers import get_resolver | |
from django.core.urlresolvers import RegexURLResolver, RegexURLPattern | |
def _recurse_resolver(resolver, prefix=[]): | |
patterns = [] | |
for obj in resolver.url_patterns: | |
if isinstance(obj, RegexURLPattern): | |
patterns.append(prefix + [obj.regex.pattern]) | |
elif isinstance(obj, RegexURLResolver): |
#!/bin/bash | |
# This should be run on a relatvely modern version of Ubuntu (9.10 or later, | |
# without any sort of confidence) | |
PROJECT_NAME=$1 | |
if [ x$PROJECT_NAME = "x" ] ; then | |
# No project name! | |
echo "Usage: $0 <project name>" | |
exit 1 |
import os | |
import socket | |
class IP(object): | |
def __init__(self): | |
self.base = None | |
def get(self, end): | |
if not self.base: |