Skip to content

Instantly share code, notes, and snippets.

View philippeowagner's full-sized avatar

Philippe O. Wagner philippeowagner

View GitHub Profile
@philippeowagner
philippeowagner / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Standard 1.4 urls
{% url path.to.some_view v1 v2 %}
{% url path.to.some_view arg1=v1 arg2=v2 %}
{% url app_views.client client.id %}
{% url path.to.view arg arg2 as the_url %}
{% url path.to.view as the_url %}
# Namespaced 1.4 urls
{% url myapp:view-name %}
{% url myapp:path.to.some_view v1 v2 %}
if (document.body.requestFullscreen ||
document.body.mozRequestFullScreen ||
document.body.webkitRequestFullscreen
) {
$("<button>View this chart in Full Screen</button>")
.on('click', function (e) {
var root = $interactive.get(0);
if (root.requestFullscreen) { root.requestFullscreen(); }
else if (root.mozRequestFullScreen) { root.mozRequestFullScreen(); }
else if (root.webkitRequestFullscreen) { root.webkitRequestFullscreen(); }
@philippeowagner
philippeowagner / API.md
Last active August 29, 2015 14:09 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

class PubSub(object):
"""
Very simple Pub/Sub pattern wrapper
using simplified Redis Pub/Sub functionality.
Usage (publisher)::
import redis
r = redis.Redis()
class FooAdmin(admin.ModelAdmin):
def get_urls(self):
urls = super(ContentProjectAdmin, self).get_urls()
extra_urls = patterns('',
url(r'^dashboard/$', self.admin_site.admin_view(self.dashboard), name="cms_dashboard"),
)
return extra_urls + urls
@property
def request(self):
"""
just for convenience
"""
return self
STATUS_CANCELLED = 'cancelled'
STATUS_NEW = 'new'
STATUS_PENDING = 'pending'
STATUS_PAYMENT_DUE = 'payment-due'
STATUS_PAYMENT_PENDING = 'payment-pending'
STATUS_PAID = 'paid'
NEGOTIABLE_STATUS_CHOICES = (
(STATUS_CANCELLED, 'Cancelled'), # Cancelled, duh
(STATUS_NEW, 'New'), # Default state of request
from functools import wraps
from django.conf import settings
from django.http import HttpResponseRedirect
def require_ssl(view):
"""
Decorator that requires an SSL connection. If the current connection is not SSL, we redirect to the SSL version of
the page.
@philippeowagner
philippeowagner / gist:9edaca20354eaf5e181c
Created October 23, 2014 19:44
I just set up a Squeezbox Server on my Raspberry Pi