Skip to content

Instantly share code, notes, and snippets.

View blacksmithop's full-sized avatar
😃
Trying things differently

Abhinav blacksmithop

😃
Trying things differently
View GitHub Profile
@blacksmithop
blacksmithop / Search my gists.md
Created June 13, 2022 12:30 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@blacksmithop
blacksmithop / switch_case_list_elements.py
Created June 21, 2022 06:15
python 3.10 switch case example list elements
# Python 3.10 switch case example for a list
def file_handler_v1(command):
match command.split():
case ["show"]:
print("List all files and directories: ")
# code to list files
case ["remove", *files]:
print("Removing files: {}".format(files))
# code to remove files
case _:
@blacksmithop
blacksmithop / readme.md
Last active July 6, 2022 09:00
ISPOR API

ISPOR

API

URL

https://isporsearch302.aws.mtxgp.net//searchblox/servlet/SearchServlet?query=*&default=AND&xsl=json&facet=on&col=2&pagesize=10&f.events.filter=2019-11%2C%20ISPOR%20Europe%202019%2C%20Copenhagen%2C%20Denmark&page=1&sort=relevance&facet.field=citable&f.citable.size=1000&facet.field=categories&f.categories.size=1000&facet.field=areaofstudy&f.areaofstudy.size=1000&facet.field=disease&f.disease.size=1000&facet.field=events&f.events.size=1000

@blacksmithop
blacksmithop / closest_key_in_dict.py
Created July 19, 2022 08:43
Get key with closest match* when accessing a dict item by key, otherwise return the 'first' key
class mdict(dict):
def __missing__(self, key):
keys = list(self.keys())
return next(in_key for in_key in keys if key in in_key) or keys[0]
if __name__ == "__main__":
item = mdict()
item["abc"] = 123
@blacksmithop
blacksmithop / drop_duplicate_if_null.py
Last active August 3, 2022 09:08
Drop duplicate row if column is null
>>> df1
name flag
0 1 1
1 2 1
2 3 1
3 4 1
>>> df2
name flag
0 3 NaN
1 4 NaN
@blacksmithop
blacksmithop / ouroboros.py
Created August 10, 2022 11:54
Infinite iterator
from itertools import chain
def gen_iterables():
while True:
for i in range(1, 6): # memory equivalent to that used by `range` is consumed at any moment
yield range(i)
gen = chain.from_iterable(gen_iterables())
for i in range(20):
@blacksmithop
blacksmithop / iterate-walrus.py
Created August 10, 2022 12:03
Iteration using walrus operator
items = list(range(1,11))
i_items = iter(items)
while el := next(i_items):
print(el)
@blacksmithop
blacksmithop / requirements.txt
Created November 21, 2022 10:56
Basic requirements of (almost) every Data Science project
pandas
openpyxl
spacy
@blacksmithop
blacksmithop / custom-ner-model-training.ipynb
Last active March 1, 2023 11:53
custom-ner-model-training.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blacksmithop
blacksmithop / Readme.md
Created March 6, 2023 09:30
Text to Speech demo (with pyttsx3 & streanlit)

image