Skip to content

Instantly share code, notes, and snippets.

View Oluwasetemi's full-sized avatar
🏠
Working from home

Oluwasetemi Ojo Oluwasetemi

🏠
Working from home
View GitHub Profile
// Run this command to generate base config and vs code settings:
// pnpm dlx @antfu/eslint-config@latest
import antfu from "@antfu/eslint-config";
export default antfu({
type: "app",
typescript: true,
formatters: true,
stylistic: {
/* eslint-disable node/no-process-env */
import type { ZodObject, ZodRawShape } from "zod";
import { ZodError } from "zod";
export default function tryParseEnv<T extends ZodRawShape>(
EnvSchema: ZodObject<T>,
buildEnv: Record<string, string | undefined> = process.env,
) {
try {
@Oluwasetemi
Oluwasetemi / absolute-import-codemod-transform.js
Created July 28, 2024 22:16 — forked from phenax/absolute-import-codemod-transform.js
Codemod transform to convert all relative paths to absolute import paths inside src
const path = require('path');
const SOURCE = 'src';
const SOURCE_PATH = path.resolve(SOURCE) + '/';
const removeSourceDirName = path =>
path.replace(new RegExp(`^${SOURCE}\/?`, 'gi'), '');
@Oluwasetemi
Oluwasetemi / useTheme2.tsx
Created September 20, 2021 13:08 — forked from timc1/useTheme2.tsx
🌑☀️core app system/light/dark mode theming + varying themes for nested components
import * as React from "react";
type ThemeConfig = "system" | "light" | "dark";
type ThemeName = "light" | "dark";
// Custom themes are keyed by a unique id.
type KeyedThemes = {
[k: string]: {
config: ThemeConfig;
themeName: ThemeName;
};
@Oluwasetemi
Oluwasetemi / useTheme.tsx
Created September 20, 2021 13:08 — forked from timc1/useTheme.tsx
🌑☀️mode theming hook
import * as React from "react";
type Theme = "system" | "light" | "dark";
const STORAGE_KEY = "theme";
const VALID_THEMES: Theme[] = ["system", "light", "dark"];
const DARK_MODE_MEDIA_QUERY = "(prefers-color-scheme: dark)";
function getAppTheme(): Theme {
if (typeof window !== "undefined") {
@Oluwasetemi
Oluwasetemi / package.json
Last active March 4, 2021 10:48 — forked from kentcdodds/package.json
Validates that the versions of tools specified in `engines` in the package.json are installed on the machine.
{
"name": "workshop-computer-validator",
"version": "1.0.0",
"description": "I use this to validate people's computers have the proper versions of node and npm installed for a workshop",
"bin": "./validate-system.js",
"dependencies": {
"semver": "7.1.3"
}
}
import React, { Suspense, useState } from "react";
import { unstable_createResource as createResource } from "react-cache";
import {
Combobox,
ComboboxInput,
ComboboxList,
ComboboxOption
} from "./Combobox2.js";
function App({ tabIndex, navigate }) {
@Oluwasetemi
Oluwasetemi / vscode-italics.json
Created May 30, 2018 03:33
VSCode italics in (almost) any theme
// All you need to do is add a font that has pretty good itlaics support i.e Fira, Operator, etc. and then add these two params to your existing User settings.
// Tested in Monokai Sharp and Super One Dark
{
"editor.fontFamily": "'Operator Mono', Menlo, Monaco, 'Courier New', monospace",
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment",
@Oluwasetemi
Oluwasetemi / bling.js
Created April 28, 2018 07:20 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@Oluwasetemi
Oluwasetemi / compat-old.txt
Created February 3, 2018 14:28 — forked from Elchi3/compat-old.txt
English pages still using CompatibilityTable.ejs
Archive/<input>_archive
Web/API/AbstractWorker/onerror
Web/API/AmbientLightSensor/AmbientLightSensor
Web/API/AmbientLightSensor/reading
Web/API/AmbientLightSensorReading
Web/API/AmbientLightSensorReading/AmbientLightSensorReading
Web/API/AmbientLightSensorReading/illuminance
Web/API/Animation
Web/API/Animation/Animation
Web/API/Animation/cancel