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 json, gzip | |
def load_json(file_path): | |
try: | |
with gzip.open(file_path, 'rt', encoding='utf-8') as f: | |
return json.load(f) | |
except OSError: #if the file is not gzipped | |
with open(file_path, 'r', encoding='utf-8') as f: | |
return json.load(f) |
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 pydeck as pdk | |
df = pd.read_json("https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/line/heathrow-flights.json") | |
INITIAL_VIEW_STATE = pdk.ViewState(latitude=47.65, longitude=7, zoom=4.5, max_zoom=16, pitch=50, bearing=0) | |
line_layer = pdk.Layer( | |
"LineLayer", | |
df, | |
get_source_position="start", |
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 pydeck as pdk | |
import pandas as pd | |
import numpy as np | |
### sample data | |
import duckdb | |
import geopandas | |
df = duckdb.sql(f"SELECT * FROM 'geonames_23_03_2025.parquet' WHERE \"1\" = 'London' \ | |
AND \"8\" = 'GB' ").df() | |
gdf = geopandas.GeoDataFrame( |
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
pmtiles extract https://build.protomaps.com/20250303.pmtiles OUTPUT.pmtiles --region=your_subset.geojson |
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
#!/bin/bash | |
# Set the input directory (where your PDFs are) | |
INPUT_DIR="." # Current directory, change if needed | |
# Set the output file name | |
OUTPUT_FILE="llm_ready.txt" | |
# Set the temporary directory | |
TEMP_DIR="temp_pdf_text" |
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
huggingface-cli login # logs in with a suitable HF token | |
huggingface-cli upload do-me/Eurovoc_English . files # all files must be in cwd |
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
find . -maxdepth 1 -type f -name "*.webp" 2>/dev/null | sort | awk '{print NR, $0}' | while read num old_name; do new_name=$(printf "%04d.webp" "$num"); mv "$old_name" "$new_name"; done |
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 pandas as pd | |
import json | |
import gzip | |
# Load data | |
df = pd.read_json("your_file.json.gz") | |
# Round embeddings to 4 decimal places | |
df["embeddings"] = df["embeddings"].apply(lambda emb: [round(e, 4) for e in emb]) |
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 requests | |
import xml.etree.ElementTree as ET | |
import geopandas as gpd | |
from io import StringIO | |
import pandas as pd | |
from shapely import wkt | |
import os | |
def get_feature_types(wfs_url): | |
"""Extracts feature type names from a WFS GetCapabilities response.""" |
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 time | |
import duckdb | |
def run_duckdb_query(): | |
# Connect to DuckDB (using an in-memory database as an example) | |
conn = duckdb.connect(database=':memory:') | |
# Load the spatial extension | |
conn.execute("LOAD spatial") |
NewerOlder