Skip to content

Instantly share code, notes, and snippets.

Zachary Voase zacharyvoase

Block or report user

Report or block zacharyvoase

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
zacharyvoase /
Created Apr 6, 2017
A Lazy Model loader for Django
Do `import lazy_model_loader` as early as possible in your application's
lifecycle, then:
from lazymodels.my_app import MyModel
def some_func():
return MyModel.objects.filter(name='Foo')
We're hacking the Python import system to enable you to import lazy references
zacharyvoase /
Last active Apr 5, 2017
Django Model Injection
# -*- coding: utf-8 -*-
Model class injectors, to make Django 1.9+'s app registry easier to work with.
Django 1.9 made it an error to import an app's models submodule when importing
the app module itself. Instead, you should use `apps.get_model(app_label,
model_name)` to get the model class, and signals should be wired up in the
`ready()` hook of a custom `AppConfig` subclass.
zacharyvoase /
Last active Mar 14, 2017
CountMinSip: A simple CountMinSketch in Python using csiphash
# -*- coding: utf-8 -*-
SipHash works well as a family of pairwise-independent hash functions for a CountMinSketch.
This implementation uses my Python cffi-bound version:
import csiphash
import math
import numpy as np
zacharyvoase /
Created Feb 6, 2017
Translatable: A monad for composable translations.
A monad for composable translations.
Wrap simple values:
>>> t = Translatable.value(123)
>>> t # doctest: +ELLIPSIS
Translatable(translation_keys=(), function=<function <lambda> at ...>)
>>> t.translate({})
zacharyvoase / bootstrapValidation.js
Created Jun 21, 2016
Sync form field validation state between Angular and Bootstrap
View bootstrapValidation.js
* Angular's ngModel helpfully adds the `ng-invalid` class to form controls
* containing invalid input. However, Bootstrap forms are typically structured
* like so:
* <div class="form-group">
* <label>Name*</label>
* <input class="form-control" type="text" ng-model="" />
* </div>
zacharyvoase /
Last active May 25, 2016
5-syllable words with the emphasis on the penultimate syllable
$ curl '' | awk '$2 ~ /^...''.$/ { print $4 }'

Keybase proof

I hereby claim:

  • I am zacharyvoase on github.
  • I am meat ( on keybase.
  • I have a public key whose fingerprint is EB8F 83DF B7F7 7478 5826 635C 8C5B 7543 A8AB F545

To claim this, I am signing this object:

zacharyvoase / gist:8168217
Created Dec 29, 2013
Krugman’s Wrong on Bitcoin, ish
View gist:8168217

N.B.: This is a response to

I can't help but think that it's unproductive to classify things as ‘good’ or ‘evil’ if you can't ultimately control them. Bitcoin isn’t good or evil, it just is.

On the question of “backing”: what it’s backed up by is the fact that some people are willing to spend their own assets and labor to acquire BTC, in the belief that so will other people and thus that BTC is and will remain liquid and valuable. It’s a Keynesian Beauty Contest (KBC), a concept I would expect Krugman to be more than familiar with.

My beef with Bitcoin is that it has proven itself to be a shitty medium of exchange and a shitty store of value—neither of these hold ‘rapid, unpredictable changes in valuation’ as a desirable trait, yet the KBC nature of the technology ensures that this trait will hold for Bitcoin, because minor fluctuations in individuals’ confidence are magnified and become rapid swings in price.

The irony of Bitcoin is that it

zacharyvoase / error-report.txt
Created May 14, 2013
Seeing an error on Heroku with name resolution—this is what happens when I do `heroku run python shell`.
View error-report.txt
>>> import requests
>>> requests.get('')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/requests/", line 55, in get
return request('get', url, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/requests/", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/requests/", line 354, in request
resp = self.send(prep, **send_kwargs)
zacharyvoase /
Last active Oct 24, 2017
A li’l class for data URI manipulation in Python.

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.


You can’t perform that action at this time.