Skip to content

Instantly share code, notes, and snippets.

@afiodorov
afiodorov / 17.py
Last active December 17, 2023 14:26
advent of code 2023 day 17 a* algo
import pandas as pd
from queue import PriorityQueue
from dataclasses import dataclass
from functools import cache
grid = pd.read_csv("./data/17.txt", names=[0], dtype='str').apply(lambda x: pd.Series(list(x[0])), axis=1).astype(int)
directions = [(0, 1), (1, 0), (-1, 0), (0, -1)]
@dataclass(frozen=True, order=True)
class NodeState:
@afiodorov
afiodorov / lambda.py
Last active December 25, 2023 08:32
telegram_bot_aws_lambda
import os
import json
import logging
from urllib import request
from datetime import datetime, timezone
from dataclasses import dataclass
import boto3
from boto3.dynamodb.conditions import Key
@afiodorov
afiodorov / main.py
Created April 5, 2024 14:15
jq_filters
#!/usr/bin/env python3
import argparse
import json
import sys
def jq_filters(d, path=None, text_limit=None):
"""
Returns all jq filters for the json.
"""
@afiodorov
afiodorov / .zshrc
Last active May 1, 2024 20:37
.zshrc snippets
function find_and_activate_venv() {
current_dir=$PWD
while [ "$current_dir" != "/" ]; do
if [ -d "$current_dir/.venv" ]; then
source "$current_dir/.venv/bin/activate"
return
fi
current_dir=$(dirname "$current_dir")
done