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
@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 — forked from dev01d/vscode-italics.json
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
@Oluwasetemi
Oluwasetemi / bytesToSize.js
Created March 12, 2017 09:23 — forked from lanqy/bytesToSize.js
JavaScript To Convert Bytes To MB, KB, Etc
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
@Oluwasetemi
Oluwasetemi / recursion.js
Created November 14, 2016 03:00 — forked from bendc/recursion.js
Functional loop
const loop = (() => {
const recur = (callback, count, i=0) => {
if (i == count-1) return callback(i);
callback(i);
return recur(callback, count, i+1);
};
return (callback, count) => {
if (count > 0) return recur(callback, count);
};
})();
@Oluwasetemi
Oluwasetemi / .gitignore
Created October 16, 2016 23:21 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #