Skip to content

Instantly share code, notes, and snippets.

View todd-cook's full-sized avatar

Todd Cook todd-cook

  • Burlingame
View GitHub Profile
@todd-cook
todd-cook / wikidata.employers.sample.data.csv
Created January 6, 2022 07:59
Wikidata sample employers data
employer_item_id count text_data class_type context
2944031 9 Counter Terrorist Unit employer fictional branch of the CIA from the television series 24
214126 53 Los Angeles Police Department employer municipal police
37230 493 Central Intelligence Agency employer national intelligence agency of the United States
9531 1520 BBC employer British public service broadcaster
134995 57 bibliography employer
21198 842 computer science employer study of the theoretical foundations of information and computation
5962346 1 classification system employer organisation of objects into classes
482 1218 poetry employer form of literary art
@todd-cook
todd-cook / wikidata.occupations.sample.data.csv
Last active January 6, 2022 07:57
wikidata.occupations.sample.data.csv
occupation_item_id count text_data class_type context
82955 606008 politician occupation person involved in politics or person who holds or seeks positions in government
189290 33481 military officer occupation member of an armed force or uniformed service who holds a position of authority
131512 8887 farmer occupation person that works in agriculture
1734662 2012 cartographer occupation person preparing geographical maps
294126 323 land surveyor occupation profession
81096 34500 engineer occupation professional practitioner of engineering and its sub classes
372436 3790 statesperson occupation politician in high government offices
5446967 29 field agent occupation agent who works in the field as opposed to one who works at the office or headquarters
4991371 6642 soldier occupation one who serves as part of an organized armed force
@todd-cook
todd-cook / auto.label.results.top.csv
Created January 6, 2022 07:38
auto.label.results.top.csv
model lowest_confidence text_data class_type corrected_class_type
linear 1 deputy employer UNK
linear 2 chef UNK UNK
linear 3 VRP occupation UNK
polynomial 1 pen employer UNK
polynomial 2 mayor employer UNK
polynomial 3 art theft occupation UNK
radial basis 1 Academy of Finland UNK UNK
radial basis 2 Cultural Institutions Studies UNK UNK
radial basis 3 University of Helsinki UNK UNK
@todd-cook
todd-cook / testlog.py
Last active January 27, 2021 06:58
python logging dictionaries examples
import logging.config
import sys
def trylog(l):
for e in range(0, 50, 10):
l.log(e, 'level %s' % e)
if __name__ == '__main__':
@todd-cook
todd-cook / gist:feddb1d50baa0f2550520a1eeca62e5e
Created March 24, 2020 04:26
Graph Covid-19 cases in US, March
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
dates_infections = {'3/1': 89,
'3/2': 105,
'3/3': 125,
'3/4': 159,
'3/5': 227,
'3/6': 331,
'3/7': 444,
spondaic 'at si staret' ait 'caelebs sine palmite truncus,
spondaic Aeneae genetrix, vidit quoque triste parari
spondaic Has ubi verborum poenas mentisque profanae
spondaic Hunc ubi laudatos iactantem in sanguine vultus
spondaic Maenala transieram latebris horrenda ferarum
spondaic adiectoque cavae supplentur corpore rugae,
spondaic admotumque fretum remis tellusque repulsa est,
spondaic aversata gemit; certa est exquirere nutrix
spondaic bella instructa gerunt, multumque ab utraque cruoris
spondaic bellaque non transfert, et sunt, qui parcere Troiae
# Some notes on this gist:
# all abstract and base class stuff has been moved to the top of the file so that import resolution
# and IDEs won't complain unnecessarily.
# _get_model_path is default method
# tokenize has been promoted to be a default method, and signatures downstream were made consistent with this;
# -- whether this is a great idea is open to debate
# The default list argument, a subtle bug, has been corrected, e.g. see https://docs.python-guide.org/writing/gotchas/
# the self : object annotation has been removed as it is implied and it confuses IDE.
@todd-cook
todd-cook / gist:f1d7d3ecb62e0da079aaa1418ac49cfa
Created February 5, 2019 19:58
Display git branch in terminal title, bash functions
# Add to .bash_profile
function gittitle() {
echo -n -e "\033]0;`git status | awk 'NR==1 {print $3}'`\007"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
@todd-cook
todd-cook / gist:834364b2ff3b6fe92b13162862f24143
Created February 2, 2018 01:13
Rotate a block of text from a file
# rotate text in a file, such as banner text
# surprised this isn't a library function, for silly text operations
import sys
import re
def create_matrix(height):
matr = list()
for i in range(0, height):
matr.append(list())
@todd-cook
todd-cook / gist:32fdb6abdac3fcd0e59189ffc9188574
Created January 11, 2018 21:09
Python keywords and builtins - programmatically
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
>>> import builtins
>>> dir(builtins)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'Not