Skip to content

Instantly share code, notes, and snippets.

@Mr0grog
Mr0grog / urls.epa-climate-change.txt
Last active September 28, 2021 00:43
Crawl of all URLs under `epa.gov/climate*change*/`
http://www3.epa.gov/climatechange/Downloads/Region1-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region10-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region2-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region3-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region4-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region5-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region6-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region7-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region8-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region9-climate-change-adaptation-plan.pdf
@Mr0grog
Mr0grog / CODE_OF_CONDUCT.md
Last active June 25, 2021 18:57
Contributor Covenant Diff

(Version 2.0, hard-wrapping removed)

Contributor Covenant Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

@Mr0grog
Mr0grog / test-async-hooks.js
Created May 20, 2021 16:21
Test out scenarios with Node.js async hooks
/**
* Test how async hooks works in various scenarios.
*
* Call `hook.enable()` to start tracking async resources and `hook.disable()`
* to stop or pause tracking. Then use `logAndResetHooks()` to print a log of
* all the creation and destruction of async hooks.
*/
const asyncHooks = require("async_hooks");
const http = require("http");
@Mr0grog
Mr0grog / _example_usage.sh
Last active April 15, 2021 16:55
ArcGIS GeoJSON Downloader
# This script requires `requests`, so install it if you don't already have it.
pip install requests
# See a description of all options
python arcgis-download.py --help
# Download COVID-19 case demographics from Napa County, CA
python arcgis-download.py https://services1.arcgis.com/Ko5rxt00spOfjMqj CaseDataDemographics --sr 4326
@Mr0grog
Mr0grog / abort_experiment.py
Created February 19, 2021 08:02
Aborting HTTP requests in python-requests or python urllib3
"""
This is an experiment in aborting requests when using Python's `requests`
or `urllib3` packages.
My primary use case is a long running script that makes a lot of requests, but
needs to be gracefully cancelable (I use threads and signals to handle SIGINT
and SIGTERM, which is not shown here). When the first signal is sent, the
script should finish any in-progress work and gracefully shut down/clean up.
If there are HTTP requests in flight that are stuck for a long time (e.g.
many minutes), they should be aborted so the rest of the cleanup logic has a
@Mr0grog
Mr0grog / example.py
Created January 7, 2021 17:45
Reading Qlik Public Dashboards with Python
#######
# EXAMPLE OF USING THE QLIK CLIENT
#
# Reading some data from Contra Costa’s COVID-19 dashboard.
#######
from datetime import date, timedelta
from qlik import QlikClient
# First, create the client and open a connection.
@Mr0grog
Mr0grog / summarize.py
Last active January 26, 2023 18:45
Summarize log files from EDGI Wayback imports
from datetime import timedelta
import dateutil.parser
from pathlib import Path
import re
START_LINE = re.compile(r'^\[([^\]]+)\] Starting Internet Archive Import')
END_LINE = re.compile(r'^\s*Internet Archive import completed at (.+)')
SUMMARY_START = re.compile(r'^\s*Loaded (\d+) CDX records:')
SUMMARY_ITEM = re.compile(r'^\s*(\d+)\s([\s\w\-]+)\s\(')
IMPORT_ERRORS = re.compile(r'^\s*Total:\s*(\d+)\serrors')
@Mr0grog
Mr0grog / edgi-non-gov-mil-us-seeds-broad.csv
Last active October 15, 2020 20:47
EDGI 2020 EoT seeds from non- .gov/.mil/.us hosts
url
http://mdl-mom5.herokuapp.com/
https://www.instagram.com/cleanetwork/
https://sercc.com/
https://serc.carleton.edu/
https://cires.colorado.edu/
http://geomag.colorado.edu/
https://lasp.colorado.edu/
http://www.cloudsat.cira.colostate.edu/
http://rammb.cira.colostate.edu/
@Mr0grog
Mr0grog / .env
Created April 13, 2020 05:52
List pages that are errors from web-monitoring-db
export WEB_MONITORING_DB_URL='https://api.monitoring.envirodatagov.org'
export WEB_MONITORING_DB_EMAIL='YOUR EMAIL HERE'
export WEB_MONITORING_DB_PASSWORD='YOUR PASSWORD HERE'
@Mr0grog
Mr0grog / stdout_stderr_combined.py
Created January 25, 2020 07:39
Experiments in capturing combined output streams from subprocesses in Python.
# Experiments in capturing combined output streams from subprocesses.
#
# It turns out it's kind of hard to get the interleaved results of stdout and
# stderr in Python. However, in a lot of situations where Python is calling
# out to other processes, you probably want to swallow the child process's
# stderr when things to right and print it when things go wrong. Since some
# programs may be outputting results on stdout and warnings and errors on
# stderr, it makes sense that you'd want it all, and all in the order it was
# printed when things go wrong.
#