Skip to content

Instantly share code, notes, and snippets.

@rbk
rbk / titlechanger.js
Last active June 13, 2025 13:21
turns the tab title into an animated marquee
const titleChanger = () => {
const state = {
title: '___Hi there!___'
};
const swap = () => {
const parts = state.title.split("");
const lastItem = parts.pop();
const firstItem = parts.shift();
@rbk
rbk / vs-code-colors.md
Created May 13, 2025 14:11
Vs Code Colors

VS Code Color Customizations

NOTE: Key/value pairs should be nested under workbench.colorCustomizations

Example Object

const colorCustomizations = {
const items = Array.from(document.querySelectorAll('main ul li'));
const glossary = {}
const exampleObject = {};
items.map(x => {
const xx = x.textContent.split(':');
const desc = xx[1]?.trim();
const key = xx[0]?.trim();
if (!key.startsWith('The ')) {
exampleObject[key] = "#ff0000";
glossary[key] = desc;
@rbk
rbk / send-email.js
Created December 30, 2024 20:43
send an email with node mailer
const nodemailer = require('nodemailer');
const sendEmail = async ({to, subject, message, from}) => {
const transporter = nodemailer.createTransport({
host: process.env.AWS_SMTP_HOST,
port: process.env.AWS_SMTP_PORT,
secure: false,
auth: {
user: process.env.AWS_SMTP_USER, // generated ethereal user
pass: process.env.AWS_SMTP_PASS, // generated ethereal password
@rbk
rbk / webpack.config.js
Last active May 19, 2024 17:42
2024 - Full webpack.config.js I am using for a side project. (to share on SO)
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: 'development',
watchOptions: {
ignored: /node_modules/,
},
optimization: {
minimize: true,
@rbk
rbk / dom-utils.js
Created April 1, 2024 17:10
Remove all CSS styles from the DOM
Array.from(document.querySelectorAll('style, link')).map(x => x.remove());
Array.from(document.querySelectorAll('*')).map(x => {
x.setAttribute('stlye', "")
});
@rbk
rbk / download.js
Created October 18, 2022 03:06
Download a file with node
const files = [
"https://archive.org/download/OTRR_Gunsmoke_Singles/Gunsmoke%2052-04-26%20%28001%29%20Billy%20the%20Kid.mp3"
]
const exec = require('child_process').exec;
const downloadFile = (url) => {
return new Promise((resolve) => {
console.log(`wget ${url} --no-check-certificate`)
exec(`wget ${url} --no-check-certificate`, function(err, stdout, stderr) {
@rbk
rbk / async-localstorage.js
Created August 28, 2022 12:34
Simple async localStorage.
const asyncLocalStorage = {
setItem: function (key, value) {
return Promise.resolve().then(function () {
localStorage.setItem(key, value);
});
},
getItem: function (key) {
return Promise.resolve().then(function () {
return localStorage.getItem(key);
});
window.onerror = function(errorMessage, filePath, lineNumber, offset, stackObject) {
console.log(stackObject)
console.log({
'errorMessage' : errorMessage,
'filePath' : filePath,
'lineNumber' : lineNumber,
'offset' : offset,
'stackObject' : stackObject,
})
}
/**
* Say you have this: {"key": "123", "limit": 20}
* But you need this: ?key=123&limit=20
* Use objectToParams...
*/
const objectToParams = (obj) => {
const params = Object.keys(obj).reduce((acc, key) => {
return `${acc}&${key}=${obj[key]}`;
}, '');
return params.replace(/&/, '?');