Skip to content

Instantly share code, notes, and snippets.

View karfau's full-sized avatar
🎯
Focusing

Christian Bewernitz karfau

🎯
Focusing
  • bettermarks GmbH
  • Saxony / Germany
  • 16:44 (UTC +02:00)
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active September 20, 2024 14:02
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.
@karfau
karfau / nvm-install
Last active August 15, 2024 11:10
A script that can be sourced in shell scripts to enable nvm support
# shellcheck shell=sh
# https://gist.github.com/karfau/dcf98c6eefc2f2132c160f5c14d2112f
# v2024.8.15
# needs to be sourced as part of your script
# 1. tries to configure nvm and run `nvm install`
# 2. checks if the node version is correct based on ./.nvmrc
# if both doesn't work, exits with code 1 and some helpful messages
# Sometimes we prefer `nvm use` over `nvm install`
@nolanlawson
nolanlawson / protips.js
Last active August 22, 2024 14:19
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@blackfalcon
blackfalcon / git-feature-workflow.md
Last active August 15, 2024 15:16
Git basics - a general workflow

Git-workflow vs feature branching

When working with Git, there are two prevailing workflows are Git workflow and feature branches. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited, and the focus of this article.

If you are new to Git and Git-workflows, I suggest reading the atlassian.com Git Workflow article in addition to this as there is more detail there than presented here.

I admit, using Bash in the command line with the standard configuration leaves a bit to be desired when it comes to awareness of state. A tool that I suggest using follows these instructions on setting up GIT Bash autocompletion. This tool will assist you to better visualize the state of a branc

@gavJackson
gavJackson / AbstractCommand.js
Created October 23, 2012 15:12
Robotlegs inspired classes with Agility.js
/**
* Created by IntelliJ IDEA.
* User: Digital Keystone (gavin.jackson)
* User: gavin.jackson
* Date: 06/03/12
* Time: 11:24
*/
/**
* Class: AbstractCommand
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
# Start a new chapter by branching the current branch off:
(branch chapter5)$ git checkout -b chapter6
# Make some commits:
(branch chapter6)$ git commit
(branch chapter6)$ git commit
# Oh noez, chapter 3 needs a bugfix
(branch chapter6)$ git checkout chapter3
(branch chapter3)$ git commit -m "Bugfix"