Skip to content

Instantly share code, notes, and snippets.

View Steellgold's full-sized avatar
🍓

Gaëtan H Steellgold

🍓
View GitHub Profile
@Steellgold
Steellgold / color.ts
Created November 26, 2023 15:37
Your text need to be dark or white?
const textIsWhite = (color: string): boolean => {
const hex = color.replace("#", "");
const c_r = parseInt(hex.slice(0, 2), 16);
const c_g = parseInt(hex.slice(2, 4), 16);
const c_b = parseInt(hex.slice(4, 6), 16);
const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
return brightness < 155;
};
@nandorojo
nandorojo / private-npm-in-gh-actions.md
Created August 3, 2021 23:52
Use private NPM packages in your GitHub actions

1 NPM_TOKEN

Add an NPM_TOKEN secret on GitHub. Get your secret key from the NPM dashboard.

2 Add a step to your action

- name: Authenticate with private NPM package
  run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
@sindresorhus
sindresorhus / esm-package.md
Last active May 20, 2024 14:52
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@maxim
maxim / gh-dl-release
Last active May 21, 2024 05:55
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#