Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active May 2, 2024 20:54
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.
@mourner
mourner / str-concat.js
Last active October 18, 2022 21:15
A benchmark that demonstrates something is wrong with v8's concatenation performance
const N = 1000000;
function simpleConcat() {
let str = '';
for (let i = 0; i < N; i++) {
str += 'a';
}
return str;
}
@qx133
qx133 / tryEthereum.js
Created April 30, 2017 14:18
Try out Ethereum using only nodejs and npm!
var Web3 = require('web3');
var util = require('ethereumjs-util');
var tx = require('ethereumjs-tx');
var lightwallet = require('eth-lightwallet');
var txutils = lightwallet.txutils;
var web3 = new Web3(
new Web3.providers.HttpProvider('https://rinkeby.infura.io/')
);
var address = '0x8D68583e625CAaE969fA9249502E105a21435EbF';
var key = '1ce642301e680f60227b9d8ffecad474f15155b6d8f8a2cb6bde8e85c8a4809a';
@carlfriess
carlfriess / subtitles.js
Created April 10, 2016 17:41
Node.js script to add a subtitles track to a mp4 from an srt file.
#!/usr/local/bin/node
const readline = require('readline');
var exec = require('child_process').exec;
var path = require('path');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 30, 2024 18:17
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@rjmacarthy
rjmacarthy / bitcoind-ubuntu-install
Last active April 30, 2024 19:45
Install Bitcoind Ubuntu
** Add repository and install bitcoind **
sudo apt-get install build-essential
sudo apt-get install libtool autotools-dev autoconf
sudo apt-get install libssl-dev
sudo apt-get install libboost-all-dev
sudo add-apt-repository ppa:luke-jr/bitcoincore
sudo apt-get update
sudo apt-get install bitcoind
mkdir ~/.bitcoin/ && cd ~/.bitcoin/
@jarvys
jarvys / run-multiple-redis-instances.md
Last active September 27, 2022 13:02
run multiple redis instances on the same server for centos
  • create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf
  • edit /etc/redis-xxx.conf, illustrated as below
...