Skip to content

Instantly share code, notes, and snippets.

@kanrong
kanrong / Promise.filter.js
Created September 4, 2024 06:28 — forked from yongjun21/Promise.filter.js
Complete implementation of Promise.filter
Promise.filter = function (iterable, filterer, options = {}) {
let concurrency = options.concurrency || Infinity
let index = 0
const results = []
const predicates = []
const pending = []
const iterator = iterable[Symbol.iterator]()
while (concurrency-- > 0) {
@kanrong
kanrong / Promise.map.js
Created September 4, 2024 06:28 — forked from yongjun21/Promise.map.js
Complete implementation of Promise.map
Promise.map = function (iterable, mapper, options = {}) {
let concurrency = options.concurrency || Infinity
let index = 0
const results = []
const pending = []
const iterator = iterable[Symbol.iterator]()
while (concurrency-- > 0) {
const thread = wrappedMapper()
@kanrong
kanrong / read-access.sql
Created August 28, 2024 03:34 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;