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
# A quick way to record a new time entry using the official Harvest CLI package. | |
# Usage: `hours duration [alias]` | |
# Create a new alias for a project/task mapping with `hrvst alias create` if needed. | |
function hours -d "Record new entry to Harvest" -a hours -a alias | |
__hrvst_auth | |
if test (count $argv) -eq 0 | |
__total_hours | |
return 0 | |
end |
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
# USAGE | |
# | |
# 1. Install Taskfile from <https://taskfile.dev> | |
# 2. Save this file to $HOME/Taskfile.yml | |
# 3. Run `task -g <name of the task>` | |
version: '3' | |
vars: | |
EDITOR: nvim # Set this to your preferred text editor |
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
export enum Suit { | |
Club, | |
Diamond, | |
Spade, | |
Heart, | |
} | |
export enum Rank { | |
Two = 2, | |
Three, |
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 separator = "."; | |
const updateRecursively = <T extends Record<string, any>>( | |
data: T, | |
keys: string[], | |
value: unknown | |
): T => { | |
const [key] = keys; | |
if (keys.length === 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
import * as fs from "node:fs/promises"; | |
type Disk = Map<string, string>; | |
interface FileSystemAdapter { | |
readFile(path: string): Promise<string>; | |
writeFile(path: string, content: string): Promise<void>; | |
deleteFile(path: string): Promise<void>; | |
} |
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 PathScanner: | |
input_paths: list[str] | |
allowed_extensions: tuple[str] | |
def __init__(self, input_paths: list[str], allowed_extensions: tuple[str]) -> None: | |
self.input_paths = input_paths | |
self.allowed_extensions = allowed_extensions | |
def fetch_paths(self) -> list[str]: | |
result: list[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
#!/usr/bin/env python3 | |
""" | |
Quick script to update all the existing Poetry packages by traversing pyproject.toml file. | |
Requires external package `tomli` to parse TOML file. | |
""" | |
import sys | |
from pathlib import Path | |
from shlex import split | |
from subprocess import CompletedProcess, run | |
from typing import Any |
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
# Example: `it -v`, then press <ENTER> to pick a single task, or <TAB> to select multiple tasks and then <ENTER> | |
function it -d 'Run Taskfile tasks interactively' | |
task $argv (\ | |
task --list \ | |
| cut -d ' ' -f2 \ | |
| tail -n +2 \ | |
| sed 's/://' \ | |
| sort \ | |
| fzf -m --reverse --preview 'task --summary {}' \ |
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 json import JSONEncoder, dumps | |
from typing import Any | |
import numpy as np | |
class NumpyEncoder(JSONEncoder): | |
def default(self, obj: object) -> Any: | |
if isinstance(obj, np.integer): | |
return int(obj) | |
if isinstance(obj, np.floating): |
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 1: true or false to indicate success | |
function createUser(id: string): boolean { | |
const user = User.getById(id); | |
if (!user) { | |
User.create(id); | |
return true; | |
} | |
return false; |
NewerOlder