Skip to content

Instantly share code, notes, and snippets.

@intrnl
intrnl / css-in-js.ts
Last active September 12, 2023 08:10
let uid = 0;
let inserted = false;
const stylesheet = /*#__PURE__*/ new CSSStyleSheet();
const build = (bake: (name: string, body: string) => string) => {
if (import.meta.env.DEV) {
const seen = new WeakSet<TemplateStringsArray>();
const cache = new Map<number, string>();
@intrnl
intrnl / bad_domains.txt
Last active September 4, 2023 12:05
Mobile ad/tracker domains, from mobile apps, or sites with domains that weren't caught by browser extensions
trinitymedia.ai
a.vdo.ai
tru.am
ad.leap.app
netlify-rum.netlify.app
cdn.permutive.app
0f73e92f-4074-4fe3-85d3-ed3fc969859e.edge.permutive.app
6093eccf-6734-4877-ac8b-83d6d0e27b46.edge.permutive.app
68547f8f-2fd8-4ff3-9b63-51e86e2edee8.edge.permutive.app
a2a5c7f9-3fa0-4182-889a-15aa61acf59b.edge.permutive.app
@intrnl
intrnl / mangle.ts
Created August 12, 2023 17:23
Mangle all TS interface fields with a directive
// TODO: make sure this doesn't run if `git diff --stat HEAD -- src/` actually returns something
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import { type PropertySignature, InterfaceDeclaration, Project, SyntaxKind } from 'ts-morph';
import { ShortIdent } from '../lib/mangler/shortident.js';
const root = path.join(fileURLToPath(import.meta.url), '../..');
@intrnl
intrnl / bluesky-delete-all-post.ts
Last active August 6, 2023 08:11
script to delete all posts from a Bluesky account
import { Agent } from '@intrnl/bluesky-client/agent';
import type { UnionOf } from '@intrnl/bluesky-client/atp-schema';
import { pRateLimit } from 'p-ratelimit';
const agent = new Agent({ serviceUri: 'https://bsky.social' });
const limit = pRateLimit({ concurrency: 3, interval: 1000, rate: 5 });
const getRecordId = (uri: string) => {
const idx = uri.lastIndexOf('/');
@intrnl
intrnl / solid-navigation-resource.ts
Created July 8, 2023 02:22
Solid.js cached resource tied to the navigation entry
/// <reference types="navigation-api-types" />
import {
type ResourceFetcher,
type ResourceReturn,
type ResourceSource,
createResource,
onCleanup,
} from 'solid-js';
@intrnl
intrnl / stringReplaceAsync.js
Last active June 3, 2023 23:33
Asynchronous string replace
function stringReplaceAsync (string, regex, replacer) {
if (!regex.global) {
const match = regex.exec(string)
if (!match) return string
const retVal = replacer(...match, match.index, string)
if (retVal instanceof Promise) {
return retVal.then((ret) => (
string.slice(0, match.index) +
[intrnl@azalea react-app]$ rm -rf node_modules/ oro-cache/
[intrnl@azalea react-app]$ ../../orogene-v0.3.6-x86_64-unknown-linux-gnu/oro restore --cache oro-cache --loglevel info
2023-03-07T08:52:19.766842Z INFO orogene: Running command: Restore(
RestoreCmd {
registry: Some(
Url {
scheme: "https",
cannot_be_a_base: false,
username: "",
password: None,
import { is_function } from './utils.js';
let undefined;
let RUNNING = 1 << 0;
let NOTIFIED = 1 << 1;
let OUTDATED = 1 << 2;
let DISPOSED = 1 << 3;
let HAS_ERROR = 1 << 4;
let TRACKING = 1 << 5;
import * as acorn from 'acorn';
import { walk } from 'estree-walker';
import MagicString from 'magic-string';
import { analyze } from 'periscopic';
const debuggableConfig = {
'@vanilla-extract/css': {
style: {
maxParams: 2,
@intrnl
intrnl / apollo-hasura-migration.js
Last active February 22, 2023 12:03
Hasura v2 migration package for Apollo Client
// NOTE: Hasura v1 to Hasura v2 conversion
/* eslint-disable import/export */
import {
useQuery as useApolloQuery,
useSubscription as useApolloSubscription,
} from '@apollo/react-hooks-unpatched'
import gql from 'graphql-tag'
export * from '@apollo/react-hooks-unpatched'