Skip to content

Instantly share code, notes, and snippets.

View bericp1's full-sized avatar

Brandon Phillips bericp1

View GitHub Profile
@bericp1
bericp1 / tbit.sh
Created January 22, 2019 20:48
Bash-wrapped AppleScript to toggle the "built-in trackpad disabled" accessibility setting.
# Built-in Trackpad toggle script
# https://github.com/Ryderpro/Apple-Scripts
osascript <<'END'
tell application "System Preferences"
quit
delay 1
end tell
tell application "System Preferences"
@bericp1
bericp1 / createTimer.js
Created July 19, 2019 22:57
Creates a high resolution timer. Call with a name to start. Call with a new name to "lap". Call with no arguments to stop.
function createTimer (log) {
let prev = null;
function hrtimeDurationToMs([durS, durUs]) {
return ((durS * 1000) + (durUs / 1000000)).toFixed(4);
}
return (name = null) => {
if (prev) {
const dur = hrtimeDurationToMs(process.hrtime(prev[1]));
log(`end ${prev[0]}, took ${dur}ms`, { name: prev[0], hrtime: prev[1], dur });
}
@bericp1
bericp1 / output.txt
Created August 13, 2019 23:23
Output of `yarn run react-native-schemes-manager fix-libraries` on RN 0.60.5
yarn run v1.16.0
$ PROJECT_PATH_OMITTED/node_modules/.bin/react-native-schemes-manager fix-libraries
✔ [fix-libraries]: Debug -> DevDebug created in node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj
✔ [fix-libraries]: Debug -> StagingDebug created in node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj
✔ [fix-libraries]: Release -> DevRelease created in node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj
✔ [fix-libraries]: Release -> StagingRelease created in node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj
✔ [fix-libraries]: Debug -> DevDebug created in node_modules/react-native/Libraries/ART/ART.xcodeproj
✔ [fix-libraries]: Debug -> StagingDebug created in node_modules/react-native/Libraries/ART/ART.xcodeproj
✔ [fix-libraries]: Release -> DevRelease created in node_modules/react-native/Libraries/ART/ART.xcodeproj
✔ [fix-libraries]: Release -> StagingRelease created in node_modules/react-native/Librari
@bericp1
bericp1 / alert.js
Created September 20, 2019 17:13
An alert module
import { flatten } from 'ramda';
/**
* The default alert message type.
*
* @constant
* @type {string}
*/
export const DEFAULT_ALERT_TYPE = 'info';
@bericp1
bericp1 / debug-rewrite-rules.php
Created October 9, 2019 16:36
WP Template and Rewrite Rule Debug – just drop in `mu-plugins/`
<?php
/**
* Adapted from
*
* @param string $where
*
* @return bool
*/
function car_debug_rewrite_rules()
@bericp1
bericp1 / AlternativeFileReplacerPlugin.js
Last active March 17, 2021 16:04
A webpack plugin that replaces a file with an alternate version alongside it.
const path = require('path');
const escapeStringRegExp = require('escape-string-regexp');
const _debug = require('debug');
const PLUGIN_NAME = 'AlternativeFileReplacerPlugin';
const debug = _debug(PLUGIN_NAME);
/**
* Create an "isFileAccessible" function for an `fs` interface that has a `stat` function.
@bericp1
bericp1 / VPCLatticePrefixLists.ts
Created February 1, 2025 21:58
As of 2025-02-01 CDK does not provide a way to get the managed prefix lists which VPC Lattice automatically creates in the account after you create your first `CfnServiceNetworkVpcAssociation`. This custom resource looks them up for use in e.g. Peers on security groups in other constructs.
import { Construct } from 'constructs';
import * as customResources from 'aws-cdk-lib/custom-resources';
import * as vpclattice from 'aws-cdk-lib/aws-vpclattice';
export interface VPCLatticePrefixListsProps {
region: string;
serviceNetworkVpcAssociation: vpclattice.CfnServiceNetworkVpcAssociation;
}
export class VPCLatticePrefixLists extends Construct {