Skip to content

Instantly share code, notes, and snippets.

@yoshrote
yoshrote / parser.rb
Created July 8, 2020 19:31
sketch of a parser
# a parser which will parse a string into key-value pairs
# it respects quotes around values and coerces the values to expected types using a spec
# example at the bottom
require 'strscan'
class Parser
# Parse key-value pairs while respecting quotes and coercing values
def parse_by_spec(spec, raw_arguments)
processed_args = {}
### Keybase proof
I hereby claim:
* I am yoshrote on github.
* I am yoshrote (https://keybase.io/yoshrote) on keybase.
* I have a public key ASAIb4dui-Tk_RaOmz7id3gR5UamEz1_xfg2FiWJLFcftAo
To claim this, I am signing this object:
@yoshrote
yoshrote / py
Created October 1, 2017 11:10
distributed transaction
import datetime
import json
class DistributedTransaction(object):
TTL = datetime.timedelta(seconds=30)
def __init__(self, cache, key):
self.cache = cache
self.key = key