Skip to content

Instantly share code, notes, and snippets.

View AndrewJHart's full-sized avatar
:electron:
Building react apps & micro-services

Andrew Hart AndrewJHart

:electron:
Building react apps & micro-services
View GitHub Profile
@AndrewJHart
AndrewJHart / external_tastypie_serialization.py
Last active November 28, 2018 21:30 — forked from marteinn/external_tastypie_serialization.py
Different ways to use Tastypie's resource serialization and build a response outside of the API or a resource.. e.g. a separate view in views.py, building a custom view within the resource, etc..
"""
Credit to the parker library (https://github.com/coxmediagroup/parker/) and their TastyPieHandler.
"""
# Examples of building manual responses anywhere, w/i extra views, and overridden methods
############################################################################
# example of building a serialized response from anywhere
req = HttpRequest()
@AndrewJHart
AndrewJHart / FadeTransitionRegion.coffee
Created April 10, 2014 20:21 — forked from charlycoste/FadeTransitionRegion.coffee
CoffeeScript version of the animated marionette.region FadeTransitionRegion
FadeTransitionRegion = Backbone.Marionette.Region.extend
show: (view)->
@ensureEl()
view.render()
@close ->
return if @currentView and @currentView isnt view
@currentView = view
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Jeet 5 - http://jeet.gs
/* Syntax Quick Reference
--------------------------
column($ratios: 1, $offset: 0, $cycle: 0, $uncycle: 0, $gutter: jeet(gutter))
FadeTransitionRegion = Backbone.Marionette.Region.extend
show: (view)->
@ensureEl()
view.render()
@close ->
return if @currentView and @currentView isnt view
@currentView = view
// 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
@AndrewJHart
AndrewJHart / leaflet-google.js
Created March 25, 2014 17:26 — forked from crofty/leaflet-google.js
Plugin to use with leaflet.js for mobile app maps integration.
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
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;
@AndrewJHart
AndrewJHart / tastypie_ApiKey_Resource.py
Last active August 29, 2015 13:56 — forked from mkubenka/api.py
Inspiration for the ApiKey resource implementation; thanks to original author martinsandstrom.
from tastypie.exceptions import NotFound
from tastypie.resources import ModelResource
from tastypie.authentication import BasicAuthentication, ApiKeyAuthentication
from tastypie.models import ApiKey, create_api_key
from django.contrib.auth.models import User
# listen for post_save signal on User model & trigger a function to generate the API key
models.signals.post_save.connect(create_api_key, sender=User)
# callable that takes allowed methods for production but returns POST & GET verbs if testing w/ localhost or debug
@AndrewJHart
AndrewJHart / logging_settings.py
Last active January 4, 2016 15:29 — forked from palewire/settings.py
Semi-advanced and useful logging config for django. Makes for good base to replace default Django config; great for app layout skeleton
# replaces default django logging config
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
@AndrewJHart
AndrewJHart / Backbone.sync_csrftoken.js
Created November 14, 2013 15:47 — forked from gcollazo/Backbone.sync_csrftoken.js
Set backbone to automatically set the CSRF header token for django for all ajax requests
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};