Skip to content

Instantly share code, notes, and snippets.

@replete
replete / getWOTD.js
Created April 9, 2024 15:30
Mirriam-Webster Word of The Day - Templater User Script for Obsidian.md
// Mirriam-Webster WOTD Templater User Script:
// Include this file in your Templater plugin User Scripts folder
// Use within your daily note templater template like this:
// <% tp.user.getWOTD(tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")) %>
function fetchWordOfTheDay() {
const rssUrl = 'https://www.merriam-webster.com/wotd/feed/rss2';
return new Promise((resolve, reject) => {
@replete
replete / instagramURLripper.js
Created March 2, 2024 14:44
Save all URLs from Instagram saved page on desktop
if (!window.ripperLinks) window.ripperLinks = [];
window.ripperCount = 0;
window.ripperFunc = function(){
document.querySelectorAll('article [role=link]').forEach(el => {
ripperLinks.push(el.href);
});
let uniqueLinks = ripperLinks.filter(function(elem, index, self) {
return index === self.indexOf(elem);
});
ripperLinks = uniqueLinks;
@replete
replete / chesscomapi.js
Created June 9, 2023 09:58
get game data from chess.com API
//https://api.chess.com/pub/player/{username}/games/2023/02
(async function main () {
async function getChessGamesForMonth(username, year, month) {
const res = await fetch(`https://api.chess.com/pub/player/${username}/games/${year}/${month}`);
if (res.ok) {
const data = await res.json();
return data.games
} else {
console.error('Problem loading chess.com games from API', res);
@replete
replete / wc-weather.js
Created June 9, 2023 09:56
Obsidian render 3day weather from wc - incomplete js
let data = {
"current_condition": [
{
"FeelsLikeC": "5",
"FeelsLikeF": "41",
"cloudcover": "75",
"humidity": "53",
"localObsDateTime": "2023-02-23 03:03 PM",
"observation_time": "03:03 PM",
"precipInches": "0.0",
@replete
replete / userChrome.css
Last active August 28, 2022 20:14
userchrome.css Firefox 100-ish+ MacOS Dark mode browser.uidensity = 1
/*
@replete's userChrome.css
https://gist.github.com/replete/ba62b8bc9cf61c1e1f8a2ac2eb3907f9
multi-row styles taken from:
https://github.com/MrOtherGuy/firefox-csshacks
compact toolbar styles stolen from somewhere before I decided to do a better job of it
Tweaked these two contributions a bit, but can't remember what I did. My styles are at the bottom
@replete
replete / bitbucket-pipelines-deploy-to-ftp.txt
Last active March 15, 2022 23:04
Bitbucket Pipelines deploy to FTP
Step 1:
Create a new Bitbucket pipeline with the following yaml, then add environment variables (in the bitbucket web UI) for FTP_HOST, FTP_USERNAME, FTP_PASSWORD - update host path below accordingly.
Step 2: Commit this file, once a build passess successfully and it has initialized Git FTP, proceed to Step 3
```bitbucket-pipelines.yml
image: atlassian/default-image:3
pipelines:
default:
@replete
replete / pino.colorisedTerminalTransformTransport.mjs
Created October 23, 2021 22:36
Pino v7 logger transport transformer to console.log colorized terminal output, for use within a pino transport pipeline
import { Writable } from 'stream'
export default (options) => {
const levels = {
// https://github.com/pinojs/pino/blob/master/docs/api.md#logger-level
10: `\x1b[2m[>]\x1b[0m`, //trace
20: `\x1b[35m[DEBUG]\x1b[0m`, //debug
30: `\x1b[36m[>]`, //info
40: `\x1b[33m[?]`, //warn
50: `\x1b[31m[!]`, //error
@replete
replete / bootstrap.sh
Created October 23, 2021 16:48
Node/mongo application bootstrap script WIP
#!/bin/bash
log() { echo -e "\x1b[0m\033[1;30m$(date +%H:%M:%S)\x1b[0m $@ \x1b[0m" ; }
INFO='\x1b[0m\033[1;30m[>]\x1b[0m'
OK='\x1b[0m\033[1;32m[✔]\x1b[0m'
WARN='\x1b[0m\033[1;33m[?]'
ERROR='\x1b[0m\033[1;31m[!]'
NODEVER=v17.0.1
MONGODBNAME=appdb
@replete
replete / wip-abandoned-node-app-bootstrapper.js
Created October 23, 2021 13:45
Beginnings of a node-based bootstrapper for apps, abandoned for better bash scripting but there is a handy log function here and a few patterns useful when working with child_process sync
const fs = require('fs')
const exec = (cmd) => require('child_process').execSync(cmd, { shell: '/bin/bash' })
try {
let nodePath = exec('which node').toString().replace('\n', '')
let nodeVer = exec('node -v').toString().replace('\n', '')
const expectedNodeVer = fs.readFileSync('.nvmrc', 'utf-8').replace('\n', '')
const npmVer = exec('npm -v').toString().replace('\n', '')
const nodeVerComparison = versionCompare(nodeVer.substring(1), expectedNodeVer.substring(1))
@replete
replete / log.ts
Created October 13, 2021 18:36
Color-enhanced logger for Typescript Node
const color = {
reset: '\x1b[0m',
bright: '\x1b[1m',
dim: '\x1b[2m',
underscore: '\x1b[4m',
blink: '\x1b[5m',
reverse: '\x1b[7m',
hidden: '\x1b[8m',
fgBlack: '\x1b[30m',