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 datetime, copy | |
| from optparse import Option, OptionValueError | |
| def check_datatime(option, opt, value): | |
| try: | |
| return datetime.datetime.strptime(value, option.datetime_format) | |
| except ValueError: | |
| raise OptionValueError( | |
| "option %s: invalid complex value: %r" % (opt, value)) |
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 extend_optparser import make_option | |
| from django.core.management.base import BaseCommand | |
| class DaemonCommand(BaseCommand): | |
| help = 'Runs a process as a daemon' | |
| VERSION="Please Set!!!!" | |
| option_list = BaseCommand.option_list + ( | |
| make_option('--daemon', dest='daemon', action="store_true", default=False), | |
| make_option('--delay', dest='delay', type='int', default=20), |
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
| class DynamicChoice(object): | |
| """ | |
| Trivial example of creating a dynamic choice | |
| """ | |
| def __iter__(self): | |
| for choice in self.generate(): | |
| if hasattr(choice,'__iter__'): | |
| yield (choice[0], choice[1]) | |
| else: |
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
| % Couchdb: An erlang map function to get a value from a sub record | |
| % | |
| % gets and emits a record for each sub record in legs keyed by "value_date" | |
| % For the date see: https://gist.github.com/1125467 | |
| % | |
| fun({Doc}) -> | |
| Bump = fun(Doc, Rec, Field) -> | |
| case {proplists:get_value(Field, Rec)} of | |
| {undefined} -> | |
| ok; |
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
| { | |
| "_id": "encompass-375613-20101026", | |
| "_rev": "1-4990bb59d43e6024a4e246b7c0823201", | |
| "source": "encompass", | |
| "keys": [ | |
| "transaction_id", | |
| "legs" | |
| ], | |
| "timestamp": "Wed Nov 17 18:12:55 2010", | |
| "trader": "XXX, XXXXX", |
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
| /* | |
| * runs the function, worker, through a number of steps with a delay between each step. | |
| * This example flicks through a bunch of images. | |
| * step(0,10, function(num, stop) { | |
| * $('#mo').attr('src', 'images/'+num+'.jpg'); | |
| * }, 600); | |
| */ | |
| function step(ind, stop, worker, delay) { | |
| if (ind < stop) { |
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
| list_to_integer(binary_to_list(<<"-12345">>)) |
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}) -> | |
| case {proplists:get_value(<<"name">>, Doc), proplists:get_value(<<"value">>, Doc)} of | |
| {undefined, _} -> | |
| ok; | |
| {_, undefined} -> | |
| ok; | |
| {Name, Value} -> | |
| Emit(Name, {Doc}); | |
| _ -> | |
| ok |
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
| #doing a remote branch in git | |
| git push origin origin:refs/heads/version-001 |
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
| %%%% use couchdb -i to get to the couch prompt. | |
| couch_util:json_decode(<<"{\"key\":\"value\"}">>). |