Skip to content

Instantly share code, notes, and snippets.

View davesque's full-sized avatar

David Sanders davesque

  • Seattle, WA
View GitHub Profile
@davesque
davesque / bicubic.py
Created November 1, 2017 16:48
Bicubic interpolator written with numpy
class BicubicError(Exception):
pass
class Bicubic(object):
C = np.array([
[1, 0, 0, 0],
[0, 0, 1, 0],
[-3, 3, -2, -1],
[2, -2, 1, 1],
from django.http import QueryDict
from django.test import TestCase
from rest_framework import serializers
from ..serializers import KnownFieldsSerializer, empty_whitelist
class MySerializer(KnownFieldsSerializer):
test_field = serializers.IntegerField()
from rest_framework import serializers
from rest_framework.fields import empty
from rest_framework.settings import api_settings
empty_whitelist = set()
class KnownFieldsMixin:
"""
trebVoiceTwo =
#(define-music-function
(parser location note)
(ly:music?)
#{
\relative c' { r16 $note 8.~ $note 4 r16 $note 8.~ $note 4 }
#})
@davesque
davesque / fizzbuzz.py
Created November 10, 2014 22:05
Favorite python fizzbuzz implementation
def d(fn):
def fn_(*args):
print fn(*args)
return fn_
fs = {
(False, True): d(lambda _: 'fizz'),
(True, False): d(lambda _: 'buzz'),
(False, False): d(lambda _: 'fizzbuzz'),
package xmltopdf;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
@davesque
davesque / gist:f3e3a43ceac2f3cdf528
Created October 1, 2014 18:52
docker-volumes compile error
root@a7a97c4c4034:/opt/docker-volumes# GOOS=darwin GOARCH=amd64 ./make.sh
package github.com/docker/docker/archive
imports github.com/docker/docker/archive
imports github.com/docker/docker/archive: cannot find package "github.com/docker/docker/archive" in any of:
/usr/src/go/src/pkg/github.com/docker/docker/archive (from $GOROOT)
/go/src/github.com/docker/docker/archive (from $GOPATH)
export.go:11:2: cannot find package "github.com/docker/docker/archive" in any of:
/usr/src/go/src/pkg/github.com/docker/docker/archive (from $GOROOT)
/go/src/github.com/docker/docker/archive (from $GOPATH)
_s() {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ $COMP_CWORD -eq 1 ]]; then
opts=($S_BIN_PATH/*)
basenames="${opts[@]##*/}"
COMPREPLY=( $(compgen -W "${basenames[@]}" -- $cur) )
fi
}
@davesque
davesque / managers.py
Created August 19, 2014 00:21
Default queryset method call manager
from collections import deque
from django.db import models
class MethodCalls(object):
"""
A mock object which logs chained method calls.
"""
def __init__(self):
@davesque
davesque / reloader.py
Created December 9, 2013 18:36
Autoreload script for local
#!/usr/bin/env python
"""
Auto-reload script for local uWSGI setups. Inspired by code in the
django.utils.autoreload module.
"""
import logging
import os
import time