Skip to content

Instantly share code, notes, and snippets.

View dheniges's full-sized avatar

Dirk Heniges dheniges

View GitHub Profile
@dheniges
dheniges / asyncPool.ts
Created February 14, 2024 23:47
A small node.js module to allow concurrent processing of any AsyncIterator via AsyncGenerator
import { randomUUID } from 'crypto'
// A concurrency-limited pool of promises generated from any async iterable compatible feed.
// A processor function is required to take the result of the async iteration and return a value.
// Processor func can be async
//
// Will only run [concurrency] operations at once
// The pool will fill as fast as the async iteration function can provide values, up to the max concurrency
export default async function* asyncPool(concurrency: number, itemFeed: AsyncIterable<any>, iteratorFn: (...args : any[]) => any) {
const promiseMap = new Map()
@dheniges
dheniges / slack_delete.rb
Created June 5, 2018 23:09 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@dheniges
dheniges / strategy.js
Last active August 29, 2015 14:09 — forked from jcontonio/strategy.js
// Web server does this, hits an endpoint
// { type: 'saml', strategy: company.strategy }
var company = Company.findByDomain(__domain);
if (company) {
var strategy = company.strategy;
}