Skip to content

Instantly share code, notes, and snippets.

View bdombro's full-sized avatar

Brian Dombrowski bdombro

View GitHub Profile
sudo timeshift --create --scripted --comments "Fresh install" &> /dev/null # first snapshot works but reports error
echo "*******Install Foundation*******"
sudo cp -rf /etc /etc.orig
# Allow sudo password prompts and sessions to last forever
print "\nDefaults env_reset,timestamp_timeout=-1,passwd_timeout=0\n" | sudo tee -a /etc/sudoers
# Set suspend to always suspend-then-hibernate
sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
@bdombro
bdombro / jest-update-snaps.mjs
Last active March 10, 2022 16:40
jest-update-snaps.mjs
#!/usr/bin/env zx
/* eslint-disable i18next/no-literal-string */
// eslint-disable-next-line import/no-unresolved
import { startSpinner } from 'zx/experimental';
import {
assertGit,
assertGithubCli,
@bdombro
bdombro / scrubTranslation.js
Last active September 3, 2021 15:07
scrubTranslation.js
/**
* This CLI script will scrub/delete a translation from all translation files
*/
const path = require('path');
const fs = require('fs');
const execSync = require('child_process').execSync;
const toDelete = process.argv[2];
@bdombro
bdombro / benchmark-require.sh
Last active December 17, 2020 16:14
SFCC Benchmark Require Impact
#!/bin/bash
TIMEFORMAT=%R
function fetchWithGlobals {
curl 'https://zztr-140.sandbox.us01.dx.commercecloud.salesforce.com/on/demandware.store/Sites-RefArch-Site/en_US/HelloGlobals' \
-H 'authority: zztr-140.sandbox.us01.dx.commercecloud.salesforce.com' \
-H 'cache-control: max-age=0' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
@bdombro
bdombro / ArrayN.js
Created December 17, 2020 02:26
ArrayN.js - Extended Array for Rhino
'use strict';
var ArrayN = {
findIndex: findIndex,
find: find,
includes: includes,
keyBy: keyBy,
test: test,
};
Object.getOwnPropertyNames(Array).forEach(function(name) {
@bdombro
bdombro / ObjectN.js
Created December 17, 2020 02:25
ObjectN.js - Extended Object for Rhino
'use strict';
var ObjectN = {
assign: assign,
create: create,
entries: entries,
fromEntries: fromEntries,
pick: pick,
pickBy: pickBy,
omit: omit,
@bdombro
bdombro / prismaSchemaGen.ts
Created November 30, 2020 16:56
prismaSchemaGen.ts - an approach to prisma modularization
import * as fs from 'fs'
import * as glob from 'glob'
const datasource = fs.readFileSync('prisma/datasource.prisma')
const moduleFiles = glob.sync('src/**/*.prisma', {})
const modules = moduleFiles.reduce((a,f) => {
const module = fs.readFileSync(f)
return a + module
@bdombro
bdombro / KeyValueStore.ts
Created November 18, 2020 16:40
KeyValueStore.ts - Class to make Indexed Database's easy for Key-Value Stores with maxAge feature
/**
* Class to make Indexed Database's easy for Key-Value Stores
*
* In addition to wrapping IDB, it also adds a feature for maxAge,
* which can discard records if createdAt + maxAge > now
*
* Adapted from https://github.com/elias551/simple-kvs
* - Adds timestamp field and garbage collection feature.
*/
export default class KeyValueStore {
@bdombro
bdombro / crypt_unlock.sh
Last active October 15, 2020 15:45 — forked from gusennan/crypt_unlock.sh
initramfs-hook for unlocking LUKS-encrypted LVM partition
#!/bin/sh
# Part of https://www.pbworks.net/ubuntu-guide-dropbear-ssh-server-to-unlock-luks-encrypted-pc/
# Is a copy of https://gist.github.com/gusennan/712d6e81f5cf9489bd9f
PREREQ="dropbear"
prereqs() {
echo "$PREREQ"
}
ID="shhh"
SECRET="shhh"
# Note the -n!!!
AUTH=`echo -n "$ID:$SECRET" | base64`
echo AUTH