Skip to content

Instantly share code, notes, and snippets.

View JakeCowton's full-sized avatar

Jake Cowton JakeCowton

View GitHub Profile
@JakeCowton
JakeCowton / find_dict_containing.py
Created November 12, 2021 11:35
Finding the dict, within a many nested JSON objects, containing a given key, value, or key-value pair
def find_dict_containing_key(d, key):
"""
:param d: dict
:param key: the key to look for
:returns: the nested dict containing key
"""
if isinstance(d, list):
for i in d:
if isinstance(i, dict) or isinstance(i, list):
item = find_dict_containing_key(i, key)
@JakeCowton
JakeCowton / is_sublist.py
Last active April 29, 2021 11:35
Determine if a given list is a sublist of another
def is_sublist(a: list, b: list):
return any(
[v == a[0] and b[i:i + len(a)] == a for i, v in enumerate(b)]
)

Keybase proof

I hereby claim:

  • I am jakecowton on github.
  • I am jakecowton (https://keybase.io/jakecowton) on keybase.
  • I have a public key ASDSrQnAhj_6k_EwHwZ6KjwjuU09WZTY5Euy2nDe7yoCZQo

To claim this, I am signing this object:

@JakeCowton
JakeCowton / supervisely_to_voc.py
Created November 12, 2019 18:38
Convert supervisely annotations to Pascal VOC
# git clone git@github.com:supervisely/supervisely.git
# cd supervisely
# pip install -e .
# cd supervisely_lib
from export.pascal_voc import save_project_as_pascal_voc_detection
from project.project import OpenMode, Project
save_project_as_pascal_voc_detection("/path/to/empty/output/folder",
Project("/path/to/root/of/downloaded/supervisely/folder",