Skip to content

Instantly share code, notes, and snippets.

View jkeefe's full-sized avatar

John Keefe jkeefe

View GitHub Profile
@jkeefe
jkeefe / pi.md
Last active January 17, 2026 21:53
Prepping a Raspberry Pi

Preparing a Pi

My Mac is too old to use the Raspberry Pi Imager.

So intstead I ...

  • go to the downloads page and download the "Raspberry Pi OS" version (as opposed to the "Full" or "Lite" versions — just my preference).
  • use balenaEtcher to image a Mini SD card. The card should be an "A2" version, and I like to use 64GB.
  • use a USB keyboard and HDMI monitor to set up:
  • Wifi network and password (set on first bootup)
@jkeefe
jkeefe / raspberry-pi-ble-sniffer.md
Last active November 14, 2025 11:32
Notes on using Adafruit's "Bluefruit" BLE sniffer with a Raspberry Pi

BLUETOOTH SNIFFER

Working to sniff Bluetooth Low Energy with the adafruit sniffer

For more information, see this blog post

Going the python route, as described here

before installing pySerial, did ...

@jkeefe
jkeefe / niceRounder.js
Last active October 21, 2025 00:29
Rounds whole numbers to nice figures for publication
// based on: https://stackoverflow.com/a/67136959
const niceRounder = (number) => {
let near = 1
if (number > 100) near = 10
if (number > 1000) near = 100
if (number > 10000) near = 1000
if (number % near === 0) return number;
@jkeefe
jkeefe / large_files.sh
Last active December 24, 2024 17:02
Removing large files from Github repo commit history
# example: get rid of large `.tif` and `.nc` files in gis/tmp
# from https://www.geeksforgeeks.org/how-to-remove-a-large-file-from-commit-history-in-git/
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch gis/tmp/*.tif' \
--prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch gis/tmp/*.nc' \
--prune-empty --tag-name-filter cat -- --all
@jkeefe
jkeefe / import_mapshaper.js
Last active November 26, 2024 15:50
Importing mapshaper in ES6
// npm install mapshaper --save
import mapshaper from 'mapshaper'
// Example of runCommands: converting a directory of Shapefiles to GeoJSON
mapshaper.runCommands('-i shapefiles/*.shp -o geojson/ format=geojson');
// ----
// Example of applyCommands: processing a json array
@jkeefe
jkeefe / access.json
Last active May 3, 2024 19:22
Access One Bucket Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
@jkeefe
jkeefe / example.js
Last active January 25, 2024 23:12
Adding text to images in Node
const fs = require('fs')
const gm = require('gm').subClass({ imageMagick: '7+' });
WIDTH = 1138
HEIGHT = 50
X = 0
Y = 0
gm('./images/us_at_bottom.png')
.region(WIDTH, HEIGHT, X, Y)
@jkeefe
jkeefe / cors.json
Last active October 25, 2023 22:38
Open CORS policy for AWS S3
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
@jkeefe
jkeefe / round.js
Created August 3, 2023 18:00
Sweet dayjs rounding function
// from https://github.com/iamkun/dayjs/issues/1619#issuecomment-1185714859
const round: PluginFunc = (option, dayjsClass) => {
dayjsClass.prototype.round = function (amount, unit) {
const mod = this.get(unit as UnitType) % amount;
if(mod < amount / 2) {
return this.subtract(mod, unit).startOf(unit);
}
@jkeefe
jkeefe / date-to-eastern.js
Last active May 12, 2023 19:50
Parse current date to U.S. Eastern time + customize short months & a.m./p.m.
// installation:
// npm install dayjs dayjs-plugin-utc --save
// note: if not already a module, in package.json add "type":"module",
import dayjs from 'dayjs';
import updateLocale from 'dayjs/plugin/updateLocale.js';
import utc from 'dayjs/plugin/utc.js';
import timezone from 'dayjs/plugin/timezone.js';
// set up the as-of date