Skip to content

Instantly share code, notes, and snippets.

@Treehopper
Treehopper / pauseBeforeUnload.js
Created December 15, 2021 13:23 — forked from Alex-T-1024/pauseBeforeUnload.js
debugger pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { console.warn('Before unload'); debugger; }, false)
@Treehopper
Treehopper / gource-multiple-repositories.sh
Last active July 20, 2022 00:39 — forked from anonymous/gource-multiple-repositories.sh
Run gource for multiple repositories.
#!/usr/bin/env bash
# Generates gource video (h.264) out of multiple repositories.
# Pass the repositories in command line arguments.
# Example:
# <this.sh> /path/to/repo1 /path/to/repo2
i=0
for repo in $*; do
# 1. Generate a Gource custom log files for each repo. This can be facilitated by the --output-custom-log FILE option of Gource as of 0.29:
logfile="$(mktemp /tmp/gource.XXXXXX)"
@Treehopper
Treehopper / smlr.groovy
Created November 5, 2018 06:44
Test string for similarity with each line in a file
#!/usr/bin/env groovy
@Grab(group='info.debatty', module='java-string-similarity', version='1.1.0')
import info.debatty.java.stringsimilarity.*
def input = args[0]
def inputFile = new File('file.txt')
def csvFile = new File('file-smlr.csv')
def l = new Levenshtein()
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doAnswer(answer).when(mock).call() construct" enabled="true" name="doAnswer">${a:importStatic(org.mockito.Mockito.doAnswer)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}doAnswer( new Answer&lt;${T}&gt;() {&#13;
public ${T} answer( InvocationOnMock invocation ) throws Throwable {&#13;
${cursor}&#13;
return null;&#13;
}&#13;
} ).when( ${mock} ).${call};</template><template autoinsert="false" context="java-statements" deleted="false" description="Mockito doAnswer(answer).when(mock).call() construct that manipulates invocation argument" enabled="true" name="doAnswerOnArgument">${a:importStatic(org.mockito.Mockito.doAnswer)}${b:import(org.mockito.stubbing.Answer, org.mockito.invocation.InvocationOnMock, java.lang.Throwable)}doAnswer( new Answer&lt;${T}&gt;() {&#13;
public ${T} answer( InvocationOn