Skip to content

Instantly share code, notes, and snippets.

View ont's full-sized avatar
🐳
captain, docker ahead!

ont

🐳
captain, docker ahead!
View GitHub Profile
@ont
ont / parser.py
Last active January 24, 2020 11:01
tnsnames.ora parser
import re
class Parser:
def parse(self, text):
tokens = self.tokenize(text)
return self.parse_dict(tokens)
def tokenize(self, text):
return [ x for x in re.split(r'(\s+|[()=])', text) if x.strip()]
@ont
ont / nomad-job-parsing.go
Created November 12, 2019 13:49
Example of parsing part of nomad's job hcl file.
package main
import (
"fmt"
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsimple"
//"github.com/zclconf/go-cty/cty"
)
@ont
ont / wait_kill.py
Created November 1, 2019 05:36
Wait for blocking stdout.readline() then kill subprocess.
import os
import signal
from threading import Thread
from subprocess import Popen, PIPE, TimeoutExpired
def kill_proc(proc):
try:
print("waiting...")
proc.wait(timeout=5)
except TimeoutExpired:
@ont
ont / sync-gateway.log
Created October 30, 2017 09:00
Sync gateway log for issue
2017-10-27T07:24:03.020Z HTTP: #2190: GET /babycare-auth/_local/85a8f08fa42b380e90d6306e3bb66ded9ab64fff
2017-10-27T07:24:03.020Z HTTP: #2190: --> 401 Login required (1.7 ms)
2017-10-27T07:24:03.022Z HTTP: #2191: GET /babycare-auth/_local/0033b6c2b8f1bb565e1556531e7fd5ffdfb3582a
2017-10-27T07:24:03.022Z HTTP: #2191: --> 401 Login required (0.6 ms)
2017-10-27T07:24:03.272Z HTTP: #2192: GET /babycare-auth/_user/13266487-63e4-4108-9199-76c1baee3d12 (ADMIN)
2017-10-27T07:24:03.273Z HTTP: #2192: --> 404 missing (1.5 ms)
2017-10-27T07:24:03.274Z HTTP: #2193: GET /babycare-auth/_user/13266487-63e4-4108-9199-76c1baee3d12 (ADMIN)
2017-10-27T07:24:03.274Z HTTP: #2193: --> 404 missing (0.4 ms)
2017-10-27T07:24:03.276Z HTTP: #2194: POST /babycare-auth/_user/ (ADMIN)
2017-10-27T07:24:03.277Z HTTP: #2195: POST /babycare-auth/_user/ (ADMIN)
@ont
ont / prototype.py
Created June 29, 2015 15:22
ili9327 mcufriend.com prototype code
import time
import RPi.GPIO as g
g.setmode(g.BOARD)
pins = [
7, # cs
11, # wr - clock (rising edge)
12, # rs - data/command
15, # d1