This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git fsck --lost-found 2>&1 | grep "dangling commit" | while read line; do | |
hash="${line:16}" | |
git show --oneline "$hash" 2>&1 | head -n 1; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git clone $1 --depth=1 | |
# cd into the repo directory | |
a=$1 | |
b="${a##*/}"; | |
cd "${b%.*}" | |
for i in {1..100000..10}; do git fetch --depth=$i; done | |
git fetch --unshallow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getCurrentGitBranch() { | |
def gitBranch = "Unknown branch" | |
def workingDir = new File("${project.projectDir}") | |
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir) | |
result.waitFor() | |
if (result.exitValue() == 0) gitBranch = result.text.trim() | |
return gitBranch | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FIXME this leaks memory for some reason | |
const http = require('http'); | |
const port = parseInt(process.argv[2]); | |
const server = http.createServer((req, res) => { | |
res.setHeader('Content-Type', 'application/json'); | |
res.write(stringify(req)); | |
res.end(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BitBoolean { | |
private static final long[] indexToBitMask = new long[64]; | |
static { | |
long mask = 1; | |
for (int i=0; i<64; i++) { | |
indexToBitMask[i] = mask; | |
mask *= 2; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Utility function to change the text of a gapi-rendered Google Sign-In button */ | |
function translateSignin(id, signinText, signedinText) { | |
const spans = document.getElementById(id).querySelectorAll('.abcRioButtonContents span'); | |
if (spans.length !== 2) { | |
throw new Error(`Incorrect amount of sign-in span children (${spans.length} != 2)`); | |
} | |
spans.forEach(span => { | |
span.innerHTML = span.innerHTML.replace(/^Sign in with Google$/, signinText); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
GetJunctionTarget(Path) { | |
OutLogPath := A_Temp . "\AHK-GetJunctionTarget-fsutil.txt" | |
fsutil := A_ComSpec . " /c fsutil reparsepoint query `"" . Path . "`" > `"" . OutLogPath . "`"" | |
ExitCode := RunWait(fsutil) | |
if (ExitCode != 0) { | |
throw Error(fsutil . " exited with exit code " . ExitCode) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
; Source for AHK v1: https://www.autohotkey.com/boards/viewtopic.php?p=445668&sid=dee54807a74853039237b72c90610eae#p445668 | |
ClipCursor(x := "", y := "", w := "", h := "") { | |
if p := x != "" { | |
VarSetStrCapacity(&RECT, 16) | |
p := StrPtr(RECT) | |
for k, v in [x, y, x + w, y + h] { | |
target := p + 4 * (k - 1) | |
NumPut("Int", v, target) |