Skip to content

Instantly share code, notes, and snippets.

@mtth
mtth / json_variable.py
Created September 11, 2015 15:09
JSON encoding with variable expansion
#!/usr/bin/env python
# encoding: utf-8
"""JSON serialization with value expansion."""
from json import JSONEncoder
import re
# Try 1.
@mtth
mtth / js.py
Created September 12, 2015 17:20
Quine Python to JavaScript to Python
s = "s = %j; t = %j; print t % (t, s)"; t = "var util = require('util'); var s = %r; var t = %r; console.log(util.format(t, t, s));"; print t % (t, s)
@mtth
mtth / instrument.js
Last active November 17, 2015 06:22
Instrument Avro types
/* jshint node: true */
'use strict';
var avsc = require('avsc');
/**
* Function returning an instrumented type.
*
* @param schema {Object} Schema to parse.
@mtth
mtth / README.md
Last active August 9, 2023 20:59
Avro logical types
@mtth
mtth / README.md
Last active July 19, 2018 02:51
Avro type hooks
@mtth
mtth / README.md
Last active January 30, 2016 21:46
Avro error hooks
@mtth
mtth / README.md
Last active April 15, 2016 14:35
Avro meta type

An Avro schema to describe Avro schemas.

@mtth
mtth / Mail.avpr
Created February 26, 2016 15:45
Avro RPC
{
"protocol": "Mail",
"namespace": "example.proto",
"doc": "From https://github.com/phunt/avro-rpc-quickstart/blob/master/src/main/avro/mail.avpr",
"types": [
{
"name": "Message",
"type": "record",
"fields": [
{
@mtth
mtth / keybase.md
Last active March 23, 2019 15:28
Keybase proof

Keybase proof

I hereby claim:

  • I am mtth on github.
  • I am mtth (https://keybase.io/mtth) on keybase.
  • I have a public key whose fingerprint is 5E58 F75A 5DA4 4C4B CD67 13A0 7800 266D A107 476A

To claim this, I am signing this object:

@mtth
mtth / restli-encode.py
Last active September 26, 2022 07:01
Rest.li encode: a simpler way to encode Rest.Li query parameters.
#!/usr/bin/env python
# encoding: utf-8
"""Rest.li encode: a simpler way to encode Rest.Li query parameters.
Usage:
restli-encode.py [JSON]
Arguments:
JSON JSON string. Will read stdin if unspecified.