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
| define(function(require, exports) { | |
| var _ = require('underscore'), | |
| Backbone = require('backbone'); | |
| _.extend(exports, Backbone.Events, { | |
| initialize: function(options) { | |
| this.settings = options && options.settings || {}; | |
| this.preload = options && options.preload || {}; | |
| this.layout = require('./core/views/workspace'); |
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.contrib.auth.decorators import login_required | |
| class LoginRequiredMixin(object): | |
| login_required = True | |
| def get_login_required(self): | |
| return self.login_required | |
| def dispatch(self, request, *args, **kwargs): | |
| self.request = request |
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
| require 'chef' | |
| require 'chef/config' | |
| require 'chef/knife' | |
| current_dir = File.dirname(__FILE__) | |
| Chef::Config.from_file(File.join(current_dir, '.chef', 'knife.rb')) | |
| Vagrant::Config.run do |config| | |
| config.vm.provision :chef_client do |chef| | |
| chef.chef_server_url = Chef::Config[:chef_server_url] |
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
| # https://code.djangoproject.com/ticket/17209 | |
| import urlparse | |
| from django.conf import settings | |
| from django.core.urlresolvers import reverse_lazy | |
| from django.http import HttpResponseRedirect, QueryDict | |
| from django.utils.decorators import method_decorator | |
| from django.utils.http import base36_to_int | |
| from django.utils.translation import ugettext as _ | |
| from django.views import generic |
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 MultipartResource(object): | |
| def deserialize(self, request, data, format=None): | |
| if not format: | |
| format = request.META.get('CONTENT_TYPE', 'application/json') | |
| if format == 'application/x-www-form-urlencoded': | |
| return request.POST | |
| if format.startswith('multipart'): | |
| data = request.POST.copy() |
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
| var song = new Backbone.Model({ | |
| title: "Lucy In The Sky With Diamonds", | |
| album: new Backbone.Model({ | |
| title: "Sgt. Pepper's Lonely Hearts Club Band", | |
| release: { | |
| year: "1987" | |
| } | |
| }) | |
| }); |
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
| var categoryClassTransformer = function(value) { | |
| return (value) ? value.toLowerCase().replace(/ /g, '') : ''; | |
| }; | |
| var triedClassTransformer = function(value) { | |
| return (value == true) ? 'tried' : 'todo'; | |
| }; | |
| var Meal = Backbone.Model.extend({}), | |
| MealLogView = Backbone.View.extend({ |
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
| var authorize = function(username, key) { | |
| jQuery.ajaxSetup({ | |
| beforeSend: function(xhr) { | |
| xhr.setRequestHeader('Authorization', 'ApiKey ' + username + ':' + key); | |
| return xhr; | |
| } | |
| }); | |
| }; | |
| authorize('amccloud', '204db7bcfafb2deb7506b89eb3b9b715b09905c8'); |
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 TrackingPixelMiddleware(object): | |
| def process_message(self, message): | |
| message.body = '%s<img src="http://example.com/track.gif">' % (message.body,) | |
| return message |
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 requests, json, re | |
| def camelcase_to_underscore(text, lower=True): | |
| text = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) | |
| text = re.sub('([a-z0-9])([A-Z])', r'\1_\2', text) | |
| if lower: | |
| text = text.lower() | |
| return text |