Skip to content

Instantly share code, notes, and snippets.

@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 / entry.server.tsx
Last active April 10, 2024 15:46
Setup Sentry.io with Remix
const env = getEnvVars();
function myTracesSampler(samplingContext: SamplingContext) {
// Don't trace healthcheck or HEAD requests
const { transactionContext } = samplingContext;
if (
transactionContext.name === 'routes/healthcheck/_index' ||
transactionContext.tags?.method === 'HEAD'
) {
return false;
@kiliman
kiliman / README.md
Last active April 4, 2024 18:02
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 / index.tsx
Created February 7, 2023 21:31
Remix `useSubmitPromise` hook
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import type { SubmitOptions } from "@remix-run/react";
import { useActionData, useNavigation, useSubmit } from "@remix-run/react";
import { useCallback, useEffect, useMemo } from "react";
export function loader({ request }: LoaderArgs) {
return json({ message: "Hello World" });
}
@kiliman
kiliman / types.ts
Created August 11, 2023 14:43
Type helpers
export type MakeOptional<Type, Key extends keyof Type> = Omit<Type, Key> &
Partial<Pick<Type, Key>>;
export type PickNullable<T> = {
[P in keyof T as null extends T[P] ? P : never]: T[P];
};
export type PickNotNullable<T> = {
[P in keyof T as null extends T[P] ? never : P]: T[P];
};
@kiliman
kiliman / updatelinks.js
Last active November 16, 2023 23:21
Tampermonkey script to update GitHub links to ignore whitespace on diffs
@kiliman
kiliman / Remix-Logo-Black.svg
Created November 14, 2023 21:33
Remix logos with transparent background
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kiliman
kiliman / twitter-scroll-restore.js
Last active October 27, 2023 15:34
TamperMonkey script to fix Twitter scroll handling on replies
// ==UserScript==
// @name Twitter Scroll Restore
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author @kiliman
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?domain=twitter.com
// @grant none
// ==/UserScript==
@kiliman
kiliman / ts2js.sh
Last active October 11, 2023 00:43
Script to convert TypeScript files to JavaScript
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 source_folder target_folder"
exit 1
fi
source_folder="$1"
target_folder="$2"
@kiliman
kiliman / github-open-npm.js
Last active September 25, 2023 05:40
TamperMonkey script to open the npm package by Ctrl/Cmd+click on import statement from GitHub code view
// ==UserScript==
// @name GitHub open npm from import
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description Opens the npm package by Ctrl/Cmd+click on import statement
// @author Kiliman
// @match https://github.com/*
// @icon https://www.google.com/s2/favicons?domain=github.com
// @grant none
// ==/UserScript==