Skip to content

Instantly share code, notes, and snippets.

@nhoffman
nhoffman / qr_code.py
Created September 11, 2024 18:33
Create a QR Code
#!/usr/bin/env python3
"""Create a QR Code
"""
import os
import sys
import argparse
@nhoffman
nhoffman / setup.py
Created April 15, 2023 17:52
setup.py pattern for creating multiple entry points
from setuptools import setup, find_packages
from pathlib import Path
with open("README.md", "r") as readme:
long_description = readme.read()
scripts_dir = Path(__file__).parent / 'openaiwrappers' / 'scripts'
scripts = [fn.stem for fn in scripts_dir.iterdir()
if not fn.stem.startswith('__')]
@nhoffman
nhoffman / sql2csv.py
Created December 23, 2022 06:27
Export MS SQL queries to csv
#!/usr/bin/env python3
"""Reformat sqlcmd output to csv
- writes output of the sql query to a temporary file
- saves query as unicode and converts utf-16 to utf-8
- replaces "NULL" with empty cells
"""
import os
@nhoffman
nhoffman / scrape_urls.py
Created December 13, 2021 21:04
scrape urls from an html file
#!/usr/bin/env python3
"""Scrape all urls from an html document
"""
import os
import sys
import argparse
@nhoffman
nhoffman / git_stats.py
Created May 31, 2021 03:50
visualize author contributions to one or more git repos
#!/usr/bin/env python3
"""Describe author contributions for one or more git repositories by date
Output is a csv with columns (repo, author, timestamp, churn) where
'churn' is the sum of lines added and lines removed.
Requires pandas and plotnine
"""
@nhoffman
nhoffman / medialab_cap_topics.user.js
Last active May 31, 2022 20:55
userscript for medialab inspection proof
// ==UserScript==
// @name medialab_cap_topics
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Add a menu to MediaLab inspection proof to filter CAP checklist items
// @author Noah Hoffman
// @match https://www.medialab.com/lms/admin/ad_ic_viewchecklist.aspx?*
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
@nhoffman
nhoffman / cwlog.py
Created October 7, 2019 03:41
Show cloudwatch log events
#!/usr/bin/env python3
"""Show cloudwatch log events.
Examples:
Show log stream containing the most recent event for a log group:
cwlog.py -g /aws/lambda/lambda-labreport
@nhoffman
nhoffman / get_classifications.py
Created August 29, 2019 17:03
Reformat of output/per_pquery_assign (output of 'gappa assign')
#!/usr/bin/env python3
"""Reformat of output/per_pquery_assign (output of 'gappa assign')
see https://github.com/lczech/gappa/wiki/Subcommand:-assign
Use "afract" for filtering, based on two criteria.
1. keep lineages with afract => min-afract
2. keep ranks with a cumulative value of afract >= min-total
@nhoffman
nhoffman / get_classifications.py
Last active June 4, 2018 17:24
Produce table of classifications from output of 'guppy classify'
#!/usr/bin/env python
"""Produce a table of classifications for each input sequence in the
output of guppy classify
"""
from __future__ import print_function
import sys
import argparse
@nhoffman
nhoffman / report-template.Rmd
Last active June 7, 2021 20:19
rmarkdown template
---
title: [title]
author: Noah Hoffman
date: "`r format(Sys.time(), '%Y-%m-%d')`"
output:
html_document:
toc: true
---
# setup