This file contains hidden or 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
""" | |
Finds maximal repetitions (T^N, N>=2) in strings using Divide and Conquer. | |
This module implements algorithms to identify blocks of repeating substrings within | |
a given text. The primary approach involves two main stages: | |
1. **Finding Squares (TT):** It uses an O(N log N) Divide and Conquer | |
algorithm coupled with the Z-function to find all occurrences of "squares" – | |
substrings of the form TT (a pattern T repeated twice). This specific | |
algorithm is commonly found in competitive programming resources (e.g., |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
// ───────────────────────────────────────────────────────────────────────────── | |
// sparkles.js | |
// A self-contained sparkle/dot effect that you can turn on/off by calling | |
// sparkle(true) or sparkle(false) or sparkle() to toggle. | |
// No external CSS or other files needed. | |
// ───────────────────────────────────────────────────────────────────────────── | |
(function () { | |
// ─────────────────────────────────────────────────────────────────────────── | |
// CONFIGURATION CONSTANTS |
This file contains hidden or 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 hidden or 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) |
NewerOlder