Skip to content

Instantly share code, notes, and snippets.

View johndhancock's full-sized avatar

John Hancock johndhancock

  • The Boston Globe
  • Dallas, Texas
View GitHub Profile
@johndhancock
johndhancock / all_records_2026.csv
Last active April 10, 2026 14:22
warn_notices_2026_csv
duplicate Received Employer City/Town Region Layoff date(s) Employees impacted
False 4/3/2026 South Shore Elder Services Braintree, MA Southeast 6/1/2026 - 6/30/2026 52
False 3/30/2026 Clover Fast Food, Inc. (Clover) Cambridge, MA Boston 5/29/2026 182
False 3/29/2026 Walmart Worcester, MA Central 5/29/2026 90
False 3/25/2026 Takeda Pharmaceuticals USA, Inc. (dba Takeda) Cambridge, MA Boston 7/1/2026 - 12/31/2027 247
False 3/25/2026 Charles River Laboratories Wilmington, MA Boston 4/24/2026 - 7/10/2026 71
False 3/24/2026 Revvity, Inc. Boston, MA Boston 6/1/2026 - 3/31/2027 29
False 3/24/2026 Compass Group USA, Inc. (dba Chartwells) Boston, MA Boston 5/27/2026 76
False 3/18/2026 WestRock Services, LLC (aka WestRock and Smurfit Westrock) Wakefield, MA Boston 5/18/2026 91
False 3/12/2026 Boston Electrometallurgical Corporation (dba Boston Metal) Woburn, MA Boston 4/21/2026 71
@johndhancock
johndhancock / mongodb-commands.md
Last active October 25, 2024 15:10
Helpful MongoDB commands

Terminal

  • lsof -iTCP -sTCP:LISTEN -n -P: See what is running on which port
  • kill {portnumber}: Stop whatever is running on designated port
  • mongod --dbpath {dir_path}: Specify where mongodb should start up the database
  • mongosh: Enter the mongodb shell

Mongoshell

  • use {db_name}: Create a database by name
  • db.{collection_name}.insertMany({json_array}): Insert multiple records into a database collection
@johndhancock
johndhancock / ai2html2react.py
Created June 20, 2024 18:45 — forked from hjhilden/ai2html2react.py
Prototype command line script to convert ai2html output to valid React
import sys
import os
import re
dir_path = os.path.dirname(os.path.realpath(__file__)) + '/'
static_content_folder = 'static/custom/ai2html-output/'
# script takes two arguments "input" and "output" and optional static content folder arg
# .js extension is added to output
@johndhancock
johndhancock / select.css
Created April 19, 2023 16:40
Styled select element
select {
display: inline-block;
font-weight: 400;
padding: .5rem 1.5rem .5rem .5rem;
border: 1px solid rgb(175,175,175);
box-shadow: 0 1px 0 1px rgba(0,0,0,.04);
border-radius: .5em;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
@johndhancock
johndhancock / r-tips-tricks.md
Last active April 13, 2023 14:35
A collection of handy tips and tricks for R

ggplot

Tip Sheet

Color palettes

Saving custom color palettes to a variable, then using them in a ggplot chart

saving the palette

palette <- c(‘#d2848c”, “#fa807s”, “#ee9a00”, “#e0ffff”)

@johndhancock
johndhancock / boston-neighborhoods.json
Last active September 10, 2021 18:54
Boston Neighborhoods.json
[
{
"name": "Roslindale",
"latlong": [-71.1245, 42.2913]
},
{
"name": "Jamaica Plain",
"latlong": [-71.1202, 42.3098]
},
{
// from purpleair.com
// original source: https://docs.google.com/document/d/15ijz94dXJ-YAZLi9iZ_RaBwrZ4KtYeCy08goGBwnbCU/edit#
function aqiFromPM(pm) {
if (isNaN(pm)) return "-";
if (pm == undefined) return "-";
if (pm < 0) return pm;
if (pm > 1000) return "-";
/*
@johndhancock
johndhancock / creditless-footer.hbs
Last active August 18, 2021 18:18
bg-hbs-components
@johndhancock
johndhancock / populateSelectors.js
Last active January 5, 2021 23:12
Populating an empty select element with values dynamically from data
export default function (values) {
// sort value strings alphabetically
values.sort((a, b) => {
if (a.toLowerCase() < b.toLowerCase()) return -1;
if (a.toLowerCase() > b.toLowerCase()) return 1;
return 0;
});
// find select element/elements
const selects = document.querySelectorAll('<<selector name>>');
@johndhancock
johndhancock / circle-ci-debug-steps.md
Last active December 19, 2019 05:10
How to debug Circle-Ci problems, via a real-world example

Early Oct. 2019, I ran into a problem on our Voter Guide where Circle Ci would fail before tests would even run. I could get a basic sense of what was happening via the Circle-Ci interface, but the problem wasn't immediately evident.

After consulting with Andrew Chavez, he pointed me to a page that explains how to SSH into a build running on Circle-Ci to run the commands step-by-step in an attempt to debug the problem.

After SSH-ing in, and cd-ing into the directory on the running build (in this case, cd voter-guide), you're able to run the commands listed in the circle-ci/config.yaml file in the project and seeing the read-out within the terminal as you go along.

In this instance, part of the setup process of the circle ci box involves running this command, which pulls a setup file for Nodejs v 8.x and installs it:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -