Skip to content

Instantly share code, notes, and snippets.

View kripod's full-sized avatar

Kristóf Poduszló kripod

View GitHub Profile
import type * as Prisma from "@prisma/client";
import { createHash, randomBytes } from "crypto";
import type { Adapter } from "next-auth/adapters";
import {
CreateSessionError,
CreateUserError,
CreateVerificationRequestError,
DeleteSessionError,
DeleteUserError,
DeleteVerificationRequestError,
@kripod
kripod / next-google-fonts-loader.tsx
Last active December 15, 2020 09:22
Google Fonts loader for Next.js
/* TODO: Abstract this module away into a separate npm package */
/*
* References:
* - https://developers.google.com/fonts/docs/css2
* - https://github.com/google/fonts/tree/master/axisregistry
*/
import Head from "next/head";
@kripod
kripod / tailwind.config.js
Created September 9, 2020 19:28
tailwind.config.js with flex gap utilities, no animations+preflight and future compatibility for v1.8+
const plugin = require("tailwindcss/plugin");
function half(value) {
return value.replace(/\d+(.\d+)?/, (number) => number / 2);
}
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
@kripod
kripod / cssPropertyPrefixesAndAlternativeNames.mjs
Last active September 1, 2020 22:02
Retrieve vendor prefixes and alternative names for every CSS property with Browserslist and mdn-browser-compat-data
import browserslist from "browserslist";
import compareVersions from "compare-versions";
import bcd from "mdn-browser-compat-data";
function normalizeVersion(version) {
return version.replace("≤", "");
}
const browsersByBrowserslistId = new Map([
/* Keys: https://github.com/browserslist/browserslist#browsers */
@kripod
kripod / alternativeCSSPropertiesByStandardName.js
Last active September 1, 2020 22:03
CSS – Properties with alternative names
/* Gathered from mdn-browser-compat-data using the default browserslist config */
export const alternativeCSSPropertiesByStandardName = [
"color-adjust": ["-webkit-print-color-adjust"],
"grid-auto-columns": ["-ms-grid-columns"],
"grid-auto-rows": ["-ms-grid-rows"],
"overflow-wrap": ["word-wrap"],
"scroll-margin-bottom": ["scroll-snap-margin-bottom"],
"scroll-margin-left": ["scroll-snap-margin-left"],
"scroll-margin-right": ["scroll-snap-margin-right"],
@kripod
kripod / modern-reset.css
Last active January 28, 2022 21:09
modern-reset.css
/**
* Based on the differences between UA sheets.
* Selectors are chunked in ordered groups for better compression (e.g. gzip).
*/
body,
p,
h1,
h2,
h3,
@kripod
kripod / package.json
Created May 6, 2020 10:30
Creating minified ESM+CJS bundles from TypeScript with Rollup and Babel in a monorepo, utilizing conditional exports
{
"name": "to-be-added",
"version": "0.0.0",
"sideEffects": false,
"exports": {
".": {
"import": "./dist-esm/bundle.min.mjs",
"require": "./dist-cjs/bundle.min.cjs"
},
"./server": "./server/index.js"
@kripod
kripod / css-in-js-logo.svg
Last active April 24, 2020 23:11
CSS in JS logo proposal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kripod
kripod / murmur2.ts
Last active February 20, 2020 22:58
MurmurHash2 in TypeScript
/* eslint-disable no-fallthrough */
// Inspired by: https://github.com/levitation/murmurhash-js
export default function murmur2(data: string, seed: number = 0): number {
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
// const m = 0x5bd1e995;
// const r = 24;
@kripod
kripod / imul.js
Last active February 19, 2020 16:06
Optimized Math.imul() for JavaScript
function imul2(x, yHi, yLo) {
return (((x * yHi) << 16) + x * y) | 0;
}
function imul(x, y) {
return imul2(x, (y >>> 16) & 0xffff, y & 0xffff);
}