Skip to content

Instantly share code, notes, and snippets.

View smeijer's full-sized avatar

Stephan Meijer smeijer

View GitHub Profile
@smeijer
smeijer / github-sync.sh
Created February 6, 2024 17:43
sync github repositories
#! /usr/bin/env node
import fs from 'fs';
import { promisify } from 'util';
import path from 'path';
import { spawn } from 'child_process';
const fsExists = promisify(fs.exists);
if (!process.env.GITHUB_TOKEN) throw new Error("process.env.GITHUB_TOKEN is required");
if (!process.env.GITHUB_USER) throw new Error("process.env.GITHUB_USER is required");
@smeijer
smeijer / @remix-run+server-runtime+2.0.1.patch
Created October 2, 2023 14:30
patch-package to make Remix not use type-fest Jsonify
diff --git a/node_modules/@remix-run/server-runtime/dist/serialize.d.ts b/node_modules/@remix-run/server-runtime/dist/serialize.d.ts
index 70ed67b..c77e90b 100644
--- a/node_modules/@remix-run/server-runtime/dist/serialize.d.ts
+++ b/node_modules/@remix-run/server-runtime/dist/serialize.d.ts
@@ -1,17 +1,31 @@
-import type { Jsonify } from "type-fest";
import type { AppData } from "./data";
import type { TypedDeferredData, TypedResponse } from "./responses";
-type Fn = (...args: any[]) => any;
+type JsonPrimitive = string | number | boolean | String | Number | Boolean | null;
@smeijer
smeijer / output.test.ts
Last active August 24, 2022 10:12
Testing build output for a node lib
/* eslint-disable @typescript-eslint/no-var-requires */
import { transform } from '@babel/core';
import { exec } from 'child_process';
import { readFileSync } from 'fs';
import { promisify } from 'util';
const execAsync = promisify(exec);
const pkg = require('../../package.json');
function importBundle(filepath: string) {
@smeijer
smeijer / session.js
Created February 18, 2022 14:05 — forked from AndrewIngram/session.js
next-runtime session middleware
import { json } from "next-runtime";
import jwt from "jsonwebtoken";
const SESSION_KEY = "some-secret";
export function readSession(cookies) {
const sessionCookie = cookies.get("session");
let data = {};

Reach UI Philosophy

Reach UI is an accessible foundation for React applications and design systems.

The three equally important goals are to be:

  • Accessible
  • Composable
  • Stylable
@smeijer
smeijer / README.md
Created February 15, 2021 13:39
twind/shim + nextjs

My config for using twind/shim with next.js, as used for rake.red

Github Gists don't like slashes in names, so be sure to move .twind.config.js out of the pages folder.

./twind.config.js
./pages/_app.js
./pages/_document.js
@smeijer
smeijer / post-install.js
Last active November 7, 2019 14:46
Post install script to make node_modules IE compatible again
const fs = require('fs');
const getModules = projectDir =>
fs
.readdirSync(`${projectDir}/node_modules`)
.map(ns => {
if (ns[0] === '@') {
return fs
.readdirSync(`${projectDir}/node_modules/${ns}`)
.map(name => `${projectDir}/node_modules/${ns}/${name}/package.json`);
@smeijer
smeijer / transpile-3.js
Created August 2, 2019 17:27
medium-costs-of-optional-chaining-6
var can = user && user.can || {};
var canEdit = can.edit;
var canDelete = can.delete;
// transpiles to:
"use strict";
var can = (user && user.can) || {};
var canEdit = can.edit;
var canDelete = can.delete;
@smeijer
smeijer / transpile-2.js
Created August 2, 2019 17:27
medium-costs-of-optional-chaining-5
var can = user?.can || {};
var canEdit = can.edit;
var canDelete = can.delete;
// transpiles to:
"use strict";
var _user;
var can =
@smeijer
smeijer / transpile-1.js
Created August 2, 2019 17:26
medium-costs-of-optional-chaining-4
var canEdit = user?.can?.edit;
var canDelete = user?.can?.delete;
// transpiles to:
"use strict";
var _user, _user$can, _user2, _user2$can;
var canEdit =
(_user = user) === null || _user === void 0