Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Brett matthew-brett

View GitHub Profile
View bt_power.py
#!/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
View set_r_dirs.R
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)
View bt_power.py
#!/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
View pip_distro_bits.bq
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
View process_numpy_bq_results.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View process_bq_results.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View pip_and_distros.bq
select pip_version, distro_name, distro_version, libc_version, (download_count / total * 100) as percent
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,
details.installer.version as pip_version,
COUNT(*) AS download_count,
SUM(COUNT(*)) OVER () AS total
FROM `the-psf.pypi.downloads*`
WHERE
View recent_pip_versions.bq
select pip_version, distro_name, distro_version, (download_count / total * 100) as percent
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.installer.version as pip_version,
COUNT(*) AS download_count,
SUM(COUNT(*)) OVER () AS total
FROM `the-psf.pypi.downloads*`
WHERE
details.installer.version IS NOT NULL
View recent_distributions.bq
select distro_name, distro_version, libcv, (download_count / total * 100) as percent
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 libcv,
COUNT(*) AS download_count,
SUM(COUNT(*)) OVER () AS total
FROM `the-psf.pypi.downloads*`
WHERE
details.distro.name IS NOT NULL
View ana_deaths.py
""" Analyzes output from NZ death registry search.
Input is some death records from printable (all) version of search on
https://bdmhistoricalrecords.dia.govt.nz
"""
import re
from datetime import datetime
import calendar