Any TILs from your package managers library recently?

lukeocodes profile image Luke Oliff ・1 min read

I want to hear about any absolute GEMS (ruby devs need not smirk) from your package manager libraries.

Today, I found THESE! (not just one!)


GitHub logo fent / randexp.js

Create random strings that match a given regular expression.


randexp will generate a random string that matches a given RegExp Javascript object.

Dependency Status codecov


const RandExp = require('randexp')
// supports grouping and piping
new RandExp(/hello+ (world|to you)/).gen()
// => hellooooooooooooooooooo world
// sets and ranges and references
new RandExp(/<([a-z]\w{0,20})>foo<\1>/).gen()
// => <m5xhdg>foo<m5xhdg>

// wildcard
new RandExp(/random stuff: .+/).gen();
// => random stuff: l3m;Hf9XYbI [YPaxV>U*4-_F!WXQh9>;rH3i l!8.zoh?[utt1OWFQrE ^~8zEQm]~tK

// ignore case
new RandExp(/xxx xtreme dragon warrior xxx/i).gen();
// => xxx xtReME dRAGON warRiOR xXX

// dynamic regexp shortcut
new RandExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i');
// is the same as
new RandExp(new RegExp('(sun|mon|tue|wednes|thurs|fri|satur)day', '

I'm writing a Slack bot that reacts to a word in a message. It listens for a message and matches it with a regex, responding appropriately.

This library will allow me to write tests that match, without hard coding a message.


GitHub logo bubenshchykov / ngrok

Expose your localhost to the web. Node wrapper for ngrok.

ngrok Build Status TypeScript compatible npm npm

alt ngrok.com


npm install ngrok
const ngrok = require('ngrok')
(async function() {
  const url = await ngrok.connect()


npm install ngrok -g
ngrok http 8080

This module uses node>=8.3.0 with async-await. For callback-based version use 2.3.0

For global install on Linux, you might need to run sudo npm install --unsafe-perm -g ngrok due to the nature of npm postinstall script.


You can create basic http-https-tcp tunnel without authtoken. For custom subdomains and more you should obtain authtoken by signing up at ngrok.com. Once you set it, it's stored in ngrok config and used for all tunnels. Few ways:

await ngrok.authtoken(token)
await ngrok.connect({authtoken: token, ...});


const url = await ngrok.connect(); // https://757c1652.ngrok.io -> http://localhost:80
const url = await ngrok.connect(9090); //

Ngrok's npm package can be run as a module! I was so amazed I wrote it up as a little hello-world guide this morning.

So did you stumble upon any neat code this week?


markdown guide