Steps with explanations to set up a server using:
- Virtualenv
- Virtualenvwrapper
- Django
- Gunicorn
| // Pre-requisites: | |
| // 1. Device core plugin | |
| // 2. Splashscreen core plugin (3.1.0) | |
| // 3. config.xml: <preference name="AutoHideSplashScreen" value="false" /> | |
| // 4. config.xml: <preference name="DisallowOverscroll" value="true" /> | |
| function onDeviceReady() { | |
| if (parseFloat(window.device.version) >= 7.0) { | |
| document.body.style.marginTop = "20px"; | |
| // OR do whatever layout you need here, to expand a navigation bar etc |
| FadeTransitionRegion = Backbone.Marionette.Region.extend | |
| show: (view)-> | |
| @ensureEl() | |
| view.render() | |
| @close -> | |
| return if @currentView and @currentView isnt view | |
| @currentView = view |
| - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command; { | |
| DLog(@"setApplicationIconBadgeNumber:%@\n", command.arguments); | |
| self.callbackId = command.callbackId; | |
| NSMutableDictionary* options = [command.arguments objectAtIndex:0]; | |
| int badge = [[options objectForKey:@"badge"] intValue] ?: 0; | |
| [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge]; | |
| var Artist = Backbone.Model.extend(); | |
| var Artists = Backbone.Collection.extend({ | |
| model : Artist, | |
| url : "http://api.discogs.com/database/search?type=artist", | |
| sync : function(method, collection, options) { | |
| // By setting the dataType to "jsonp", jQuery creates a function | |
| // and adds it as a callback parameter to the request, e.g.: | |
| // [url]&callback=jQuery19104472605645155031_1373700330157&q=bananarama | |
| // If you want another name for the callback, also specify the |
| from tastypie.exceptions import NotFound | |
| from tastypie.resources import ModelResource | |
| from tastypie.authentication import BasicAuthentication, ApiKeyAuthentication | |
| from tastypie.models import ApiKey | |
| from django.contrib.auth.models import User | |
| __author__ = 'martinsandstrom' | |
| class ApiTokenResource(ModelResource): |
| def save_m2m(self, bundle): | |
| """ | |
| Handles the saving of related M2M data. | |
| Due to the way Django works, the M2M data must be handled after the | |
| main instance, which is why this isn't a part of the main ``save`` bits. | |
| Currently slightly inefficient in that it will clear out the whole | |
| relation and recreate the related data as needed. | |
| """ |
| $(function(){ | |
| var tokenValue = $("meta[name='csrf-token']").attr('content'); | |
| $.ajaxSetup({ | |
| headers: {'X-CSRF-Token': tokenValue} | |
| }); | |
| }) |
| var FadeTransitionRegion = Backbone.Marionette.Region.extend({ | |
| show: function(view){ | |
| this.ensureEl(); | |
| view.render(); | |
| this.close(function() { | |
| if (this.currentView && this.currentView !== view) { return; } | |
| this.currentView = view; |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.