Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active April 7, 2025 16:23
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.
@mort3za
mort3za / git-auto-sign-commits.sh
Last active February 5, 2025 18:58
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
@ValentinBlokhin
ValentinBlokhin / rc-producer.yml
Created August 2, 2017 10:32
Gives opportunity to easily start debug ava tests using chrome in webstorm. https://github.com/avajs/ava/blob/master/docs/recipes/debugging-with-chrome-devtools.md
# The list or single options object
# The applicable file patterns. Required. Single (not list) pattern maybe specified.
files: ["**/Tests/**/*", "**/*.spec.*", "**/*.test.*", "!**/node_modules/**/*"]
# The script to run. Defaults to current file.
script: "/usr/local/bin/inspect"
# The script args. Next macros are supported:
# ${file} — current file,
# ${fileNameWithoutExt} — current file name without extension,
@lll000111
lll000111 / async-errors-with-stack-demo.js
Last active July 4, 2019 20:42
How to get stacktraces from errors from asynchronous functions (node.js and all browsers - simple)
// @flow
'use strict';
// Needed to create a _really_ asynchronous function. A fake asynchronous function (returning
// "Promise.reject()" right away, for example) actually creates a stacktrace.
const wait = delay => new Promise(resolve => setTimeout(() => resolve(), delay));
// Some deeply nested (in the actual call hierarchy) asynchronous function that throws an error.
const fnError = async () => {
await wait(1);
@konfou
konfou / mkvextract-helper.sh
Last active January 2, 2025 20:50
extract all tracks/attachments/chapters from an mkv file
#!/usr/bin/env bash
#
# Extract all tracks/attachments/chapters from an mkv file.
# depends
type -p mkvmerge &>/dev/null || exit 3
type -p mkvextract &>/dev/null || exit 3
# trap SIGINT
trap 'trap - INT; kill -s INT "$$"' INT

Shipit Deploy

Shipit is a pretty awesome universal automation and deployment tool written in JavaScript.

Setup your server

(this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g pm2

Install shipit

  • npm install -g shipit-cli
@jonathansimmons
jonathansimmons / base16.css
Last active February 3, 2020 08:36
Base 16 Ocean Dark Slack Theme
/* Not perfect but looks good considering slack limitations */
#2B2F3A,#1F232C,#1F232C,#DFE1E8,#4F5C65,#90A2B2,#A1C088,#C36069
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active December 23, 2024 19:57
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@ThomasArdal
ThomasArdal / Customer.cs
Created June 12, 2014 18:33
Elasticsearch migration c# example
namespace ConsoleApplication1
{
public class Customer
{
public int Zipcode { get; set; }
}
}