Skip to content

Instantly share code, notes, and snippets.

View Justin-Credible's full-sized avatar

Justin Unterreiner Justin-Credible

View GitHub Profile
-- Variable Declarations --
set title to "Chrome Development Launcher"
set startScript to "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --user-data-dir=/Users/$USER/Library/Application\\ Support/Google/ChromeDev"
set args to "--user-data-dir=/Users/$USER/Library/Application\\ Support/Google/ChromeDev --args --ignore-certificate-errors --disable-web-security --use-spdy=off --remote-debugging-port=9222"
set endScript to "> /dev/null 2>&1 &"
@Justin-Credible
Justin-Credible / braintree-web.d.ts
Created June 28, 2017 17:03
TypeScript definitions for the Braintree Web SDK (version 2.22.2)
/**
* Types for Braintree's Client SDK for Web.
*
* https://github.com/braintree/braintree-web
*/
declare namespace BraintreeClientWeb {
interface BraintreeClientWebStatic {
api: API;
@Justin-Credible
Justin-Credible / capacitor.d.ts
Last active July 29, 2020 18:45
TypeScript definitions for Capacitor, adapted for use in projects that use the namespace ("internal modules") convention.
/**
* TypeScript type definitions for Capacitor, adapted from the ones included
* in the @capacitor/core package (version 2.2.1).
*
* https://capacitor.ionicframework.com
*
* Useful if your project uses TypeScript namespaces ("internal modules")
* instead of the newer ES2015 module ("external modules") convention.
*
/**
* Normally, when using the await keyword to wait on a promise, if the promise is
* rejected then an exception will be thrown. This means that to handle a rejection
* you would need to try/catch all your await usages, which is inconvenient.
*
* This helper is meant to be used with the await keyword to wrap the promise
* so that it never throws an exception; it is guaranteed to resolve successfully.
*
* In the case of an error, it will be available in the resolved result object so
@Justin-Credible
Justin-Credible / async-utils.test.ts
Created December 4, 2023 21:41
Locking mechanism in TypeScript
import { doWithLock, waitFor } from '../async-utils';
describe('async-utils', () => {
describe('doWithLock', () => {
it('prevents multiple tasks from completing out of order', async () => {
const completed: string[] = [];
doWithLock('MY_LOCK', async () => {
await waitFor(0);
completed.push('A');