Skip to content

Instantly share code, notes, and snippets.

View wesnel's full-sized avatar
:shipit:

Wesley Nelson wesnel

:shipit:
View GitHub Profile
@wesnel
wesnel / open_input.py
Created February 23, 2022 00:27
single python context manager for reading from either `stdin` or a file
# standard library
from contextlib import contextmanager
from pathlib import Path
from sys import stdin
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Optional
@wesnel
wesnel / configure_logging.py
Created February 22, 2022 23:54
basic python logging setup
# standard library
from sys import stderr
import logging
LOGGER = logging.getLogger(__name__)
FMT = (
"%(asctime)s - "
"%(levelname)s - "
"%(filename)s/%(funcName)s:%(lineno)d -> "
"%(message)s"
@wesnel
wesnel / open_output.py
Created February 22, 2022 19:32
single python context manager for writing to either `stdout` or a file
# standard library
from contextlib import contextmanager
from pathlib import Path
from sys import stdout
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Optional
@wesnel
wesnel / snowflake_paginated_query.py
Created February 16, 2022 23:22
paginated bulk download of a snowflake query
#!/usr/bin/env python3
"""Script for downloading the results of a snowflake query.
Use the -h flag to see the command line arguments.
"""
# standard library
from contextlib import contextmanager
from os import getenv
from pathlib import Path
@wesnel
wesnel / scalyr_paginated_query.py
Last active May 5, 2023 20:23
paginated bulk download of log messages from scalyr queries
#!/usr/bin/env python3
"""Script for bulk downloading log lines from a scalyr query.
Use the -h flag to see the command line arguments.
The script has dependencies which will need to be installed into your
python environment:
- https://github.com/Delgan/loguru#installation
- https://docs.python-requests.org/en/latest/user/install/#install
// Wesley Nelson
// wnelson@uab.edu
// CS332 Lab 1
// 2020-09-02
// compile with `gcc -o is_prime is_prime.c`
// to run tests, compile with `gcc -DTEST -o is_prime_test is_prime.c`
#include <stdbool.h> // for the bool type
#include <stdio.h> // for i/o
@wesnel
wesnel / memories.py
Created May 21, 2020 02:14
Download all Snapchat memories from your account data JSON (https://support.snapchat.com/en-US/a/download-my-data).
import asyncio
from json import loads
from pathlib import Path
MEMORIES_HISTORY_PATH = "./json/memories_history.json"
async def download_memory(memory: dict) -> None:
filetype = "mp4" if memory["Media Type"] == "VIDEO" else "jpg"
filename = f"{'_'.join(memory['Date'].split())}.{filetype}"
cmd = (

Getting Geo Test Data

In order to test possible implementations of a database for storing geospatial data, it’s helpful to have a large amount of data on hand. A good source is GDELT.

Let’s write a quick script to gather some location data from GDELT.

Their CSV is compressed and contains way more information than we need,

(ns euclid.core)
(defn gcd
"Compute the GCD using Euclid's algorithm."
[a b]
(if (= b 0)
a
(gcd b (rem a b))))