Skip to content

Instantly share code, notes, and snippets.

View matthew-brett's full-sized avatar

Matthew Brett matthew-brett

View GitHub Profile
@matthew-brett
matthew-brett / unzip_submissions.py
Created April 10, 2024 15:55
Uznip submissions
#!/usr/bin/env python3
from pathlib import Path
import zipfile
from argparse import ArgumentParser, RawDescriptionHelpFormatter
def unpack_zip(zip_path, out_dir):
out_path = out_dir / zip_path.stem
@matthew-brett
matthew-brett / business.csv
Created January 3, 2024 17:35
Some San Francisco business names
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
name
HEUNG YUEN RESTAURANT
ILLY CAFFE SF_PIER 39
AMICI'S EAST COAST PIZZERIA
LOCAL CATERING
OUI OUI! MACARON
Hula Truck (#2)
GENKI CREPES & MINI MART
UNCLE LEE CAFE
Twirl and Dip
#!/usr/bin/env python3
""" Process .py file with nosetests assert_true etc for pytest
It does a fairly crude (regexp) job of taking lines nosetests lines like::
yield assert_true, 1 == 2
and replacing them with::
assert 1 == 2
@matthew-brett
matthew-brett / attendproc
Last active October 3, 2023 08:38
Script to process attendance files to generate various listings
#!/usr/bin/env python3
"""Process attendance data
Start by downloading an attendance sheet in HTML or Excel format.
You can download attendance data using the ".." icon in the Attendance
interface.
Download in Excel format using the "Download Excel" option.
#!/usr/bin/env python3
"""Print URL for multi-user teams chat
Start by downloading an attendance sheet in HTML using the ".." icon in the
Attendance interface, and selecting "View Attendance Sheet". This will give
you an HTML file download. Note the filename. Then run this program, passing
the filename of the downloaded file. It will print out a URL you can paste
into your browser. If you do, your browser will open Teams with a chat ready
to fill out, and all the people listed anywhere on the attendance sheet added
(regardless of whether they attended or not).
@matthew-brett
matthew-brett / reset_boot_disk.py
Created July 13, 2022 11:41
Script to do VMDK disk reset after reboot
#!/usr/bin/env python
""" Reset disk for VirtualBox vmdk
"""
import os.path as op
from subprocess import check_output
import plistlib
import re
from argparse import ArgumentParser, RawDescriptionHelpFormatter
#!/usr/bin/env python3
""" Show bluetooth power for named device on macOS
"""
import sys
import json
from subprocess import check_output, DEVNULL
from argparse import ArgumentParser, RawDescriptionHelpFormatter
r_local_dir <- file.path('C:', 'R')
r_tmp_dir <- file.path(r_local_dir, 'tmp')
r_inst_dir <- file.path(r_local_dir, 'win-library', '4.0')
dir.create(r_tmp_dir, recursive=TRUE)
dir.create(r_inst_dir, recursive=TRUE)
r_user_dir <- Sys.getenv('R_USER')
r_env_fn <- file.path(r_user_dir, '.Renviron')
write(paste("TMPDIR='", r_tmp_dir, "'", sep=''), r_env_fn)
write(paste("R_LIBS_USER='", r_inst_dir, "'", sep=''), r_env_fn, append=TRUE)
#!/usr/bin/env python3
import sys
import json
from subprocess import check_output, DEVNULL
from argparse import ArgumentParser, RawDescriptionHelpFormatter
def get_parser():
parser = ArgumentParser(description=__doc__, # Usage from docstring
SELECT pip_version, distro_name, distro_version, libc_version, bits, download_count
FROM (
SELECT REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(LOWER(details.distro.name), " (gnu/)?linux", ""), "^red.?hat.*", "redhat"), "os x","macos") AS distro_name,
details.distro.version as distro_version,
details.distro.libc.version as libc_version,
REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(file.filename, ".*manylinux.*_i686.whl$", "32"), ".*manylinux.*_x86_64.whl$", "64"), ".*manylinux.*", "") AS bits,
details.installer.version as pip_version,
COUNT(*) AS download_count,
FROM `the-psf.pypi.downloads*`
WHERE