Skip to content

Instantly share code, notes, and snippets.

View jwalgran's full-sized avatar

Justin Walgran jwalgran

  • Element 84
  • Phoenix, Arizona, USA
View GitHub Profile
@jwalgran
jwalgran / conditional-redirect-cloudfront-function.js
Created May 11, 2023 20:56
An AWS CloudFront function to conditionally redirect requests based on a query string parameter
// Adapted from https://devscope.io/code/aws-samples/amazon-cloudfront-functions/issues/11
function objectToQueryString(obj) {
var str = [];
for (var param in obj)
if (obj[param].value === '') {
str.push(encodeURIComponent(param));
} else {
// Normalize single and multiple value query params to a list of
// param value objects
@jwalgran
jwalgran / oar-stasmvt-tiler.md
Last active October 10, 2019 17:49
Implementing the ST_AsMVT based tiler for the Open Apparel Registry
@jwalgran
jwalgran / oar-dedupe-interactive-learning-session.txt
Created February 7, 2019 18:13
Dedupe interactive learning session on OAR facility data
> python oar_dedupe_example.py
importing data ...
starting active labeling...
country : cn
name : jiangsu best fashion dress co. ltd
address : no 88 huanxi road, zhutang town, jiangsu
country : cn
name : jiangsu best fashion dress co ltd
address : no88 round west road zhutang town jiangyin city jiangsu
@jwalgran
jwalgran / tts-card-urls.bash
Last active January 4, 2022 21:06
Extract the card face URLs from a Tabletop Simulator mod
grep FaceURL ~/Library/Tabletop Simulator/Mods/Workshop/1467894341.json | cut -d "\"" -f 4 | sort | uniq
tree_id plot_id url
1824045 2091476 https://www.opentreemap.org/greenprintmaps/features/2091476/
1824257 2091688 https://www.opentreemap.org/greenprintmaps/features/2091688/
1825475 2092906 https://www.opentreemap.org/greenprintmaps/features/2092906/
1825522 2092953 https://www.opentreemap.org/greenprintmaps/features/2092953/
1824791 2092222 https://www.opentreemap.org/greenprintmaps/features/2092222/
1825029 2092460 https://www.opentreemap.org/greenprintmaps/features/2092460/
1824888 2092319 https://www.opentreemap.org/greenprintmaps/features/2092319/
1824607 2092038 https://www.opentreemap.org/greenprintmaps/features/2092038/
1824401 2091831 https://www.opentreemap.org/greenprintmaps/features/2091831/
@jwalgran
jwalgran / docker-cleanup.md
Created April 25, 2018 17:34
Commands for cleaning up Docker containers and images

Delete exited containers

 docker container rm $(docker ps --filter "status=exited" | awk '{print $1}' | tail -n +2)

Delete untagged images

docker rmi $(docker images | grep "^" | awk '{print $3}')
@jwalgran
jwalgran / ch28-basic-libraries.md
Created February 13, 2018 21:44
Notes from Chapter 28 of Haskell Programming

Basic libraries

That's enough, Linus.

Basic libraries and data structures

Goal: Reduce CPU and memory

Data structure choice can have a big impact on resource usage.

@jwalgran
jwalgran / ch19.md
Created November 21, 2017 21:57
Haskell Programming Chapter 19 Notes

Chapter 19 - Applying structure

19.1 Applied structure

A big change of pace from previous chapters. A guided safari through a jungle of real projects.

19.2 Monoid

Templating content in Scotty

@jwalgran
jwalgran / ch11.hs
Created September 5, 2017 20:05
Haskell Programming Chapter 11 Part 2
module Ch11 where
import Data.Char
data GuessWhat =
Chickenbutt deriving (Eq, Show)
data Id a =
MkId a deriving (Eq, Show)
@jwalgran
jwalgran / waffle-io-queue-and-in-progress.js
Last active May 31, 2018 20:45
Format the third and fourth columns of a waffle.io board as tab-separated text
// 1. Browse a waffle.io board where "Queue" and "In Progres" are the 2nd and 3rd columns.
// 2. Run this code in the developer console.
// 3. Copy the tab-separated data and paste into your spreadsheet of choice.
// Thanks to https://github.com/rajadain for the initial implementation
var rows = [];
$('#page > div > div.ng-scope > div > ui-view > div > div.board.js-board > span.ng-scope > div.board-body > div > div:nth-child(3) .card,#page > div > div.ng-scope > div > ui-view > div > div.board.js-board > span.ng-scope > div.board-body > div > div:nth-child(4) .card').each(function() {
var card = $(this),
url = card.attr('data-waffle-url').replace('api.github.com/repos', 'github.com'),