This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aryIannaTimeZones = [ | |
'Europe/Andorra', | |
'Asia/Dubai', | |
'Asia/Kabul', | |
'Europe/Tirane', | |
'Asia/Yerevan', | |
'Antarctica/Casey', | |
'Antarctica/Davis', | |
'Antarctica/DumontDUrville', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068 | |
'Antarctica/Mawson', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Controls the font size in pixels. | |
"editor.fontSize": 12, | |
// Controls auto save of dirty files. Accepted values: 'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'. | |
"files.autoSave": "off", | |
// Controls the font family. | |
"editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
data = [{ | |
'base': 'a', | |
'data':1, | |
},{ | |
'base': 'a', | |
'data':2, | |
},{ | |
'base': 'a', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def json_default(o): | |
if isinstance(o, (date, datetime)): | |
return o.isoformat() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def slice_dict_keys(d: dict, start: str, end: str): | |
lk = list(d.keys()) | |
lv = list(d.values()) | |
try: | |
start_ll = lk.index(start) | |
end_ll = lk.index(end) | |
except ValueError: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DayQuarter: | |
def __init__(self, date_class: date, months = 3): | |
self.date_class = date_class | |
self.months = months | |
def quarter(self) -> int: | |
return (self.date_class.month - 1) // self.months + 1 | |
def first(self): | |
return datetime(self.date_class.year, self.months * ((self.date_class.month - 1) // self.months) + 1, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Table mapping response codes to messages; entries have the | |
# form {code: (shortmessage, longmessage)}. | |
HTTP_response_codes = { | |
100: ('Continue', 'Request received, please continue'), | |
101: ('Switching Protocols', | |
'Switching to new protocol; obey Upgrade header'), | |
200: ('OK', 'Request fulfilled, document follows'), | |
201: ('Created', 'Document created, URL follows'), | |
202: ('Accepted', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
with rapidjson or json lib | |
""" | |
import rapidjson, zlib | |
from diskcache import core, Disk | |
from datetime import date, datetime | |
from typing import Any | |
def json_default(o): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Get a number with type int from a float as like 1.0 | |
""" | |
def float_is_int(value: float | str | int) -> float | int: | |
if isinstance(value, str): | |
try: | |
value = float(value) | |
except ValueError: | |
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
https://stackoverflow.com/a/59956828/3360295 | |
""" | |
fdict = { | |
'apple': {'green': 5, 'red': 0}, | |
'banana': {'light_yellow': 10, 'dark_yellow': 0}, | |
'appraisal round': 1 | |
} |