Skip to content

Instantly share code, notes, and snippets.

@kiliman
kiliman / git-dl.sh
Last active July 21, 2021 20:18
Bash script to download folder from GitHub repository
#! /bin/bash
if [ -z "$1" ]; then
echo USAGE: "$0" URL [BRANCH]
exit
fi
url="$1"
# default to branch master
branch=master
# optional 2nd parameter is branch
@kiliman
kiliman / pm2.config.js
Last active November 23, 2021 00:08
PM2 config to handle Remix/Express/TailwindCSS + rsync to reduce duplicate reloads
module.exports = {
apps: [
{
name: "Express",
script: "server/index.js",
watch: ["server/index.js"],
watch_options: {
followSymlinks: false,
},
env: {
@kiliman
kiliman / error.js
Last active July 29, 2021 13:21
Patch to Remix for source-maps
// Copyright © 2021 React Training LLC. All rights reserved.
'use strict'
const sourceMap = require('source-map')
const fs = require('fs')
const path = require('path')
Object.defineProperty(exports, '__esModule', { value: true })
/**
* This thing probably warrants some explanation.
@kiliman
kiliman / updatelinks.js
Last active November 16, 2023 23:21
Tampermonkey script to update GitHub links to ignore whitespace on diffs
@kiliman
kiliman / README.md
Last active March 26, 2025 23:44
Debug server-side Remix using VSCode

💡 HOWTO: Debug your server-side Remix code using VSCode

✨ New in Remix v1.3.5

The latest release of Remix fixes sourcemaps so you no longer need to use any hacks to set breakpoints in your route modules. Simply start the debugger and Remix will hit the breakpoint in your loaders and actions.

Debugging session even survives edits and Live Reload.

@kiliman
kiliman / react-router+6.0.2.patch
Created December 7, 2021 23:20
Patch for react-router to fix no matching paths with leading . (e.g. /.well-known/acme-challenge/abc123)
diff --git a/node_modules/react-router/umd/react-router.development.js b/node_modules/react-router/umd/react-router.development.js
index bfb1dc6..6aa8ba5 100644
--- a/node_modules/react-router/umd/react-router.development.js
+++ b/node_modules/react-router/umd/react-router.development.js
@@ -820,7 +820,9 @@
: // Otherwise, at least match a word boundary. This restricts parent
// routes to matching only their own words and nothing more, e.g. parent
// route "/home" should not match "/home2".
- "(?:\\b|$)";
+ // PATCH: return "" instead of "\\b" because it fails to match leading .
@kiliman
kiliman / @remix-run+server-runtime+1.0.6.patch
Created December 8, 2021 16:41
PATCH to add request and context to Remix CatchBoundary
diff --git a/node_modules/@remix-run/server-runtime/server.js b/node_modules/@remix-run/server-runtime/server.js
index eef3403..d483581 100644
--- a/node_modules/@remix-run/server-runtime/server.js
+++ b/node_modules/@remix-run/server-runtime/server.js
@@ -226,7 +226,9 @@ async function handleDocumentRequest(request, loadContext, build, platform, rout
componentDidCatchEmulator.catch = {
status: requestState === "no-match" ? 404 : 405,
statusText: requestState === "no-match" ? "Not Found" : "Method Not Allowed",
- data: null
+ data: null,
@kiliman
kiliman / globals.js
Created January 5, 2022 19:42
remix-fastify adapter
'use strict';
var node = require('@remix-run/node');
node.installGlobals();
@kiliman
kiliman / server-index.js
Created January 8, 2022 16:07
Remix Express handler that checks for auth cookie/token and return 401 if missing on non-anonymous routes
function handleRequest(req, res, next) {
let build = require('./build')
if (MODE !== 'production') {
purgeRequireCache()
}
if (requireAuthentication(req)) {
return unauthenticated(req, res)
}
return createRequestHandler({
build,
@kiliman
kiliman / main.js
Last active January 25, 2022 00:30
Remix Electron to add menus and navigate to routes
// @ts-check
const electron = require("electron");
const { app, BrowserWindow, dialog, Menu } = electron;
const { startServer } = require("./server");
let win;
let server;
async function main() {
await app.whenReady();