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 / 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;
@corysimmons
corysimmons / SassMeister-input.scss
Created March 2, 2014 21:14
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
// Grid Settings
$jeet-gutter: 3 !default;
$jeet-parent-first: false !default;
$jeet-layout-direction: LTR !default;
@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': {
@ShawnMilo
ShawnMilo / validate_uuid4.py
Created December 3, 2013 20:55
Validating a uuid4 with Python.
from uuid import UUID
def validate_uuid4(uuid_string):
"""
Validate that a UUID string is in
fact a valid uuid4.
Happily, the uuid module does the actual
checking for us.
@mikermcneil
mikermcneil / sails_heroku_postgres.md
Last active February 19, 2016 07:23
How to configure a Sails.js app with a remote Postgres database hosted on Heroku

Using a PostgreSQL database on Heroku with Sails.js

The trick to setting up a Sails.js app with a remote Postgres database hosted on Heroku is all about SSL. Here's how you do it:

In your adapters.js file

Note: This is for Sails v0.9.x, the stable release at the time of this writing.

In Sails v0.10.x, the config/adapters.js file has been replaced with config/connections.js

@AndrewJHart
AndrewJHart / resources.py
Last active December 28, 2015 09:29
Override django-tastypie hydrate_FIELD to remove/delete JSON field(s) (related field in this instance) for tastypie resource on PUT request only before its converted to object and saved.
def hydrate_device(self, bundle):
"""
override hydrate method for incoming bundle hydrate is done on a per field basis (really cool)
so this allows to override only the one (related field) and to strip the JSON data from the PUT
request thus allowing PUT request to go through successfully. NOTE: Only for PUT requests - we need
this data for POST or else the related field (device) wont be created
Issue stems from the relation - DeviceSettings has one-to-one to Device, DeviceSettings stores meta
data and other stuff about the device w/o interferring with the original device model and allowing
separation of concerns to make the Device and Service models work as standalone app for apns/gcm. Thus,
unique foreign key constraint on the Device model w/ APNService FK & due to one way relationship
@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);
};
@guptag
guptag / Q.js Examples
Last active April 4, 2021 06:22
Q.js examples - Small snippets to understand various api methods in Q.js
//To run Q.js examples:
// 1. Open a new browser tab in Chrome and turn on developer toolbar (or open any http site).
// 2. Copy/Paste this gist in the console and hit enter to run the snippets.
// Based on the inspiration from samples @ https://github.com/kriskowal/q
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////