Skip to content

Instantly share code, notes, and snippets.

@nickscript0
nickscript0 / songs_to_csv.js
Created December 15, 2018 19:47
Improvement to export_google_music.js gist
// After running this guy's Google Play Music export https://gist.github.com/dcalacci/7f8853174797c0c56c49
// His export to CSV function doesn't format the lines properly
// Paste the following function in the console and run 'songsToCsv(all_songs)'
function songsToCsv(data) {
const out = [];
const seen = new Set();
const keys = [
'artist', 'album', 'title', 'duration', 'playcount', 'rating'
];
@nickscript0
nickscript0 / typescript-zip.ts
Created December 17, 2018 14:38
Typed zip functions in TypeScript
// zip for 2 arrays
function zip2<A, B>(a: A[], b: B[]): Array<[A, B]> {
return a.map((_, c) => [a, b].map(row => row[c])) as Array<[A, B]>;
}
// zip for any number of arrays
type Zip<T extends unknown[][]> = { [I in keyof T]: T[I] extends (infer U)[] ? U : never }[];
function zip<T extends unknown[][]>(...args: T): Zip<T> {
return <Zip<T>><unknown>(args[0].map((_, c) => args.map(row => row[c])));
}
@nickscript0
nickscript0 / public-ip.sh
Created December 24, 2018 17:07
Fastest way to find your Public IP in the terminal (OpenDNS query)
dig myip.opendns.com @208.67.222.222 +short
@nickscript0
nickscript0 / raspberry_pi_initial_setup.md
Last active May 16, 2022 00:20
Raspberry Pi 3 - Initial Setup with Raspbian

Initial Raspberry Pi 3 Setup with Raspbian

Flash Raspbian and connect to network via ethernet

  1. Download the latest Lite version from https://www.raspberrypi.org/software/operating-systems/
  2. Use the "balenaEtcher" app (https://www.balena.io/etcher/) to flash the iso to a microSD card
  3. Copy a blank file named ssh to the boot partition (the root folder of the microSD card)
  4. Power up the Raspberry PI, find it's IP in your router's connected devices, and ssh pi@<ip> (password: raspberry)

Initial Hardware and Raspbian configuration

  1. sudo raspi-config
  2. System Options > Change user password
@nickscript0
nickscript0 / mpg-to-Lp100km-bookmarklet.js
Last active December 20, 2019 13:26
Bookmarklet: Finds all strings that match '<number> mpg' and suffixes them with the l/100km conversion
javascript: (function () {
function convert(currentElement) {
if (!currentElement.textContent) return;
/*
* Match mpg strings with negative lookahead for the l/100km conversion string
* to avoid duplicating the conversion when run multiple times.
* E.g. "N.N mpg" not followed by " (N.N l/100km)"
*/
const mpgRegex = /(\d*(\.\d+)?)(\s)*mpg(?!\s\(\d+\.\d+\sl\/100km\))/gi;
const currentText = currentElement.textContent;