Skip to content

Instantly share code, notes, and snippets.

@JonathanGawrych
JonathanGawrych / git force remerge.sh
Last active March 13, 2019 20:11
Force a remerge using git's plumbings commands
# If remerging a revert, do this to get back your changes
git revert revertSha
git reset HEAD~
git add -A
# And skip to the echo below
# Find the merge-base of an already merged branch
# https://stackoverflow.com/a/4991675/1248889
diff -u <(git rev-list --first-parent topic) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1
Rule Description
Generic.Arrays.ArrayIndent Ensures that array are indented one tab stop.
Generic.Arrays.DisallowLongArraySyntax Bans the use of the PHP long array syntax.
Generic.Arrays.DisallowShortArraySyntax Bans the use of the PHP short array syntax.
Generic.Classes.DuplicateClassName Reports errors if the same class or interface name is used in multiple files.
Generic.Classes.OpeningBraceSameLine Checks that the opening brace of a class/interface/trait is on the same line as the class declaration.
Generic.CodeAnalysis.AssignmentInCondition Detects variable assignments being made within conditions.
Generic.CodeAnalysis.EmptyPHPStatement Checks against empty PHP statements.
Generic.CodeAnalysis.EmptyStatement This sniff class detected empty statement.
@JonathanGawrych
JonathanGawrych / CHITEST in memory.txt
Created February 17, 2020 00:58
Do the chitest formula in memory. Assumes the data is in DATA!$A:$K, and that the chi sheet, the top/left row/column references the columns to use (B, C, D, etc)
=CHITEST(
QUERY(QUERY(Data!$A:$K,"SELECT count(B) WHERE "&$A2&" IS NOT NULL GROUP BY "&$A2&" PIVOT "&B$1, 1), "SELECT * OFFSET 1", 0),
MMULT(
QUERY(Data!$A:$K,"SELECT COUNT(B) WHERE "&$A2&" IS NOT NULL GROUP BY "&$A2&" label Count(B) ''", 1),
ARRAYFORMULA(DIVIDE(TRANSPOSE(
QUERY(Data!$A:$K,"SELECT COUNT(B) WHERE "&B$1&" IS NOT NULL GROUP BY "&B$1&" LABEL COUNT(B) ''", 1)),
QUERY(Data!$A:$K,"SELECT COUNT(B) LABEL COUNT(B) ''", 1)))
)
)
)
@JonathanGawrych
JonathanGawrych / countup.js
Created May 7, 2020 00:42
Countup with variable carry
function* count(max) {
if (max.length === 0) {
yield [];
return;
}
for (let i = 1; i <= max[0]; i++) {
for (const subTree of count(max.slice(1))) {
yield [i].concat(subTree);
}
}
@JonathanGawrych
JonathanGawrych / HealthEquityAutoFill.userscript.js
Last active March 18, 2024 04:06
Userscript to automatically fill out the HSA Partial Transfer form for Health Equity to Fidelity
// ==UserScript==
// @name Fill Out HSA Transfer
// @match https://member.my.healthequity.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let toTransfer = null;
@JonathanGawrych
JonathanGawrych / findPathToObj.php
Last active June 8, 2022 17:58
A php function to scan an object to attempt to find a path to a value.
<?php
function findPathToObj($from, $to, $maxLevel = 5): ?string
{
$queue = [[
'var' => $from,
'path' => 'root',
'level' => 0
]];
$seen = [];
@JonathanGawrych
JonathanGawrych / kill-gitlab-vs.user.js
Last active October 11, 2022 17:13
Virtual scroll in gitlab is bad. Just disable this feature (at GoReact)
// ==UserScript==
// @name Disable Gitlab Virtual Scroll At GoReact
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Virtual scroll in gitlab is bad. Just disable this feature
// @author Joanthan Gawrych
// @match https://gitlab.goreact.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=goreact.com
// @grant none
// ==/UserScript==
@JonathanGawrych
JonathanGawrych / findpath.js
Last active March 18, 2024 01:46
Given an key of a deep object and you're trying to find a path to it, BFS and print the path
const findPathByKey = (ob, key) => {
const found = new Set();
const queue = [{obj: ob, path: []}];
let pathLength = 0;
while (queue.length > 0) {
const {obj, path} = queue.shift();
if (pathLength < path.length) {
pathLength = path.length;
console.log(`increasing depth to ${pathLength}, current queue size: ${queue.length}, current found size: ${found.size}`);
}
@JonathanGawrych
JonathanGawrych / git-undo-merge.md
Created April 7, 2023 16:43
How to undo a git merge

Figured out how to undo merge commits. If you have a branch like so:

develop -A--B--C--D--E
             \     \
topic         1--2--M--3

And you wanted to remove the merge, checkout topic and run git rebase --onto 2 M, where M is the merge commit and 2 is the topic's commit before the merge commit: WARNING: THIS DELETES EVIL MERGE CHANGES (changes that do not appear in either parent)

@JonathanGawrych
JonathanGawrych / jira-sum-highlighted.user.js
Last active July 6, 2023 21:59
Creates a floating badge of the sum on the tickets when you highlight multiple
// ==UserScript==
// @name Jira Sum Highlighted
// @author Jonathan Gawrych
// @match https://goreact.atlassian.net/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @grant none
// @run-at document-idle
// ==/UserScript==
(function doit() {