Skip to content

Instantly share code, notes, and snippets.

@Rob--W
Rob--W / escaopeHTMLTag.js
Created November 14, 2016 16:39
Example of safe HTML escaping using template literals
/* Example:
var someUnsafeStr = '<img>';
var result = escapeHTMLTag`<input value="${someUnsafeStr}">`;
console.log(result); // <input value="&lt;img&gt;">
// Questions? rob {at} robwu.nl
// */
function escapeHTML(str) {
// Note: string cast using String; may throw if `str` is non-serializable, e.g. a Symbol.
@twilight-sparkle-irl
twilight-sparkle-irl / indexy.sh
Last active July 14, 2019 16:27
i went too deep. creates index files for a directory on the drive, and continually updates them
#!/bin/bash
# requires inotify-tools and tree be installed
# --CONFIG--
INDEXDIR="$(pwd)" # change this to where you have the directory you want to index mounted
URL="https://generichost.example/~/person/assets" # change this to where the urls go
TITLE="stuff - %s" # %s represents the current directory
# below is the css to apply to the files. you can touch it if you wanna
# but i'd just recommend replacing the directory listing creator entirely lol