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
| fun({Doc}) -> | |
| Bucket = couch_util:get_value(<<"bucket">>, Doc, null), | |
| Emit(Bucket, null) | |
| end. |
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
| #!/bin/bash | |
| # | |
| # This script installs and configures couchdb on a fresh Amazon Linux AMI instance. | |
| # | |
| # Must be run with root privileges | |
| # Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5) | |
| # | |
| export BUILD_DIR="$PWD" |
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
| msToDate(Milliseconds) -> | |
| BaseDate = calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}), | |
| Seconds = BaseDate + (Milliseconds div 1000), | |
| { Date,_Time} = calendar:gregorian_seconds_to_datetime(Seconds), | |
| Date. |
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
| from kombu import Exchange | |
| from kombu import Queue | |
| from kombu import BrokerConnection | |
| class ProduceConsume(object): | |
| def __init__(self, exchange_name, **options): | |
| exchange = Exchange(exchange_name, type='fanout', durable=False) | |
| queue_name = options.get('queue', exchange_name+'_queue') | |
| self.queue = Queue(queue_name ,exchange) |
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
| #!/bin/bash | |
| # | |
| # This script installs and configures couchdb on a fresh Amazon Linux AMI instance. | |
| # | |
| # Must be run with root privileges | |
| # Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5) | |
| # | |
| export BUILD_DIR="$PWD" |
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 aproperty(): | |
| doc = "The aproperty property." | |
| def fget(self): | |
| return self._aproperty | |
| def fset(self, value): | |
| self._aproperty = value | |
| def fdel(self): | |
| del self._aproperty | |
| return locals() | |
| aproperty = property(**aproperty()) |
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
| #!/bin/env python | |
| import sys | |
| from ConfigParser import SafeConfigParser, NoOptionError | |
| from optparse import OptionParser | |
| parser = OptionParser() | |
| parser.add_option("-s", "--set", dest="set", action='append', help="use to add or change an option, eg --set=processor,autostart,true\nwill add autostart=true to the [processor] section") | |
| parser.add_option("-g", "--get", dest="get", help="use to get an option, eg --get=processor,autostart\ncould return true, the default return falue is an empty string:''") | |
| (options, args) = parser.parse_args() |
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
| @register.filter(name='quantityformat') | |
| def quantityformat(bytes): | |
| """ | |
| Formats the value like a 'human-readable' file size (i.e. 13K, 4.1M, | |
| 102, etc). | |
| """ | |
| try: | |
| bytes = float(bytes) | |
| except (TypeError,ValueError,UnicodeDecodeError): | |
| return ungettext("%(size)d", "%(size)d", 0) % {'size': 0} |
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
| import httplib2 | |
| def url_fetch(url, user=None, password=None, method="GET", body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None): | |
| """ | |
| A quick version of urlopen but nealry always works | |
| """ | |
| h = httplib2.Http(".cache") | |
| if user: | |
| h.add_credentials(user,password) |
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
| sudo mkfs -t ext4 /dev/$1 | |
| sudo mount -t ext4 /dev/$1 $2 |