Skip to content

Instantly share code, notes, and snippets.

cryptosi: Hi guys, looking to convince my company to use Remix but need some compelling arguments. This new project is definitely a good use case so I want to be able to articulate why we should use Remix. I've been doing my own research but wanted to reach out here to see if anyone had resources they might use for me to read and compile a list of reasons to use remix.

From purpler:

  • helped me avoid needing a graphql layer between my frontend and prisma

From Julienng:

  • simpler model than next : no isr, & all : it's easier to explain to new developer
  • simpler form than anything in the react world when you don't need anything fancy, and you can still do fancy stuff when needed
  • auto reload of loader when an action is fired : bye bye refreshListeners on parents for us and reloadPage() callback 😅
@ngbrown
ngbrown / background.js
Created February 15, 2023 06:01
CSP Nonce by extension
async function getCurrentTab() {
let queryOptions = { active: true, lastFocusedWindow: true };
// `tab` will either be a `tabs.Tab` instance or `undefined`.
let [tab] = await chrome.tabs.query(queryOptions);
return tab;
}
function reddenPage() {
document.body.style.backgroundColor = 'red';
const nonce = [...document.getElementsByTagName("script")].find(x => x.nonce)?.nonce;
@ngbrown
ngbrown / Export-Files-Csv.ps1
Created May 3, 2023 20:32
Export list of files with PowerShell
Get-ChildItem "\\?\C:\*.*" -Recurse | Select-Object FullName,LastWriteTime,Length | Export-Csv "$([Environment]::GetFolderPath("Desktop"))\File-Listing.csv" -NoTypeInformation
@ngbrown
ngbrown / hash-code.js
Last active November 30, 2023 16:28
Print CSP Hash
function _arrayBufferToBase64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
for (var i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
function getCspDigest(code) {
crypto.subtle.digest('SHA-256', new TextEncoder().encode(code)).then(function(val){
@ngbrown
ngbrown / uplot-react.tsx
Last active August 11, 2023 08:47
Updated uplot-react
// Adapted from https://github.com/skalinichev/uplot-wrappers
// MIT license
import type { JSX } from "react";
import React, { useCallback, useEffect, useRef } from "react";
import uPlot from "uplot";
import { dataMatch, optionsUpdateState } from "./uplot-wrappers-common.js";
export default function UplotReact({
@ngbrown
ngbrown / use-dynamic-throttle.ts
Last active August 19, 2023 17:10
useDynamicThrottle React hook
import { useCallback, useEffect, useRef, useState } from "react";
/**
* Returns a throttled version of the value and a function to release the next update, which may occur immediately or
* on the next value change.
*
* This can be used to keep the interface responsive when you have values that are changing too fast for async processes to keep up.
* @param value The value that is going to be throttled
*/
export function useDynamicThrottle<T>(
@ngbrown
ngbrown / generate-fontawesome-icons.js
Created December 21, 2023 02:42
Generate TypeScript files containing Font Awsome Icons from kit metadata
#!/usr/bin/env node
/* eslint-env node */
import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
async function main() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@ngbrown
ngbrown / client-only.tsx
Created December 27, 2023 18:58
Remix Client Only Component
import React, { ComponentType, lazy, Suspense } from "react";
export function ClientOnly({
fallback,
component,
}: {
fallback: React.ReactElement;
component: Promise<{ default: ComponentType<any> }>;
}) {
const LazyComponent = lazy(() => component);
@ngbrown
ngbrown / download-git-powershell.md
Created January 10, 2024 17:44
Downloading Git for Windows PowerShell

To download Git with PowerShell:

Get most recent version URL from https://git-scm.com/download/win

cd "${env:USERPROFILE}\Downloads"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$ProgressPreference = 'SilentlyContinue';Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/Git-2.43.0-64-bit.exe -OutFile Git-2.43.0-64-bit.exe
@ngbrown
ngbrown / svg-path-builder.ts
Last active April 14, 2024 18:06
SVG Path Builder (TypeScript)
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#path_commands
// https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
// M moveto (x y)+
// Z closepath (none)
// L lineto (x y)+
// H horizontal lineto x+
// V vertical lineto y+
// C curveto (x1 y1 x2 y2 x y)+
// S smooth curveto (x2 y2 x y)+
// Q quadratic Bézier curveto (x1 y1 x y)+