Skip to content

Instantly share code, notes, and snippets.

View nickolasclarke's full-sized avatar

Nick Clarke nickolasclarke

View GitHub Profile
@nickolasclarke
nickolasclarke / uv.md
Created October 1, 2025 20:21
UV gists

VSCode Python debugger with UV

This is useful for debugging CLIs, scripts with in-line requirements, or other tools that are easier to invoke via UV.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug with uv",
            "type": "debugpy",
            "request": "launch",

Example config.json

{
  "credentials": {
    "project_id": 123,
    "secret": "my_secret",
    "username": "my_service_account"
  },
  "start_date": "2025-06-30T21:00:00Z",
  "region": "US" #aside: this appears to be required, despite what https://docs.airbyte.com/integrations/sources/mixpanel suggests
@nickolasclarke
nickolasclarke / install_wechat_for_x11_forwarding.md
Last active June 27, 2025 23:50
Install Wechat / Weixin for Linux on Arm64 Debian VM on MacOS

If you too would like to run the new Weixin for Linux on a lightweight Arm64 Debian Linux VM such as those afforded you by Orbstack follow below.

  1. Install XQuartz
  2. Install Orbstack
  3. Follow this rough guide to getting an X11 forwarding working on an orbstack-provided VM
  4. Grab the link for the appropriate package bundle for WeiXin for Linux
  5. SSH into your VM with (-X or -Y passed for automatic X11 forwarding)
  6. wget <insert_link_to_weixin_for_linux.your_package_extension>
  7. Now install all the missing packages needed. I had to run sudo apt install fonts-noto-cjk libxkbcommon-x11-0 libxcb-icccm4 libxcb-image libxcb-image0 libxcb-shape0 libxcb-render-util libxcb-render-util0 libxcb-keysyms1 libtiff6 libnss3
  8. If you are using Debian, as I was, run sudo dpkg -i ./<name_of_weixin_for_linux_file_you_just_downloaded>.db
@nickolasclarke
nickolasclarke / string_counts.py
Created October 11, 2024 00:30
get_string_counts
from pathlib import Path
import polars as pl
# get all the definions names from the files
mode_defs = [
f.split(".")[0]
for _, _, files in Path(
"/Users/nclarke/repos/wg/wg-mode/Mode/weavegrid/definitions"
).walk()
for f in files
@nickolasclarke
nickolasclarke / enable_dbt_models.py
Created July 31, 2024 19:13
Modfies specified dbt models in place to enable them.
#!/bin/bash
# Check if at least one filename is provided
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <file1> <file2> ... <fileN>"
exit 1
fi
# Loop through each file provided as an argument
for file in "$@"; do
@nickolasclarke
nickolasclarke / find_string_in_files.py
Created June 24, 2024 20:39
find a target string in compressed files
import gzip
import os
import sys
from concurrent.futures import ThreadPoolExecutor
# for each gz file in the directory, find the the target string in the file
# return the file name and the line number of the target string
**Describe the bug**
A clear and concise description of what the bug is.
I am attempting to decrypt file that appears to successfully decrypt with legible data in `decrypted.data`, but still results in `decrypted.ok == false`, `decrypted.status == '` and `decrypted.returncode == 0`.
I am decrypting a file that is being read from a temporary file with:
```python
def decrypt(encrypted_data, keypair, passphrase=None):
{
"objectIdFieldName": "OBJECTID",
"uniqueIdField": {
"name": "OBJECTID",
"isSystemMaintained": true
},
"globalIdFieldName": "",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 102100,
@nickolasclarke
nickolasclarke / scrape_powerplants.py
Last active June 14, 2022 18:48
Extract Power Plant Data
import requests
import pandas as pd
from bs4 import BeautifulSoup
BASE_URL = 'https://www.usbr.gov/projects/index.php?id='
def scrape_power_plant(id: int) -> dict:
"""
Returns power plant information from "Main-well" div as a dict
@nickolasclarke
nickolasclarke / sql_snippets.md
Last active March 23, 2022 18:56
SQL snippets

SQL Snippets

  • Return all rows with >1 of the same value (i.e. users with >1 phone number in this case)
    SELECT user_id, phone_number
    FROM phone_numbers 
    WHERE user_id IN (
      SELECT user_id FROM phone_numbers GROUP BY user_id HAVING count(*) >1
      )