On a previous post we've talked abut our new REST API and the benefits it provides to our power users. If that was not enough for your satisfaction, we are releasing REST Clients for Python and Ruby to help you use our service without having worry about anything.
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 unittest import TestCase, main | |
| from netdnarws import NetDNA | |
| class SomeDescritptiveTestName(TestCase): | |
| def setUp(self): | |
| self.api = NetDNA("alias", | |
| "xxx", | |
| "xxx", | |
| "lrws.netdna.com", |
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 json | |
| import requests | |
| from oauth_hook import OAuthHook | |
| class NetDNAOAuthHook(OAuthHook): | |
| def __init__(self, consumer_key, consumer_secret, token=None, | |
| token_secret=None, header_auth=True, **kwargs): |
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 | |
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
| //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
| 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
| 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
| 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
| try: | |
| # ... | |
| try: | |
| hago_algo_que_puede_llegar_a_romper() | |
| except Exception, e: | |
| raise MiExceptionMasBonita(e) | |
| # ... |