This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Go to https://open.spotify.com/collection/tracks | |
// 2. Scroll to the very bottom so everything is loaded | |
// 3. Press F12 and paste the following code (obviously only if you understand what it does) | |
// 4. Press Ctrl+A and copy everything to a .csv file | |
document.documentElement.innerHTML = "<pre>Title\tArtist\tAlbum\n" | |
+ [...document.querySelectorAll(".tracklist .tracklist-row")] | |
.map(x => { | |
const e = x.querySelector(".TrackListRow__explicit-label"); | |
if (e) e.parentElement.removeChild(e); | |
return x.querySelector(".tracklist-name").textContent + "\t" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
* { box-sizing: border-box; } | |
body { margin: 0; padding: 0; display: flex; background: #2C2C39; min-height: 100vh; } | |
.input { width: 40%; padding: 25px; display: flex; flex-direction: column; } | |
textarea { flex-grow: 1; border: none; resize: none; margin-bottom: 25px; padding: 15px; background: rgba(255,255,255,0.1); color: #fff; } | |
textarea:last-child { margin-bottom: 0; } | |
.output { flex-grow: 1; padding: 25px 25px 25px 0; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repo=sharkdb/fd | |
file=0 # use the first file | |
# with jq (recommended if available) | |
wget https://api.github.com/repos/${repo}/releases/latest -qO- | jq -r ".assets[${file}].browser_download_url" | |
# - or - | |
curl https://api.github.com/repos/${repo}/releases/latest -so- | jq -r ".assets[${file}].browser_download_url" | |
file=$(($file + 1)) # WARNING: sed uses 1-based indices! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RestApi(endpoint, options) { | |
this.endpoint = (endpoint || "/").replace(/\/$/, ""); | |
this.options = options || {}; | |
// Allow usage in queue, or in other places where the value of "this" is incorrect: | |
for (let method in ["GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"].reduce((p,c)=>p[c]=1,{})) { | |
this[method] = RestApi.prototype[method].bind(this); | |
} | |
} | |
RestApi.fetchResponseHandler = function fetchResponseHandler(hardFail, res) { | |
return new Promise((resolve, reject) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Completely promise-based queue that works with functions returning promises and normal values. | |
/* | |
function doSomething() { | |
return new Promise(y => setTimeout(() => y(), 3000)); | |
} | |
// Using the singleton | |
for (let i = 0; i < 10; i++) Q(() => doSomething()).then(() => console.log(i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Network Bridge | |
After=syslog.target network.target | |
[Service] | |
Type=onehot | |
ExecStart=/opt/bridge.sh | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Minimal Event Handler | |
// Call makeEmitter(obj) to make obj an event emitter. | |
// obj.on(event, handler) | |
// obj.off(event[, handler]) | |
// obj.fire(event[, args...]) | |
// https://gist.github.com/moqmar/1a33e871e9a4b855443d57d40f56d052 (Public Domain/CC0) | |
function makeEmitter(obj) { | |
obj.__l = {}; // Listeners - this.on("update", fn) -> { update: [fn] } | |
obj.on = function(ev, fn) { | |
if (!this.__l[ev]) this.__l[ev] = [fn]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Build script for the Git version of https://caddyserver.com | |
# | |
# Requirements: | |
# - Go | |
# - jq (if using names instead of import paths for plugins) | |
# Usage: | |
# curl https://gist.githubusercontent.com/moqmar/ba77bd778e6ebc956eaa36388be3fcdd/raw | bash -s http.realip http.ipfilter http.cors http.expires http.ratelimit #[...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ./Dockerscript <prefix> | |
name=helloworld | |
[ -n "$PREFIX" ] && prefix=-$PREFIX | |
set -e | |
start() { | |
docker network create --driver bridge $name$prefix | |
docker run -id --restart=always --network=$name$prefix -v "$PWD/files:/data" --name=$name$prefix-main "$@" hello-world |