Skip to content

Instantly share code, notes, and snippets.

View vasco-santos's full-sized avatar
🥁

Vasco Santos vasco-santos

🥁
View GitHub Profile
@developersharif
developersharif / LCG.js
Created May 2, 2023 10:55
The code provides a simple implementation of the Linear Congruential Generator (LCG) algorithm in JavaScript. LCG is a type of pseudo-random number generator that produces a sequence of numbers that appear to be random but are actually determined by a mathematical formula. The algorithm takes a seed value as input and generates a sequence of pse…
class LCG {
constructor() {
this.seed = Date.now();
this.a = 1664525;
this.c = 1013904223;
this.m = Math.pow(2, 32);
}
nextInt() {
this.seed = (this.a * this.seed + this.c) % this.m;
@sindresorhus
sindresorhus / esm-package.md
Last active September 1, 2026 12:44
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.
@alanshaw
alanshaw / streaming-iterables.md
Last active July 16, 2026 15:49
Streaming iterables WAT?

Streaming iterables

Your friends from pull stream, but in terms of async iterators.

source it

A "source" is something that can be consumed. It is an iterable object.

const ints = {
@jacobheun
jacobheun / libp2p-badges.md
Last active April 14, 2019 14:45
Generate badges

A crude script for generating libp2p repo badges.

./badges.js <project> # where project is the name of the repo in the libp2p org

badges.js

#!/usr/bin/env node
@harrishancock
harrishancock / streaming-responses-200.js
Created March 1, 2018 18:48
Cloudflare Workers streaming response bodies example with unconditional 200
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
/**
* Make multiple requests,
* aggregate the responses and
* stream it back as a single response.
*/
async function fetchAndApply(request) {
@jimothyGator
jimothyGator / README.md
Last active August 8, 2026 00:54
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@wdjunaidi
wdjunaidi / gist:1762114
Created February 7, 2012 21:27
curl - passing arrays and file as multipart/form-data
curl -vX POST <url> -F <arraykey>[0]=<value0> -F <arraykey>[1]=<value1> -F <arraykey>[2]=<value2> -F <key>=@<filename>