Skip to content

Instantly share code, notes, and snippets.

@mattdw
mattdw / unlitspriteshader.js
Last active August 5, 2020 20:14
a sprite shader for THREE.js which doesn't need to clone textures, by storing its own repeat/offset
import THREE from "lib/three";
const params = `
varying vec2 vUv;
uniform vec2 offset;
uniform vec2 repeat;
uniform sampler2D texture;
uniform vec3 color;
`
@mattdw
mattdw / keybase.md
Last active August 16, 2016 11:19
keybase.md

Keybase proof

I hereby claim:

  • I am mattdw on github.
  • I am mattdw (https://keybase.io/mattdw) on keybase.
  • I have a public key ASB3vKYhhR3xVZW78xI-9omf_HPaFsiAL7oAAAJtxSUGEgo

To claim this, I am signing this object:

@mattdw
mattdw / simple_search.py
Created April 19, 2012 23:24
A simple functional search query creator for Django.
from django.db.models import Q
from django.utils.text import smart_split
def get_or_query(query_string, fields):
return reduce(Q.__or__,
(Q(**{'%s__iregex' % field: r"[[:<:]]%s" % term.strip('\'"')})
for term in smart_split(query_string) if term not in ['and', 'or']
for field in fields),
Q())
@mattdw
mattdw / multiqueryset.py
Created March 8, 2012 02:17
Django MultiQuerySet (for easy reference)
class MultiQuerySet(object):
def __init__(self, *args, **kwargs):
self.querysets = args
self._count = None
def count(self):
if not self._count:
self._count = sum(len(qs) for qs in self.querysets)
return self._count
@mattdw
mattdw / userStyles.css
Created September 6, 2011 03:58
Replace Julian Assange with a Kitten in the Wikileaks Cable Viewer
/* User CSS to replace Julian Assange with a Kitten in the Wikileaks Cable Viewer
* (doesn't work on other Wikileaks pages, only the Cable Viewer)
* for domain: wikileaks.org
* Safari User CSS extension here: http://code.grid.in.th/
*/
.pane.small a[href="/support.html"] img {
display: none;
}
Java 6 on Mac OS X 10.5 Leopard
===============================
Apparently Java 6 (that is, 1.6) has been available on Mac OS X for
quite some time (ie. almost a year.) I was entirely unaware of this;
I'm probably not the only one. To enable Java 6, simply run
`/Applications/Utilities/Java Preferences.app`, and drag the available
JVMs into the order you prefer.
This will swap the default 'java', 'javac' etc to point to your first