Skip to content

Instantly share code, notes, and snippets.

View navin-moorthy's full-sized avatar
💻
Focused

Navin Moorthy navin-moorthy

💻
Focused
View GitHub Profile
@navin-moorthy
navin-moorthy / generate-tailwind-properties.js
Last active December 30, 2020 12:19
Generate Tailwind Properties
#!/usr/bin/env node
// With the help of https://gist.github.com/kentcdodds/bb452ffe53a5caa3600197e1d8005733
// Thanks Kent C. Dodds
const spawnSync = require("child_process").spawnSync;
const styles = {
// got these from playing around with what I found from:
// https://github.com/istanbuljs/istanbuljs/blob/0f328fd0896417ccb2085f4b7888dd8e167ba3fa/packages/istanbul-lib-report/lib/file-writer.js#L84-L96
@navin-moorthy
navin-moorthy / tailwindcss+2.2.7.patch
Created August 4, 2021 11:48
Tailwind JIT - Prepend stackable variant before DEFAULT utilities
diff --git a/node_modules/tailwindcss/lib/jit/lib/generateRules.js b/node_modules/tailwindcss/lib/jit/lib/generateRules.js
index 9b59423..c2f8660 100644
--- a/node_modules/tailwindcss/lib/jit/lib/generateRules.js
+++ b/node_modules/tailwindcss/lib/jit/lib/generateRules.js
-function applyVariant(variant, matches, context) {
+function applyVariant(variant, matches, hasLibVariant, context) {
if (matches.length === 0) {
return matches;
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"orta.vscode-jest",
"tlent.jest-snapshot-language-support",
"vespa-dev-works.jestrunit",
"vivaxy.vscode-conventional-commits",
"bradlc.vscode-tailwindcss",
"aaron-bond.better-comments",
echo "words" | sed '/^words/,$!d'
sed '/^words/,$!d' input.txt > output.txt
# https://markoskon.com/creating-font-subsets/#minimal-english-subset
pyftsubset\
Inter.var.woff2 \
--output-file="Inter.var-english.woff2" \
--flavor=woff2 \
--layout-features="kern,liga,clig,calt,ccmp,locl,mark,mkmk,\
onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,\
cswh,dlig,ss01,ss03,zero"\
--unicodes="U+0000-00A0,U+00A2-00A9,U+00AC-00AE,U+00B0-00B7,\
U+00B9-00BA,U+00BC-00BE,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,\
@navin-moorthy
navin-moorthy / settings.json
Created June 10, 2022 14:35
Tailwind Intellisense for twrnc
{
// Add the below code to vscode user settings.json
"tailwindCSS.experimental.classRegex": [
["tailwind.style\\(([^)]*)\\)", "\"([^\"]*)\""],
["tailwind.getColor\\(([^)]*)\\)", "\"([^\"]*)\""],
],
"tailwindCSS.experimental.configFile": "your/path/to/tailwind.config.js",
}
@navin-moorthy
navin-moorthy / KeysOfValue.ts
Last active June 27, 2023 07:12
Typescript Utils
export type KeysOfValue<T, TCondition = string> = {
[K in keyof T]: T[K] extends TCondition ? K : never;
}[keyof T];
@navin-moorthy
navin-moorthy / downloadAllImages.js
Last active July 6, 2023 07:13
Site Boost Utils
// https://www.smashingmagazine.com/2023/06/popular-devtools-tips/#5-download-all-images-on-the-page
$$("img").forEach(async (img) => {
try {
const src = img.src;
// Fetch the image as a blob.
const fetchResponse = await fetch(src);
const blob = await fetchResponse.blob();
const mimeType = blob.type;
// Figure out a name for it from the src and the mime-type.
import { getErrorMessage } from "./getErrorMessage.js";
/**
* Adds additional error message to the existing error message.
* @param {unknown} error - The error object.
* @param {string} errorMessage - The additional error message to be added.
* @returns {string} - The updated error message.
*/
export function addAdditionalErrorMessage(
error: unknown,
import { isNonNullable } from "isNonNullable";
export type GetFinalLogoSizeProps = { width: number; height: number; maxHeight: number; maxWidth: number };
export const getFinalLogoSize = ({ width, height, maxHeight, maxWidth }: GetFinalLogoSizeProps) => {
if (isNonNullable(maxHeight) && !isNonNullable(maxWidth)) {
return {
width: Math.floor(width * (maxHeight / height)),
height: maxHeight,
};