Skip to content

Instantly share code, notes, and snippets.

View professor-oats's full-sized avatar
💀
Focusing

professor-oats professor-oats

💀
Focusing
View GitHub Profile
@JamieMason
JamieMason / pipe.ts
Created May 9, 2024 14:08
TypeScript pipe function
/**
* Takes a value and passes it through a sequence of functions in left-to-right order.
*
* A Function that takes an initial value of any type (`unknown`), followed by any number of functions as arguments. It
* returns the result of passing the initial value through each of the functions, one by one, in the order that they
* were passed in. It provides a way to easily chain together multiple functions in a pipeline, where the output of each
* function becomes the input for the next one.
*
* ## Example
*
@JamieMason
JamieMason / find-nested-dependencies.md
Created March 2, 2022 12:49
Find all modules which a given JavaScript module depends on, and all they modules they depend on, and all they modules they depend on etc.

Find nested dependencies or imports of a JavaScript Module

Find all deep/nested/recursive/descendant dependencies/imports/requires of a JavaScript Module.

Related to sverweij/dependency-cruiser#564, find all modules which a given JavaScript module depends on, and all the modules they depend on, and all the modules they depend on etc.

Installation

npm install -g ts-node
@JamieMason
JamieMason / remove-comments-between-imports.js
Last active October 31, 2026 18:51
Remove single line javascript comments between ES module import statements
const fs = require('fs')
const globby = require('globby')
globby
.sync(
['**/*.js', '!node_modules', '!.next', '!**/*.spec.js', '!**/*.test.js', '!**/integration/**'],
{
absolute: true,
},
)
.map((file) => {
@JamieMason
JamieMason / getServerSideProps-leak.js
Created February 16, 2021 10:26
TODO getServerSideProps leaking server deps into client bundle
import type { GetServerSideProps, NextPage } from 'next';
import Head from 'next/head';
import React from 'react';
import { SearchPageComponent } from './search-page-component';
import type { Props } from './search-page-props';
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
try {
if (typeof window === 'undefined') {
const { getSearchPageProps } = await import('./search-page-props');
@JamieMason
JamieMason / tailwind.config.js.md
Created November 30, 2020 11:55
A helper function to adjust every TailwindCSS font-size by a relative amount.

Adjust Default Tailwind CSS Font Sizes

A helper function to adjust every TailwindCSS font-size by a relative amount.

const defaultTheme = require('tailwindcss/defaultTheme');

const adjustFontSizes = (adjustFontSizeBy) => {
  const getAdjustedSize = (sizeName) => {
    const [fontSizeRem, { lineHeight: lineHeightRem }] = defaultTheme.fontSize[sizeName];
@JamieMason
JamieMason / zondicons.sh
Created October 22, 2020 17:54
Convert Zondicons to TypeScript React Components (~80%, still some small manual cleanup to do)
#!/usr/bin/env bash
echo "export const AddOutline: React.FC<{ className?: string }> = ({ className }) => $(cat "./add-outline.svg")" > "./add-outline.tsx"
echo "export const AddSolid: React.FC<{ className?: string }> = ({ className }) => $(cat "./add-solid.svg")" > "./add-solid.tsx"
echo "export const Adjust: React.FC<{ className?: string }> = ({ className }) => $(cat "./adjust.svg")" > "./adjust.tsx"
echo "export const Airplane: React.FC<{ className?: string }> = ({ className }) => $(cat "./airplane.svg")" > "./airplane.tsx"
echo "export const Album: React.FC<{ className?: string }> = ({ className }) => $(cat "./album.svg")" > "./album.tsx"
echo "export const AlignCenter: React.FC<{ className?: string }> = ({ className }) => $(cat "./align-center.svg")" > "./align-center.tsx"
echo "export const AlignJustified: React.FC<{ className?: string }> = ({ className }) => $(cat "./align-justified.svg")" > "./align-justified.tsx"
echo "export const AlignLeft: React.FC<{ className?: string }> = ({ className }) => $(ca
@JamieMason
JamieMason / html-languages.txt
Created September 19, 2012 08:50
HTML lang attribute / ISO language code reference / Culture names
CULTURE SPEC.CULTURE ENGLISH NAME
--------------------------------------------------------------
Invariant Language (Invariant Country)
af af-ZA Afrikaans
af-ZA af-ZA Afrikaans (South Africa)
ar ar-SA Arabic
ar-AE ar-AE Arabic (U.A.E.)
ar-BH ar-BH Arabic (Bahrain)
ar-DZ ar-DZ Arabic (Algeria)
ar-EG ar-EG Arabic (Egypt)