Skip to content

Instantly share code, notes, and snippets.

View brizandrew's full-sized avatar

Andrew Briz brizandrew

View GitHub Profile
@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
@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 / README.md
Last active March 9, 2019 19:25
NICAR 2019: Workflow Tools
@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 / 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 / using-celery.md
Created August 15, 2018 21:29
Guide to setting up celery.

Setting Up Celery

Boilerplate Code

Install celery and redis

$ pipenv install celery redis

Configure the celery.py file in your exampleapp folder with your app name.

@brizandrew
brizandrew / sortDictList.py
Created April 26, 2018 15:00
Sort a list of dictionaries by a certain key
# Source: https://wiki.python.org/moin/SortingListsOfDictionaries
def sortDictList(arr, sort_key):
output = [(dict_[sort_key], dict_) for dict_ in arr]
output.sort()
return [dict_ for (key, dict_) in output]
@brizandrew
brizandrew / server.py
Last active December 19, 2023 10:16
Simple Flask Webhook Example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, request
from urllib import unquote_plus
import json
import re
app = Flask(__name__)
@brizandrew
brizandrew / README.md
Created July 28, 2017 22:07
How to use node.js build routines and npm packages in Django.

Using Node.js With Django

When writing django apps it's easy to ignore the organization of your front end code. Often, these backend coders will just write a static js and css file, stick it in the static directory, and call it a day.

You can also build them as two completely independent parts. With a complex gulp build routine independent of the django app. But if you don't know gulp, node, or those kinds of systems it can be a daunting process to get started with.

Enter django-compressor-toolkit (the name doesn't quite roll off the tongue).

Setting Up Django-Compressor-Toolkit

Using django-compressor and django-compressor-toolkit you can write Javascript ES6 code with all its fancy import/export logic or style your pages with sass instead of css, and leave your deploy routine largely untouched.

@brizandrew
brizandrew / get.js
Created July 25, 2017 20:19
Routing get requests through a php file to go around cross-site-origin restrictions.
function get(url){
var dataString = 'url='+url;
$.ajax({
url: "get.php",
type: "POST",
data: dataString,
success: function(html) {
// Stuff...
// HTML = the page
},