Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / scaling_mastodon_down.md
Last active May 4, 2024 01:48
Scaling Mastodon down

Scaling Mastodon down

There is already a guide on scaling your Mastodon server up. This is a short guide on scaling your Mastodon server down.

I.e., maybe you want to run a small instance of <100 active users, and you want to keep your cloud costs reasonable. So you might be running everything on a single machine, with limited memory and CPU. (In my case, I was using a t3.medium instance with 2 vCPUs and 4GB of RAM.) How do you do this?

Note that I'm not a Ruby or Sidekiq expert, and most of this stuff I figured out through trial and error.

@nolanlawson
nolanlawson / bind-polyfill.js
Last active April 26, 2024 23:14
Chrome IndexedDB PouchDB heisenbug
(function () {
'use strict';
// minimal polyfill for phantomjs; in the future, we
// should do ES5_SHIM=true like pouchdb
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
@nolanlawson
nolanlawson / completion-for-gradle.md
Last active April 5, 2024 07:43
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@nolanlawson
nolanlawson / offline-first-tools.md
Last active March 16, 2024 15:46
List of offline-first tools for web developers

Offline-first tools for web developers

A quick list of tools for building HTML/CSS/JS apps that work well offline. Ping me at @nolanlawson if I missed anything!

Hybrid app development

Tools for bundling your HTML/CSS/JS into a native app.

@nolanlawson
nolanlawson / .gitignore
Last active March 9, 2024 18:53
Repro an issue with Vitest and crypto.subtle.digest
node_modules
@nolanlawson
nolanlawson / index.html
Last active March 1, 2024 22:47
PromiseWorker WebWorker example
<!DOCTYPE html>
<html lang="en">
<title>
PromiseWorker WebWorker example
</title>
<body>
<h1>PromiseWorker WebWorker example</h1>
<pre id="display"></pre>
<script src="https://npmcdn.com/promise-worker/dist/promise-worker.js"></script>
<script src="main.js"></script>
@nolanlawson
nolanlawson / .gitignore
Last active February 20, 2024 17:41
rollup-plugin-svelte v5 emitCss issue
node_modules
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@nolanlawson
nolanlawson / Dexie.min.js
Created February 7, 2015 18:01
IndexedDB+Dexie+Lunr MTG full-text search demo
(function(n,t,i,r){"use strict";function h(n,t){return typeof t!="object"&&(t=t()),Object.keys(t).forEach(function(i){n[i]=t[i]}),n}function y(n){return{from:function(t){return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,{extend:function(i){h(n.prototype,typeof i!="object"?i(t.prototype):i)}}}}}function p(n,t){return t(n)}function f(t){function or(){if(i)w.on("versionchange",function(t){w.close();t.newVersion&&n.location.reload(!0)})}function ki(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null};this.stores({})}function sr(n,t,i,r){var e,f,o,h,l,c;if(n==0)Object.keys(pt).forEach(function(n){di(t,n,pt[n].primKey,pt[n].indexes)}),e=w._createTransaction(kt,ri,pt),e.idbtrans=t,e.idbtrans.onerror=s(i,["populating database"]),e.on("error").subscribe(i),u.newPSD(function(){u.PSD.trans=e;try{w.on("populate").fire(e)}catch(n){r.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(f){}t.db.close();i(n)}});else{if(f=[],o=ii.filter(function(t){return
@nolanlawson
nolanlawson / .gitignore
Created January 28, 2024 17:25
Repro multi-page leak in Chromium 121
node_modules
*.heapsnapshot