Skip to content

Instantly share code, notes, and snippets.

View elbakerino's full-sized avatar

Michael Becker elbakerino

View GitHub Profile
@elbakerino
elbakerino / exports.md
Last active November 22, 2024 15:33
ESM Package Exports

ESM, CJS and moduleResolution

main, module, types, exports

In a package.json, some fields define where to find what.

  • main is the main entry point in CJS; or for type: "module" packages to ESM
  • module is only used by bundlers to resolve ESM, for tree-shaking for CJS+ESM packages, not by Node.js
  • types is only used by TS to resolve types
  • exports is only used by modern Node.js, if a package is type: "module"; patterns are only supported since v14.13.0, v12.20.0

Inspired by the emojis for release notes, these here are intended to give comments a better reading guidance, especially for documentations and walk-throughs.

Meaning Emoji
check here/next 👉
read more/in-depth 🎵
feature with high potential/hidden gem 💎

...

@elbakerino
elbakerino / semantic-emoji-release.md
Last active September 1, 2022 06:08
semantic-emoji-release
@elbakerino
elbakerino / tabs-group.js
Last active June 21, 2022 10:56
Example JS for the Formanta/Sass tabs component
const calcTabHeight = (tab) => {
// todo: find a better way to get the correct height size of tab + tab content
const tabContentHeight = Array.from(tab.children).reduce((height, child) => {
const styles = window.getComputedStyle(child);
const styleGutter = parseFloat(styles.getPropertyValue('margin-top')) +
parseFloat(styles.getPropertyValue('margin-bottom'));
return height + child.getBoundingClientRect().height + styleGutter;
}, 0);
const styles = window.getComputedStyle(tab);
const styleGutter = parseFloat(styles.getPropertyValue('padding-top')) +
@elbakerino
elbakerino / collapse.js
Last active June 14, 2022 16:31
collapse.js
/*
* Simple vanilla JS height collapsible.
* For HTML with a [data-toggle] and a `.collapse` as next neighbor:,
* License: by github.com/elbakerino 2022, WTFPL https://en.wikipedia.org/wiki/WTFPL
* <ul>
* <li>
* <button data-toggle="on">Toggle 1</button>
* <div class="collapse closed">
* <div>
* <h2>Item 1</h2>
@elbakerino
elbakerino / CustomValidator.js
Last active May 7, 2020 20:43
UI-Schema Custom Validator Scribble
import {NextPluginRenderer} from "@ui-schema/ui-schema/EditorPluginStack";
// this is a normal plugin, as we need to access the hook and this is not possible from wihin validatorPlugins
const CustomValidator = ({errors, valid, ...props}) => {
let {storeKeys} = props;
const {store} = useSchemaStore();
// should the internals store be used/compatible for this, maybe the internals store needs another structure
const errorForWidget = store.getInternals() ? store.getInternals().getIn(storeKeys.push('server-validation')) : null;
if(errorForWidget) {
@elbakerino
elbakerino / op-status.php
Created December 1, 2019 19:13
PHP OpCache Status Script
#!/usr/bin/env php
<?php
/**
* Prints a nice op cache status in the PHP CLI, for that `opcache.enable_cli = 1` must be set in your opcache ini
* Simply run it with: php op-status.php
*
* LICENSE: MIT
*
* @author Michael Becker, https://mlbr.xyz