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
// 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
// ----
// 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))
@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
@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()
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
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
@AndrewJHart
AndrewJHart / lunch.sh
Last active August 29, 2015 14:25 — forked from carlbennett/lunch.sh
#!/bin/bash
TODAY=`date +%Y-%m-%d`
LIST=$(cat lunch.txt | perl -MURI::Escape -ne 'print uri_escape($_)')
curl -s \
-d "list=$LIST" \
-d "format=plain" \
-d "rnd=date.$TODAY" \
"https://www.random.org/lists/?mode=advanced"
@AndrewJHart
AndrewJHart / gist:c9274d06ad305d3d4f13
Last active August 29, 2015 14:27 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@AndrewJHart
AndrewJHart / Q.js Examples
Created October 29, 2015 19:36 — forked from guptag/Q.js Examples
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.
// 2. Copy/Paste this gist in the console (opened from any http site) and hit enter to run the snippets.
// Based on the inspiration from samples @ https://github.com/kriskowal/q
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////