Skip to content

Instantly share code, notes, and snippets.

View Stephen-ONeil's full-sized avatar
:shipit:
‏‏ ‏ ‏‏‏‏ ‏ ‏‏

Stephen Levi O'Neil Stephen-ONeil

:shipit:
‏‏ ‏ ‏‏‏‏ ‏ ‏‏
View GitHub Profile
@Stephen-ONeil
Stephen-ONeil / bandcamp_purchase_history_total.js
Created March 17, 2019 04:39
Morbidly curious about your lifetime total spending on Bandcamp? I was. To get an answer, I wrote some JS that I can run in my browser's dev console to extract that info from Bandcamp's purchase history page.
// Don't go pasting scripts from internet strangers in your dev consoles, ok?
/*
Procudeure (for my own sake, because YOU wouldn't go and paste scripts from a stranger in to your dev console, right?):
1) visit https://bandcamp.com/<username>/purchases
2) run the code under the SETTING UP THE PAGE heading in the dev tool's console
3) run the code under the ACTUALLY SCRAPING heading in the dev tool's console
optional: change "CAD" argument on final line to alternate desired currency code
4) raise your eyebrows at the output (and keep in mind that you're applying current
conversion rates retroactively, and thus getting a skewed result)
@Stephen-ONeil
Stephen-ONeil / csv_multi_find_replace.sh
Last active May 1, 2019 22:39
Quick and dirty bash script for running a multi-find-and-replace on a csv (using another csv containing mapping definitions)
#!/bin/bash
# Takes a mapping csv with the first column containing the values to replace-with and the 2nd to nth columns containing the patterns
# to replace-by. The target document is matched by cell against each pattern, and a cell that matches is replaced in the output (mfr_output.csv)
# by the replace value corresponding to the first pattern it matches on.
# Known issues:
# Seems to be bad at matching certain accented chars, encoding issues? Maybe deburr before matching if you have that problem
mapping_file=$1