Skip to content

Instantly share code, notes, and snippets.

@jonnyparris
jonnyparris / prepare-commit-msg.sh
Last active April 10, 2024 20:16 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with the Jira ticket reference from a branch name
#!/bin/bash
# For instance with feature/add_new_feature_HEYT-653
# $ git commit -m"Fixed bug"
# will result with commit "[HEYT-653] Fixed bug"
# Customize which branches should be skipped when prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
@jonnyparris
jonnyparris / SleepyLoop
Created October 26, 2021 15:15
Spamming with a rate limit
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const sleepyLoop = async() => {
for (const [index, url] of urls.entries()) {
spam(url, index)
await sleep(100)
}
}
@jonnyparris
jonnyparris / schema_prisma_issue6499
Last active April 11, 2021 08:02
schema dump for db that prisma is struggling to introspect
CREATE TABLE pending_transactions
(id TEXT PRIMARY KEY,
acct INTEGER,
amount INTEGER,
description TEXT,
date TEXT,
FOREIGN KEY(acct) REFERENCES accounts(id));
CREATE TABLE created_budgets (month TEXT PRIMARY KEY);
CREATE TABLE spreadsheet_cells
(name TEXT PRIMARY KEY,
@jonnyparris
jonnyparris / openssl
Created May 2, 2020 22:38
Basica file encryption and decryption with openssl via the commandline
# encrypt file.txt to file.enc using 256-bit AES in CBC mode
openssl enc -aes-256-cbc -salt -in file.txt -out file.enc
# the same, only the output is base64 encoded for, e.g., e-mail
openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc
# To decrypt file.enc you or the file’s recipient will need to remember the cipher and the passphrase.
# decrypt binary file.enc
openssl enc -d -aes-256-cbc -in file.enc
@jonnyparris
jonnyparris / cy-commands.js
Created April 15, 2020 14:11
Cypress util commands
Cypress.Commands.add('getInputByName', name => {
return cy.get(`[name="${name}"]`);
});
Cypress.Commands.add('getByTestTag', tag => {
return cy.get(`[data-test-id="${tag}"]`);
});
Cypress.Commands.add('clickRecaptcha', () => {
cy.window().then(win => {
@jonnyparris
jonnyparris / Copy package.json to dist folder
Created April 17, 2019 20:52
Generated distribution-friendly package.json at dist/package.json (without devDependencies)
const fs = require('fs')
const DIST_SCRIPTS = {
'start': 'npm run start-main-script'
}
fs.readFile('package.json', 'utf8', (err, data) => {
const distPackage = JSON.parse(data)
distPackage['scripts'] = DIST_SCRIPTS
delete distPackage['devDependencies']