Skip to content

Instantly share code, notes, and snippets.

View brizandrew's full-sized avatar

Andrew Briz brizandrew

View GitHub Profile
@brizandrew
brizandrew / fips2Postal.js
Created August 28, 2018 19:51
Converts state fips codes into postal codes and back again.
/**
* Available Exports:
* @export {array} postalFipsList – list of state objects with 'FIPS' and 'postal' keys
* @export {object} fipsByPostal – dictionary with postal codes as keys and corresponding FIPS code as value
* @export {object} postalByFips – dictionary with FIPS codes as keys and corresponding postal code as value
* @export {function} fips2Postal – function to convert a fips code to a postal code.
* @export {function} postal2Fips – function to convert a postal code to a fips code.
*/
const fipsByPostal = {
@brizandrew
brizandrew / index.js
Created November 14, 2018 00:21
Download a Google Drive file of a given type with a JSON Web Token via Drive Api v3
/**
* Simple Node Script for Downloading Google Drive files (Drive API v3).
* Use these instructions to get a GAPI_CLIENT_EMAIL and GAPI_PRIVATE_KEY: https://github.com/The-Politico/api-to-sheets#making-a-google-service-account
* See all available types by document here: https://developers.google.com/drive/api/v3/manage-downloads
*/
const { JWT } = require('google-auth-library');
const { google } = require('googleapis');
const client = new JWT({
@brizandrew
brizandrew / README.md
Last active March 9, 2019 19:25
NICAR 2019: Workflow Tools
@brizandrew
brizandrew / slackKiosk.js
Created July 30, 2019 23:47
Bookmarklet to hide everything but the channel on a Slack page.
javascript:(function(){
s = ".p-workspace__primary_view";
function x(attr, val){document.querySelector(s).style[attr]=val;}
x('position', 'fixed');
x('background-color', 'white');
x('top', 0);
x('right', 0);
x('left', 0);
x('bottom', 0);
})();
@brizandrew
brizandrew / Texas Department of Criminal Justice COVID-19 Case Counts.js
Last active June 4, 2020 19:43
Texas Department of Criminal Justice COVID-19 Case Counts
// Go to
// https://txdps.maps.arcgis.com/apps/opsdashboard/index.html#/dce4d7da662945178ad5fbf3981fa35c
// Then copy and paste the code below into the console
// Step 1: Load SaveAs Function from File-Saver
function b(a,b){return "undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;return b.open("HEAD",a,!1),b.send(),200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object