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
Set-Clipboard -Value ("`"" + (Get-Location).Path + "`"") | |
# "C:\Windows" |
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
function Ensure-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) { |
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 sys | |
from functools import wraps | |
from typing import Any, Callable, Optional, TypeVar | |
F = TypeVar("F", bound=Callable[..., Any]) | |
def log_variables(func: F) -> F: | |
@wraps(func) | |
def wrapper(*args: Any, **kwargs: Any) -> Any: | |
def tracer(frame, event, arg) -> Optional[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
from functools import wraps | |
from typing import Any, Callable, TypeVar | |
F = TypeVar("F", bound=Callable[..., Any]) | |
def log_variables(func: F) -> F: | |
@wraps(func) | |
def wrapper(*args, **kwargs) -> Any: | |
if not hasattr(wrapper, "initialized"): |
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 __future__ import annotations | |
from typing import ClassVar, Type, TypedDict, Unpack, cast | |
from pydantic import BaseModel, Field, create_model, model_validator | |
class ColorData(TypedDict): | |
black: str | |
red: str |
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
Public Function Similarity(ByVal String1 As String, _ | |
ByVal String2 As String, _ | |
Optional ByRef RetMatch As String, _ | |
Optional min_match = 1) As Single | |
Dim b1() As Byte, b2() As Byte | |
Dim lngLen1 As Long, lngLen2 As Long | |
Dim lngResult As Long | |
If UCase(String1) = UCase(String2) Then |
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 typing import Optional, TypeGuard | |
import pandas as pd | |
from pandas import DataFrame | |
class DataFrameStore: | |
""" | |
A class to store and manage a DataFrame, with the ability to save and load it to | |
and from a file in Feather format. |
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 | |
from dataclasses import dataclass | |
from string import ascii_lowercase | |
from typing import override | |
@dataclass | |
class Question: | |
prompt: str | |
answer: str |
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 ast | |
import astor # `pip install astor` | |
from black import FileMode, format_str # `pip install black` | |
class DocstringRemover(ast.NodeTransformer): | |
def visit(self, node: ast.AST) -> ast.AST: | |
if isinstance(node, (ast.FunctionDef, ast.ClassDef, ast.Module)): | |
if ( |
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 collections | |
import itertools | |
from collections import abc | |
from typing import Any, Dict, Iterable, Iterator, Optional, Tuple | |
_sentinel = object() | |
def _merge_in( | |
target: Dict[Any, Any], |
NewerOlder