Skip to content

Instantly share code, notes, and snippets.

View zacharyvoase's full-sized avatar

Zack Voase zacharyvoase

View GitHub Profile
@zacharyvoase
zacharyvoase / gist:8168217
Created December 29, 2013 07:05
Krugman’s Wrong on Bitcoin, ish

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 11:18
Seeing an error on Heroku with name resolution—this is what happens when I do `heroku run python manage.py shell`.
>>> 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 May 21, 2020 06:19
A li’l class for data URI manipulation in Python.

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

@zacharyvoase
zacharyvoase / views.py
Created April 26, 2013 11:42
Example: Content negotiation in Django. This may be more complicated than it needs to be; it'd be simple to write a library which deals with the common cases rather than having to do the full broker registration.
from broker import Broker # https://github.com/zacharyvoase/broker
from django.core import serializers # https://docs.djangoproject.com/en/dev/topics/serialization/
from django.http import HttpResponse
from django.shortcuts import render
from myapp.models import Thing
# This is just a library I wrote once to help do content negotiation.
# We define a 'renderers' for each supported content type (HTML and JSON)
import sys
import subprocess
import tempfile
import urllib
text = sys.stdin.read()
chart_url_template = ('http://chart.apis.google.com/chart?'
'cht=qr&chs=300x300&chl={data}&chld=H|0')
chart_url = chart_url_template.format(data=urllib.quote(text))
@zacharyvoase
zacharyvoase / morse.ino
Last active December 14, 2015 08:49
Make your Arduino speak Morse code. Hook it up to an LED or a buzzer in series with a small resistor, and then write in text over the serial port. Done. This gist now includes an object code dump.
int led_pin = 2;
#define PERIOD (100)
void setup() {
pinMode(led_pin, OUTPUT);
Serial.begin(9600);
}
void writeMorse(char *code) {
int i = 0;
@zacharyvoase
zacharyvoase / Makefile
Created December 30, 2012 16:42
Basic Makefile for AVR development on OS X using CrossPack (http://www.obdev.at/products/crosspack/index.html).
# Basic AVR Makefile
# Author: Zachary Voase
# License: Public Domain <http://unlicense.org/>
#
# Configured to work with the Arduino Uno R3, programmed from a Mac, using
# CrossPack (http://www.obdev.at/products/crosspack/index.html).
# This needs to be the TTY device on your Mac at which the Arduino is mounted.
# Mine is normally either 1421 or 1411.
PORT = /dev/tty.usbmodem1421
import socket
def udp_socket():
return socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
def receive():
sock = udp_socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
#define E 2.71828182846
// The ordered list of output pins, and the length thereof.
int pins[] = {3, 5, 6, 9, 10};
int pins_length = 5;
// This needs to be close to 30ms to be perceived as smooth (NTSC = 33.36ms)
int refresh_interval = 30;
// Intervals are useful for explicitly declaring the valid range for a value,
// and converting values between ranges (e.g. 0 - 1.0 => 0 - 255).
diff --git a/util/point.sh b/util/point.sh
index da39899..5ee728b 100755
--- a/util/point.sh
+++ b/util/point.sh
@@ -1,5 +1,21 @@
#!/bin/sh
+inode () {
+ # Get the device:inode of a regular file (or the target of a symlink).
+ # These two pieces of information uniquely identify a file.