Skip to content

Instantly share code, notes, and snippets.

View Lukas-Sachse's full-sized avatar

Lukas-Sachse

View GitHub Profile
@mauriciomassaia
mauriciomassaia / Inject cacertpem into Tinify.md
Created June 5, 2024 05:13
Postinstall script to inject cacert.pem into Tinify dependency

When our team tried to use tinify into a AWS Lambda function using Typescript the file node_modules/tinify/lib/data/cacert.pem wasn't copied properly so the transpiled code could not find it and Tinify would fail.

Thanks to @shannonhochkins and his postinstall idea to inject the value of cacert.pem into Client.js.

How to setup this script

  1. Create a scripts/ folder on your project.
  2. Create a file called tinify-inject-cacertpem.js inside the scripts/ folder.
@atinux
atinux / async-foreach.js
Last active April 2, 2025 11:34
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)