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
| #!/usr/bin/env bash | |
| # | |
| # duckdb_boundary.sh — run DuckDB spatial queries by region | |
| # | |
| # Usage: | |
| # ./duckdb_boundary.sh --query "Sicilia" [--format PARQUET|CSV|JSON] | |
| # | |
| # Description: | |
| # - Ensures DuckDB 'spatial' extension is installed and loaded | |
| # - Reads OpenStreetMap boundary data (remote parquet) |
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
| COPY ( | |
| SELECT * | |
| FROM 'https://data.openstreetmap.us/layercake/boundaries.parquet' | |
| WHERE list_contains("tags"['name'], 'Sicilia') | |
| OR list_contains("tags"['names']['en'], 'Sicily') | |
| ) TO 'sicily_boundaries.parquet' (FORMAT 'PARQUET'); |
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
| osmium extract -b 12.2,36.5,15.8,38.8 italy.osm.pbf -o sicily.osm.pbf --overwrite; | |
| osmium tags-filter sicily.osm.pbf w/highway -o sicily_streets.osm.pbf --overwrite; | |
| ogr2ogr -f Parquet -oo PRELUDE_STATEMENTS="INSTALL spatial; LOAD spatial;" \ | |
| sicily_streets.parquet sicily_streets.osm.pbf lines; |
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
| { | |
| "version": 8, | |
| "sources": { | |
| "arcgisonline": { | |
| "type": "raster", | |
| "tiles": [ | |
| "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}" | |
| ], | |
| "tileSize": 256, | |
| "maxzoom": 18, |
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
| { | |
| "version": 8, | |
| "sources": { | |
| "osm": { | |
| "type": "raster", | |
| "tiles": ["https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"], | |
| "tileSize": 256, | |
| "attribution": "<a href=\"https://www.openstreetmap.org/copyright\">© OpenStreetMap Contributors</a>", | |
| "maxzoom": 19 | |
| }, |
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
| { | |
| "version": 8, | |
| "sources": { | |
| "hillshadeSource": { | |
| "type": "raster-dem", | |
| "tiles": ["https://tiles.mapterhorn.com/{z}/{x}/{y}.webp"], | |
| "encoding": "terrarium", | |
| "tileSize": 512, | |
| "attribution": "<a href=\"https://mapterhorn.com/attribution\">© Mapterhorn</a>" | |
| } |
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
| osmium tags-filter germany-latest.osm.pbf r/boundary=administrative -o temp_boundaries.osm.pbf --overwrite | |
| osmium tags-filter temp_boundaries.osm.pbf r/admin_level=4 -o bundeslaender.osm.pbf --overwrite | |
| time ogr2ogr -f Parquet bundeslaender.parquet bundeslaender.osm.pbf multipolygons |
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 mlx_lm import batch_generate, load | |
| model, tokenizer = load("mlx-community/gemma-3-270m-it-4bit") | |
| # load a pandas df here, df has a text column | |
| import pandas as pd | |
| df = pd.read_parquet("2000_benchmark_texts_BAAI.parquet") | |
| # Apply the chat template and encode to tokens | |
| prompts = [i + "--------\nSummarize this article in one sentence" for i in df.text.to_list()] | |
| prompts = [ |
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
| #!/bin/bash | |
| # Usage: clone_yek_copy <github_repo_url> | |
| # Description: Clones a GitHub repo, runs `yek | pbcopy`, then deletes the repo. | |
| set -e | |
| # --- 1️⃣ Check for URL argument --- | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <github_repo_url>" | |
| exit 1 |
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 argparse | |
| from mlx_lm import load, generate | |
| # Parse CLI arguments | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--prompt", type=str, default="hello", help="Custom prompt text") | |
| parser.add_argument("--max-tokens", type=int, default=1024, help="Maximum number of tokens to generate") | |
| args = parser.parse_args() | |
| # Load model |
NewerOlder