Skip to content

Instantly share code, notes, and snippets.

View stefcameron's full-sized avatar

Stefan Cameron stefcameron

View GitHub Profile
@stefcameron
stefcameron / gh-dependabot-prs
Last active April 4, 2024 20:28
Auto-merge Dependabot PRs
#!/bin/bash
##
## Lists and optionally merges only Dependabot PRs in a given GitHub repo.
##
## Published at: https://gist.github.com/stefcameron/527108410e01dadd58aad81232366902
##
## Version history:
##
## - 2024/04/04+1527: Update show_help() to use easier syntax.
@stefcameron
stefcameron / everyPromise.js
Created November 10, 2020 19:04
A promise that (always) resolves only once ALL given promises have resolved or rejected (requires ES6)
/**
* [ASYNC] Waits for every promise to either resolve or reject, which is different
* from `Promise.all()` which rejects on the first rejection __without waiting
* for other promises to settle__.
* @param {Array<Promise>} promises
* @returns {Promise<{ results: Array, errors: Array}>} An object where `results`
* are the settled values of all resolved promises, in the order in which they
* appeared in `promises` (but not necessarily sequential if there were rejections),
* and `errors` are the settled values of all rejected promises, in the order
* in which they appeared in `promises` (again, not necessarily sequential).
@stefcameron
stefcameron / copyToClipboard.js
Last active November 10, 2020 19:09
Copy text to clipboard
/**
* Copy the specified string to the clipboard.
* @param {string} text The text to copy.
* @returns {boolean} `true` if the copy succeeded; `false` if an
* error occurred copying the text to the clipboard.
*/
export const copyToClipboard = (text) => {
try {
// NOTE: a field is required to execute the document's 'copy' command;
// make sure the first appears offscreen without affecting layout