Skip to content

Instantly share code, notes, and snippets.

View adrianholovaty's full-sized avatar

Adrian Holovaty adrianholovaty

View GitHub Profile
@adrianholovaty
adrianholovaty / gist:2878410
Created June 5, 2012 22:10
Userless Django admin
# Does not fully work, but gets you partially there.
class UserlessAdminSite(admin.sites.AdminSite):
def check_dependencies(self):
pass
def has_permission(self, *args, **kwargs):
return True
class UserlessModelAdmin(admin.ModelAdmin):
@adrianholovaty
adrianholovaty / gist:4444825
Created January 3, 2013 16:51
Heroku deployment error
$ git push heroku master
Counting objects: 146, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (120/120), done.
Writing objects: 100% (120/120), 12.64 KiB, done.
Total 120 (delta 98), reused 0 (delta 0)
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.3.
-----> Preparing Python runtime (python-2.7.3)
-----> Installing Distribute (0.6.34)
// Copyright 2013 Soundslice LLC. License: BSD.
/* HTML example: ****************
<figure class="vid">
<video preload>
<source src="/videos/help/playhead.mp4" type="video/mp4">
<source src="/videos/help/playhead.webm" type="video/webm">
</video>
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p>
@adrianholovaty
adrianholovaty / stuff.py
Created September 5, 2013 04:31
Django two-phased template rendering
# Two-phased template rendering.
# See http://www.holovaty.com/writing/django-two-phased-rendering/
# LICENSE: Public domain.
################
# TEMPLATE TAG #
################
from django import template
register = template.Library()
@adrianholovaty
adrianholovaty / retina_help.txt
Last active August 29, 2015 14:05
Soundslice retina test
Hey, I'm trying to test this page on as many hi-DPI (aka "retina") devices
as possible:
http://www.soundslice.com/scores/auld-lang-syne/?retina
Can you take a look and let me know whether everything looks good and whether
it's any more sluggish than the non-retina version? Also let me know your
devicePixelRatio, which you can get from http://www.devicepixelratio.com/ --
if your ratio is something other than 1 or 2 (e.g., 1.5), I'm particularly
interested.
@adrianholovaty
adrianholovaty / serviceworker-cache-wrapper.js
Created December 27, 2015 14:06
Service worker cache wrapper that lets you use arbitrary cache keys
function cachePut(key, request, response) {
caches.open(key).then(function(cache) {
cache.put(request, response);
});
}
function cacheGet(key) {
return new Promise(function(resolve, reject) {
caches.open(key).then(function(cache) {
cache.keys().then(function(keyArray) {
if (keyArray.length) {
@adrianholovaty
adrianholovaty / serviceworker-cache-wrapper-example.js
Created December 27, 2015 14:10
Example usage of serviceworker-cache-wrapper.js
var jsonDataRe = /example\.com\/(.*\.json)/;
self.addEventListener('fetch', function(event) {
var request = event.request,
match = jsonDataRe.exec(request.url);
if (match) {
// Use regex capturing to grab only the bit of the URL
// that we care about, ignoring query string, etc.
var cacheKey = match[1];
@adrianholovaty
adrianholovaty / service-worker-cache-example.js
Last active May 5, 2020 21:25
Better example of custom service worker cache keys
var jsonDataRe = /example\.com\/(.*\.json)/;
self.addEventListener('fetch', function(event) {
var request = event.request,
match = jsonDataRe.exec(request.url);
if (match) {
// Use regex capturing to grab only the bit of the URL
// that we care about, ignoring query string, etc.
var cacheRequest = new Request(match[1]);