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
zacharyvoase / lazy_model_loader.py
Created Apr 6, 2017
A Lazy Model loader for Django
View lazy_model_loader.py
"""
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
zacharyvoase / modelinject.py
Last active Apr 5, 2017
Django Model Injection
View modelinject.py
# -*- 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
zacharyvoase / countminsip.py
Last active Mar 14, 2017
CountMinSip: A simple CountMinSketch in Python using csiphash
View countminsip.py
# -*- 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: https://github.com/zacharyvoase/python-csiphash
"""
import csiphash
import math
import numpy as np
@zacharyvoase
zacharyvoase / translatable.py
Created Feb 6, 2017
Translatable: A monad for composable translations.
View translatable.py
"""
A monad for composable translations.
Wrap simple values:
>>> t = Translatable.value(123)
>>> t # doctest: +ELLIPSIS
Translatable(translation_keys=(), function=<function <lambda> at ...>)
>>> t.translate({})
123
@zacharyvoase
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="user.name" />
* </div>
*
@zacharyvoase
zacharyvoase / 5syllable_with_penultimate_emphasis.sh
Last active May 25, 2016
5-syllable words with the emphasis on the penultimate syllable
View 5syllable_with_penultimate_emphasis.sh
$ curl 'http://dingo.sbs.arizona.edu/~hammond/lsasummer03/newdic.txt' | awk '$2 ~ /^...''.$/ { print $4 }'
abbreviation
abracadabra
academician
accelerando
accommodation
acculturation
adjudication
alienation
alleviation
View keybase.md

Keybase proof

I hereby claim:

  • I am zacharyvoase on github.
  • I am meat (https://keybase.io/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
zacharyvoase / gist:8168217
Created Dec 29, 2013
Krugman’s Wrong on Bitcoin, ish
View gist:8168217

N.B.: This is a response to http://krugman.blogs.nytimes.com/2013/12/28/bitcoin-is-evil/

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
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 manage.py shell`.
View error-report.txt
>>> import requests
>>> requests.get('http://google.com/')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/requests/sessions.py", line 354, in request
resp = self.send(prep, **send_kwargs)
@zacharyvoase
zacharyvoase / README.md
Last active Oct 24, 2017
A li’l class for data URI manipulation in Python.
View README.md

DataURI.py

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.

Parsing

You can’t perform that action at this time.