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 Entity(object): | |
| errors = {} | |
| validators = {} | |
| def __init__(self, **kwargs): | |
| for name, value in kwargs.iteritems(): | |
| try: | |
| if self._is_extra_property(name, value): | |
| self._extra_properties(name, 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
| class Require(object): | |
| @staticmethod | |
| def assert_equals(expected, expectee, comment="") | |
| try: | |
| assert expected == expectee | |
| except AssertionError: | |
| comment = "%s, " if comment | |
| raise AssertionError(comment + "expected: %r, but was: %r" % (expected, expectee)) |
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 timeit | |
| def strip(a_string): | |
| return a_string.strip() | |
| results_map = [] | |
| results_list_comprehension = [] | |
| comp_list = [' 123', ' 123', '123', '123 ','123 '] | |
| def strip_map(): |
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
| try: | |
| # ... | |
| try: | |
| hago_algo_que_puede_llegar_a_romper() | |
| except Exception, e: | |
| raise MiExceptionMasBonita(e) | |
| # ... |
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
| is_mismatch: function (alert) { | |
| return alert.alert_tyoe === "listing_mismatch"; | |
| }, | |
| is_info_missing: function (alert) { | |
| return alert.alert_type === "listing_info_missing"; | |
| }, | |
| has_mismatch: function () { | |
| var that = this; | |
| return _.any(this.alerts, function (alert) { | |
| return that.is_mismatch(alert); |
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
| render_mismatch: function (self, mismatch_type, default_value) { | |
| return (self['has_' + mismatch_type + '_mismatch']()) ? | |
| self['get_' + mismatch_type + '_diff']() : | |
| default_value; | |
| }, | |
| render_name_mismatch: function () { | |
| return this.render_mismatch(this, 'name', this.name); | |
| }, |
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 _verify_new_instances_for_existing_businesses(subscription_group, new_groups): | |
| for subscription in subscription_group['subscriptions']: | |
| for instance_group in new_groups: | |
| if subscription['monitored']['business_id'] == instance_group['business_id']: | |
| for instance in instance_group['instances']: | |
| update = False | |
| old_instances = [ monitored_item['instance'] for monitored_item in monitored['monitored_list'] ] | |
| if not instance in old_instances: | |
| update = True |
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
| //Este funciona | |
| { | |
| action_params: { }, | |
| display_name: "Flag as inappropriate", | |
| action_type: "external_link", | |
| preconditions: { | |
| hard_dependencies: false, | |
| dependencies: [ ], | |
| precondition_data: { |
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
| ;; A little XML/xHTML templating engine as an excercise for learning clojure | |
| (defn attr [a-map] | |
| ^{:doc "renders an attribute" | |
| :test (fn [] | |
| (assert (= "class='hola'" (attr {:name "class", :value "hola"}))))} | |
| (str (:name a-map) "='" (:value a-map) "'")) | |
| (defn as-attr-list [ats] | |
| ^{:doc "renders a list of attributes" | |
| :test (fn [] |
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
| #NetDNA API Sample Code - Python | |
| #Version 1.0a | |
| # Thanks to @sajal from TurboBytes.com for getting this script started | |
| # Contributed: @jdorfman & the @netdna family | |
| import oauth.oauth as oauth | |
| import httplib2, json | |
| import pprint | |
OlderNewer