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
| (ns doop.bootstrap | |
| (:use cascalog.playground)) | |
| (defn my-bootstrap-emacs [] | |
| "Custom bootstrap to tweak the hadoop job config for cascalog, to help | |
| manage memory." | |
| (bootstrap-emacs) | |
| (alter-var-root #'cascalog.conf/*JOB-CONF* (fn [& ignored] | |
| {"io.sort.mb" 1}))) |
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
| (with-open [client (c/create-client)] | |
| (let [response (c/GET client jira-project-url :auth {:user "user" :password "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
| def take(n, seq): | |
| "Return first n items of the seq as a list" | |
| return list(islice(seq, n)) | |
| def drop(n, seq): | |
| "Return seq with the first n items removed." | |
| return list(islice(seq, n, None, 1)) | |
| def split_by(n, seq): | |
| return [take(n, seq), drop(n, seq)] |
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 BaseModelAdmin(object): | |
| #...snip... | |
| def formfield_for_manytomany(self, db_field, request=None, **kwargs): | |
| """ | |
| Get a form Field for a ManyToManyField. | |
| """ | |
| # If it uses an intermediary model that isn't auto created, don't show | |
| # a field in admin. | |
| if not db_field.rel.through._meta.auto_created: | |
| return None |
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 SeoSiteFacet(models.Model): | |
| """This model defines the default Custom Facet(s) for a given site.""" | |
| seosite = models.ForeignKey('SeoSite') | |
| customfacet = models.ForeignKey('CustomFacet') | |
| is_default = models.BooleanField('Make this CustomFacet default', | |
| default=False) | |
| class Meta: | |
| # This is a ridiculous hack so we can display facets using the select | |
| # box instead of the dropdowns. |
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
| configurations = [] | |
| for c in configurations_qs: | |
| configurations.append({'id': c.id, 'title': unicode(c)}) | |
| configurations = list(configurations) | |
| google_analytics = list([{'id': ga.id, 'title' : ga.web_property_id} for ga | |
| in google_analytics_objs]) |
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 querytree(s): | |
| """ | |
| Build a list of nodes to describe the nested structure of a querystring. | |
| """ | |
| Node = namedtuple("Node", "level value") | |
| stack = [] | |
| # A node has children if there is a left paren before a right paren, | |
| # starting from hte index position where the node begins. | |
| for idx, char in enumerate(s): |
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
| (defun jira-rest-api-interact (method data &optional path) | |
| "Interact with the API using method 'method' and data 'data'. | |
| Optional arg 'path' may be provided to specify another location further | |
| down the URL structure to send the request." | |
| (if (not jira-rest-auth-info) | |
| (message "You must login first, 'M-x jira-rest-login'.") | |
| (let ((url-request-method method) | |
| (url-request-extra-headers | |
| `(("Content-Type" . "application/json") | |
| ("Authorization" . ,jira-rest-auth-info))) |
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 test_no_buid_sitemap(self): | |
| from lxml import etree | |
| from StringIO import StringIO | |
| site = SeoSite.objects.get(id=1) | |
| site.business_units = [] | |
| site.save() | |
| job1 = JobDetailFactory.build() | |
| job1.save() | |
| job2 = JobDetailFactory.build(uid=17059007, id=39558) | |
| job2.save() |
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 django.conf import settings | |
| from tastypie.throttle import CacheDBThrottle | |
| class SmartCacheDBThrottle(CacheDBThrottle): | |
| """ | |
| Custom throttling class to address bug in Tastypie that manifests | |
| when trying to run tests or do any kind of development with a Resource | |
| that has some kind of throttling configured. Tastypie is not smart |