This file contains 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
// Configuration | |
// You'll be able to set the domain when adding/editing the widget | |
// Make sure the stats are public on Plausible | |
const namespace = args.widgetParameter || "plausible.io" | |
const displayName = namespace.slice(0,namespace.lastIndexOf(".")) | |
const accentColor = new Color("#CCCCCC") | |
// LineChart by https://kevinkub.de/ | |
// Used as the widget background | |
class LineChart { |
This file contains 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 CopyButton({ value }) { | |
let [copied, setCopied] = React.useState(); | |
let hydrated = usePageIsHydrated(); | |
React.useEffect(() => { | |
let id = setTimeout(() => setCopied(false), 2000); | |
return () => clearTimeout(id); | |
}, [copied]); | |
return ( | |
<button |
This file contains 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
// I see this mistake often (and have made it myself before) | |
// What's the bug with this function? | |
function isFavSeason(season) { | |
return season === 'spring' || 'summer' ? 'yes' : 'no' | |
} | |
// Let's try it and find out | |
console.log(isFavSeason('spring')) // yes | |
console.log(isFavSeason('summer')) // yes |
This file contains 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
// Builds array of everything ahead of time | |
function collectAllItems() { | |
return [calculateFirst(), calculateSecond(), ...] | |
} | |
// This loop will end as soon as `isMatch(item)` is truthy. | |
// If the very first item in the array is a match, then we | |
// wasted all this time building the array in the first place. | |
for (let item of collectAllItems()) { | |
if (isMatch(item)) { |
This file contains 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
#!/usr/bin/python3 | |
import yaml | |
import sys | |
import csv | |
# create root yaml | |
matches = [] | |
# open file |
This file contains 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: gray; icon-glyph: magic; | |
// Defaults to the latest version and no automatic update; if the file exists, just use it | |
const moment = await require('moment'); | |
// Use any SemVer options to specify a version you want | |
// Refer to the calculator here: https://semver.npmjs.com/ | |
const lodash = await require('lodash@^3.9.1'); |
This file contains 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: green; icon-glyph: file-code; | |
const getModule = importModule("getModule"); | |
const documentDirectory = FileManager.iCloud().documentsDirectory(); | |
module.exports = async ({ moduleName, url, forceDownload = false }) => { | |
if (moduleExists(moduleName) && !forceDownload) { | |
return importModule(moduleName); |
This file contains 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: green; icon-glyph: file-code; | |
module.exports = async ({ url, headers = {} }) => { | |
const request = new Request(url); | |
request.method = methods.get; | |
request.headers = { | |
...headers | |
}; | |
return await request.loadString(); |
This file contains 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: green; icon-glyph: file-code; | |
const getString = importModule('getString'); | |
const documentDirectory = FileManager.iCloud().documentsDirectory(); | |
const header = `// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-gray; icon-glyph: file-code;`; |
This file contains 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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: green; icon-glyph: file-code; | |
module.exports = { | |
post: async ({ url, body, headers = {} }) => { | |
const request = new Request(url); | |
request.body = JSON.stringify(body); | |
request.method = methods.post; | |
request.headers = { | |
...defaultHeaders, |