Skip to content

Instantly share code, notes, and snippets.

@powdahound
powdahound / deferred_chain.py
Created October 15, 2009 16:13
Looking for a cleaner way to implement this pattern.
def do_stuff():
"""Does 3 things in serial"""
def cb_stuff1(unused):
print 'Doing stuff #1'
deferreds = []
for obj in self.objects.values():
deferreds.append(obj.do_something())
return defer.DeferredList(deferreds)
def cb_stuff2(unused):
>>> gc.get_objects()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/Twisted-8.2.0-py2.6-linux-x86_64.egg/twisted/conch/manhole.py", line 119, in displayhook
self.write(repr(obj))
File "/usr/local/lib/python2.6/dist-packages/pyasn1-0.0.6a-py2.6.egg/pyasn1/v1/type/base.py", line 50, in __getattr__
raise error.PyAsn1Error('No value for %s()' % attr)
PyAsn1Error: No value for __repr__()
INFO: Starting Chef Run
DEBUG: Loading plugin os
DEBUG: Loading plugin ruby
DEBUG: Loading plugin languages
DEBUG: Loading plugin kernel
DEBUG: ---- Begin uname -s STDOUT ----
DEBUG: Linux
DEBUG: ---- End uname -s STDOUT ----
DEBUG: ---- Begin uname -s STDERR ----
DEBUG:
RewriteEngine On
RewriteBase /
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
#!/usr/bin/ruby
# prints "true"
if "".length
puts "true"
end
# prints "false"
puts ("".length == true)
ERROR: #<Chef::RunList:0xb796c758 @recipes=["company::ops_site", "company::blog"], @run_list=["role[base]", "role[dev_environment]", "role[mail_server]", "role[couchdb_server]", "role[tetra_server]", "role[web_server]", "role[memcache_server]", "role[mysql_server]", "recipe[company::ops_site]", "recipe[company::blog]"], @roles=["base", "dev_environment", "mail_server", "couchdb_server", "tetra_server", "web_server", "memcache_server", "mysql_server"]>
# Record errors
type=Single
ptype=RegExp
pattern=^\[(\w+)\] \[(.+)\] ERROR: (.+)$
desc=Error
context=my.log
action=add errors [Error] $3\nTime: $1\nHost: $2\n\n
# Report errors every minute if there are any
type=Calendar
#!/bin/sh
# collectd's exec plugin was writing a bunch of
# "Success: 1 value has been dispatched." to stdout
# so we'll just ignore it since we ask collectd to
# write to syslog anyway [Garret, 2009-12-08]
exec >/dev/null 2>&1
exec /opt/collectd/sbin/collectd -f -C /opt/collectd/etc/collectd.conf
#!/bin/sh
exec >/dev/null 2>&1
echo "hello stdout"
ls
echo "hello stderr" >&2
ls >&2
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'