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
import re | |
import warnings | |
from typing import Pattern | |
def translate_url_pattern(pattern: str, # noqa: max-complexity: 20 | |
case_sensitive: bool = True, | |
) -> Pattern: | |
""" | |
translates a url pattern (like a glob pattern) to a regular expression |
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
import inspect | |
from functools import lru_cache | |
from functools import partial | |
from typing import Callable | |
@lru_cache(maxsize=None) | |
def get_function_name(func: Callable) -> str: | |
""" | |
Get the name of a function. |
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
import datetime | |
from functools import wraps | |
from threading import Condition | |
from threading import Lock | |
from typing import Callable | |
from typing import Union | |
def debounce(timeout: Union[int, float, datetime.timedelta], *, default: Any = None) -> Callable: | |
""" |
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
""" | |
malay-english dictionary words extracted from http://dictionary.bhanot.net/ | |
(extracted on 2020-11-10) | |
""" | |
definitions = { | |
'abad': 'century', | |
'berabad-abad': 'for centuries', |
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
import random | |
import re | |
import unicodedata | |
RE_ZALGO = re.compile(r'(?:.[\u0300-\u036F\u0488\u0489]+)+(?:(?:\s+|[^\w])(?:.[\u0300-\u036F\u0488\u0489]+)+)*') | |
def sad_face(text: str): | |
# return text.replace('', '\u0311\u0308')[2:] # substitute whitespace |
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
Option Explicit | |
'####################################################################################### | |
' Module code for capturing a screen image (Print Screen) and pasting to a new workbook | |
' Created on November 14th, 2009, compiled by Zack Barresse | |
' Compiled utilizing the following resources: | |
' http://www.ac6la.com/makegif.html | |
' http://www.andreavb.com/tip090001.html | |
'####################################################################################### | |
' Updated by Avery on 2020-06-23 to make the code work with 64-bit Excel |
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 star = []; | |
const star_x = []; | |
const star_y = []; | |
const star_remaining_ticks = []; | |
const tiny = []; | |
const tiny_x = []; | |
const tiny_y = []; | |
const tiny_remaining_ticks = []; | |
const sparkles = 250; // total number of stars, same as number of dots | |
const sparkle_lifetime = 30; // each star lives for twice this, then turns into a dot that also lives twice this |
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
{ | |
"basics": { | |
"name": "Avery Khoo", | |
"label": "Senior Data Scientist", | |
"picture": "", | |
"email": "averykhoo@gmail.com", | |
"phone": "", | |
"degree": "B.Eng in Computer Science", | |
"website": "", | |
"summary": "I'm a data scientist, but I've also worked on devops platforms and infra. ", |
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 functools import wraps | |
def verbose(func): | |
"""Decorator to print function call details - parameters names and effective values""" | |
@wraps(func) | |
def wrapper(*func_args, **func_kwargs): | |
print('func_code.co_varnames =', func.func_code.co_varnames) | |
print('func_code.co_argcount =', func.func_code.co_argcount) |
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://en.wikipedia.org/wiki/National_Registration_Identity_Card | |
# http://www.ngiam.net/NRIC/ | |
# http://www.ngiam.net/NRIC/NRIC_numbers.pdf | |
import random | |
weights = [2, 7, 6, 5, 4, 3, 2] | |
local_alphas = 'JZIHGFEDCBA' | |
foreign_alphas = 'XWUTRQPNMLK' |
NewerOlder