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
DROP TABLE ParentOf; | |
DROP TABLE Issues; | |
DROP TABLE Company; | |
DROP TABLE Bond; | |
CREATE NODE TABLE Company(cid SERIAL, name STRING, PRIMARY KEY(cid)); | |
CREATE (a:Company {name: "CompanyA"}); | |
CREATE (a:Company {name: "CompanyB"}); | |
CREATE (a:Company {name: "CompanyC"}); |
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
ollama: | |
image: "ollama/ollama:0.6.0" | |
restart: unless-stopped | |
environment: | |
- OLLAMA_HOST=0.0.0.0:11434 | |
- OLLAMA_MODELS=/data/models | |
- OLLAMA_FLASH_ATTENTION=1 | |
- OLLAMA_KV_CACHE_TYPE=q8_0 | |
- OLLAMA_CONTEXT_LENGTH=8192 | |
networks: |
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 polars as pl | |
import kuzu | |
import shutil | |
shutil.rmtree("test_db", ignore_errors=True) | |
db = kuzu.Database("test_db") | |
conn = kuzu.Connection(db) | |
# Get a JSON object of persons and products purchased | |
data = [ |
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
""" | |
Generate a fake dataset (csv or parquet) of persons | |
Two columns: name (str) and age (int) | |
Ensure the faker library and polars are installed: | |
pip install faker polars | |
Usage: | |
python gen_data.py -n 1000000 -f csv | |
python gen_data.py -n 1000000 -f parquet |
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
# Git branch in prompt | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ " |
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
sudo chmod 666 /var/run/docker.sock |
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
# Create a logger with rotating file handler and formatting per loguru | |
def get_logger(filename: str): | |
import sys | |
from loguru import logger | |
from pathlib import Path | |
Path("logs").mkdir(parents=True, exist_ok=True) | |
logger.remove() # Remove base logger settings and overwrite with custom settings | |
fmt = "{time:HH:mm:ss:SSS} -- {level} -- {message}" | |
# Add rotating file handler with desired level of logging | |
filename = f"{filename}.log" if not filename.endswith(".log") else filename |
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
# change normal keystroke timing on mac to make typing feel more responsive | |
# normal minimum is 15 (225 ms) | |
defaults write -g InitialKeyRepeat -int 13 | |
# normal minimum is 2 (30 ms) | |
defaults write -g KeyRepeat -int 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 logging | |
import sys | |
from logging.handlers import TimedRotatingFileHandler | |
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") | |
LOG_FILE = "my_app.log" | |
def get_console_handler(): | |
console_handler = logging.StreamHandler(sys.stdout) | |
console_handler.setFormatter(FORMATTER) |
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
""" | |
HackerNews module. | |
""" | |
import logging | |
import asyncio | |
from operator import itemgetter | |
import httpx |
NewerOlder