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
| $semiColon = ';' | |
| $pathArray = $env:PATH -split $semiColon | |
| $uniquePathArray = $pathArray | Select-Object -Unique | |
| $newPath = ($uniquePathArray -join $semiColon) | |
| [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::User) | |
| # Verify changes using $env:PATH -split $semiColon | ForEach-Object { $_ } |
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
| def baz( | |
| a: int, | |
| b: int, | |
| /, | |
| c: int | None = None, | |
| *args: int, | |
| d: int | None = None, | |
| **kwargs: int, | |
| ) -> None: | |
| print("--------------------") |
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
| def pretty_repr_types[ | |
| K, V: dict | list | str | int # type: ignore - dict and list expect type arguments (pyright) | |
| ](obj: dict[K, V] | list[V] | str | int, indent: int = 0) -> str: | |
| """Recursively prints the types of keys and values in a dictionary.""" | |
| spacing: str = " " * indent | |
| if isinstance(obj, dict) and not isinstance(obj, str): | |
| result = "{\n" | |
| for key, value in obj.items(): | |
| key_type: str = repr(type(key)) |
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 collections.abc | |
| from types import SimpleNamespace | |
| class CustomABCMeta(type): | |
| _abc_cache = set() | |
| _abc_negative_cache = set() | |
| _abc_negative_cache_version = 0 | |
| _abc_invalidation_counter = 0 |
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 collections import defaultdict | |
| from typing import Any, Dict, List, Self, Tuple | |
| import polars as pl | |
| from fuzzywuzzy import fuzz, process | |
| class NameClusterer: | |
| def __init__(self, df: pl.DataFrame, column: str, threshold: int) -> None: | |
| self.df: pl.DataFrame = df |
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 typing import Callable, Generic, ParamSpec, Protocol, TypeVar, overload | |
| _PD = ParamSpec('_PD') | |
| _PF = ParamSpec('_PF') | |
| _RD = TypeVar('_RD') | |
| _RF = TypeVar('_RF') | |
| # from functools import _Wrapped as _W | |
| class _W(Generic[_PF, _RF, _PD, _RD]): | |
| ... |
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 sys | |
| from typing import TypeVar | |
| __all__: list[str] = [ | |
| "Any", | |
| "cast", | |
| "reveal_type", | |
| ] |
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
| def gradient_text(text: str, start_color: str, end_color: str) -> Text: | |
| gradient = Text() | |
| start: ColorTriplet | None = Color.parse(start_color).triplet | |
| end: ColorTriplet | None = Color.parse(end_color).triplet | |
| for i, char in enumerate(text): | |
| ratio: float = i / (len(text) - 1) | |
| blended_color = tuple( | |
| int(start[j] + (end[j] - start[j]) * ratio) for j in range(3) | |
| ) | |
| color_code: str = f"#{''.join(f'{value:02x}' for value in blended_color)}" |
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
| Set-Clipboard -Value ("`"" + (Get-Location).Path + "`"") | |
| # "C:\Windows" |
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
| function Test-Fnm { | |
| if (-not (Get-Command fnm -ErrorAction SilentlyContinue)) { | |
| $flagFile = "$env:TEMP\fnm_installing.flag" | |
| if (-not (Test-Path $flagFile)) { | |
| New-Item -Path $flagFile -ItemType File | Out-Null | |
| try { | |
| Start-Process powershell -ArgumentList "-NoProfile -Command `"winget install Schniz.fnm; Remove-Item -Path $flagFile`"" -WindowStyle Hidden | |
| $maxRetries = 12 # wait up to 60 seconds (12 * 5) | |
| $retry = 0 | |
| while (-not (Get-Command fnm -ErrorAction SilentlyContinue) -and $retry -lt $maxRetries) { |