Skip to content

Instantly share code, notes, and snippets.

# This function will be called before each test case.
setup () {
# This block will run only for the first test in this file.
# Usefull for setting up resources that should last for all tests.
if [[ "$BATS_TEST_NUMBER" -eq 1 ]]; then
:
fi
:
}
@tilacog
tilacog / pretty_sped_specification.py
Created April 17, 2018 17:52
pretty print specification files
import sys
from xml.etree.ElementTree import iterparse
from types import SimpleNamespace
def show(text, depth, spacer=' '):
print(spacer * depth + text)
def main(spec_file_path):
@tilacog
tilacog / unzip-recurse.py
Created January 22, 2018 21:00 — forked from pmuellr/unzip-recurse.py
tool to recursively unzip .zip and .jar files
#!/usr/bin/env python
import os
import sys
import subprocess
import zipfile
#-----------------------------------------------------------------------------
def main():
fileNames = sys.argv[1:]
@tilacog
tilacog / esocial-xsd-to-csv.py
Last active November 10, 2017 16:11
converter xsds do esocial para csv
import os
import csv
import sys
from glob import glob
from xml.etree import ElementTree as ET
xsd_dir_path = 'PUT BASE DIRECTORY HERE :)'
no_duplicate_tables = '--no-duplicates' in sys.argv
done_tables = set()
@tilacog
tilacog / Makefile
Created November 2, 2017 00:25
Download NFe XML files from Google
numsites=3
all: invoices
search-results.json:
googler --count ${numsites} --exact --noprompt 'intitle:”index of” nfe xml' --json > $@
sites.txt: search-results.json
< search-results.json jq ".[]|.url" | sed 's/"//g' > $@
invoices: sites.txt
import collections
import datetime
import hashlib
import random
import string
import sys
from contextlib import suppress
random.seed(0)
#!/usr/bin/env python
import json
import sys
def pprint_specfile(path, filters):
record_fmt = '{r[name]}: {r[label]}'
field_fmt = ' {f[order]}-{f[name]}'
import zipfile
from io import BytesIO
def zipwalk(current_file, curr_path=''):
"""Recursively walks into a zipped file tree while yielding non-zipped
files content.
"""
data = BytesIO(current_file.read())
@tilacog
tilacog / relate_database_objects.py
Created November 28, 2016 10:24
Creates a digraph showing relations between views and functions in a PostgreSQL database.
import psycopg2
from itertools import chain, permutations
from graphviz import Digraph
DB_SETTINGS = dict(
host='localhost',
database='database_name',
user='user',
password='*****',
import rows
from collections import Counter
base_svg = '/path/to/drawing.svg'
base_name = 'Fulano de Tal e Coisa'
participants_table = rows.import_from_csv('/path/to/pyse-participantes.csv')
with open(base_svg) as f:
svg = f.read()