Skip to content

Instantly share code, notes, and snippets.

View monkpit's full-sized avatar

Kyle Pittman monkpit

  • Dallas, Texas, USA
View GitHub Profile
@monkpit
monkpit / addSizzle.js
Created July 8, 2021 19:08 — forked from kpittman-securus/addSizzle.js
Add Sizzle to window (jQuery selector engine)
const sizzleScript = document.createElement('script');
sizzleScript.src = 'https://cdn.jsdelivr.net/npm/sizzle@latest/dist/sizzle.min.js';
document.getElementsByTagName('head')[0].appendChild(sizzleScript);
window.sz = window.Sizzle;
@monkpit
monkpit / build.sh
Created April 28, 2021 23:20 — forked from kpittman-securus/build.sh
Parallel execution with find and xargs
#! /usr/bin/env bash
find ./src/bookmarklets -name "*.js" -print0 | xargs -I FILE -0 -P "$(nproc)" npm run rollup -- --input "FILE" --file "output/FILE"
# EDIT: Per my latest comment - I now prefer this:
for bookmarklet in ./src/bookmarklets/**/*.js
do
npm run rollup -- --input "$bookmarklet" --file "output/$bookmarklet" &
done
wait
const keymap = <T extends unknown, U extends object>(
object: U,
callback: (key: keyof U, index: number) => T
) => (Object.keys(object) as (keyof U)[]).map(callback);
@monkpit
monkpit / deploy.ts
Created April 28, 2021 23:19 — forked from kpittman-securus/deploy.ts
NewRelic deploy via browser JS
step('Trigger NewRelic marker', async (b: Browser) => {
const description = `Flood run started - ${ENV.FLOOD_SEQUENCE_ID}`;
await b.page.evaluate(
(_description, sequenceId) => {
const applicationId = '123';
fetch(`https://api.newrelic.com/v2/applications/${applicationId}/deployments.json`, {
method: 'POST',
body: JSON.stringify({
deployment: {
description: _description,
@monkpit
monkpit / cleanupPR.js
Created April 28, 2021 23:18 — forked from kpittman-securus/cleanupPR.js
Mark deleted as viewed, sort all files by number of changes
const container = $('#files');
const files = Array.from($$('.file'));
const getSortText = (el) => el.querySelector('.diffstat').innerText;
files.sort((a, b) => {
const aSortText = getSortText(a);
const bSortText = getSortText(b);
if (aSortText > bSortText) return 1;
if (aSortText < bSortText) return -1;
return 0;
});