Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html | |
Hi everyone, I'm Chris Wanstrath. | |
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But | |
then I took a few moments and thought, Wait, why? Why me? What am I supposed | |
to say that's interesting? Something about Ruby, perhaps. Maybe the | |
future of it. The future of something, at least. That sounds | |
keynote-y. | |
A unit test helper library for App Engine. | |
Note that this is currently COMPLETELY UNTESTED. Consider it demo code only. | |
This library aims to make it easier to unit-test app engine apps and libraries | |
by handling the creation and registration of service stubs and so forth for you. | |
It also provides a custom implementation of the Capability service that allows | |
you to specify what capabilities you want it to report as disabled, and it wraps | |
all stubs in a wrapper that will throw a CapabilityDisabledError if you attempt | |
to use a disabled service or method. |
application: filehangar | |
version: live | |
runtime: python | |
api_version: 1 | |
handlers: | |
- url: /remote_api | |
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py | |
login: admin |
schedule = a_periodic_task.run_every | |
next = next_ocurrance(schedule.minute, schedule.hour, schedule.day_of_week) | |
def next_ocurrance(minutes, hours, days_of_week): | |
# days_of_week convention: Sunday = 0, Saturday = 6 | |
# dateutil convention: Monday = 0, Sunday = 6 | |
now = datetime.datetime.now() | |
weekday = now.isoweekday() |
# Usage: show <local-port> <subdomain> | |
function show() { | |
DOMAIN=".tekacs.com" | |
REMOTE="$2$DOMAIN" | |
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost" | |
} |
#!/bin/bash | |
# This hook is run after every virtualenv is activated. | |
export OLD_GEM_HOME=$GEM_HOME | |
export GEM_HOME=$VIRTUAL_ENV/gems/ | |
export GEM_PATH= | |
export PATH=$VIRTUAL_ENV/gems/bin:$PATH |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
""" | |
A really stupid python template language inspired by coffeekup, markaby. | |
Do not use this code, it will ruin your day. A byproduct of insomnia. | |
TL;DR | |
----- | |
This module defines a template language that allows us to do: | |
d = Doc() |
#!/bin/bash | |
# For CentOs 5.7 | |
ln -s /lib/libssl.so.0.9.8e /lib/libssl.so.0.9.8 | |
ln -s /lib64/libssl.so.0.9.8e /lib64/libssl.so.0.9.8 | |
ln -s /lib/libcrypto.so.0.9.8e /lib/libcrypto.so.0.9.8 | |
ln -s /lib64/libcrypto.so.0.9.8e /lib64/libcrypto.so.0.9.8 | |
ln -s /lib/libexpat.so.0 /lib/libexpat.so.1 | |
ln -s /lib64/libexpat.so.0 /lib64/libexpat.so.1 |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!