It will check if current branch is master or a release branch and, if so, prevents a commit or push
- Enable git templates
git config --global init.templatedir '~/.git-templates'
import { Directive, HostListener } from '@angular/core'; | |
import { NgControl } from '@angular/forms'; | |
// Trims text for an Angular form control as the text is input, e.g. " foobar " -> "foobar" | |
@Directive({ | |
selector: '[trimOnInput]', | |
standalone: true, | |
}) | |
export class TrimOnInputDirective { |
// Playground here: https://codepen.io/tw3/pen/eYaMPOZ | |
function parseCsp(csp) { | |
const result = []; | |
const cspArr = csp.split(';'); | |
cspArr.forEach((x) => { | |
const vals = x.trim().split(' ').filter(Boolean); | |
let idx = 0; | |
const entryArr = []; | |
entryArr.push(vals[idx++]); // resource, e.g. default-src |
export class RotatingIterator<T> implements Iterable<T> { | |
private readonly origStart: number; | |
private nextIndex: number; | |
private isDone: boolean; | |
private hasLooped: boolean; | |
constructor(private readonly arr: T[], private startIndex = 0) { | |
this.origStart = startIndex; | |
this.nextIndex = startIndex; |
alias gdbak='GDBAK_FILENAME="../../temp/diff-bak-$(date +%s%3N)_$(git branch --show-current).tar"; tar cvf "${GDBAK_FILENAME}" `git diff --name-only`; echo "${GDBAK_FILENAME}"' |
#!/usr/bin/env bash | |
TARGET_BRANCH=$(git branch --show-current) | |
if [ -z "${TARGET_BRANCH}" ]; then | |
echo "Please cd into to the target branch" | |
exit; | |
fi | |
echo "Cherry-picking to branch: ${TARGET_BRANCH}" | |
read -p "Cherry-picking from branch: " SOURCE_BRANCH |
#!/usr/bin/env bash | |
main() { | |
echo "Here's an example:" | |
echo "" | |
echo "\"C:/Program Files/Python39/python.exe\" c:/bin/git-filter-repo.py --commit-callback '" | |
echo "msg = commit.message.decode(\"utf-8\")" | |
echo "newmsg = msg.replace(\"TEXT_FROM\", \"TEXT_TO\")" | |
echo "commit.message = newmsg.encode(\"utf-8\")" |
/** | |
* Example: | |
* | |
* const builder = new XPathBuilder(); | |
* const xpathStr = builder | |
* .addDescendant({ nodeName: 'carbon-dropdown' }) | |
* .addDescendant({ className: 'bx--label', innerText: 'AWS Region' }) | |
* .addAncestor({ nodeName: 'carbon-dropdown' }) | |
* .build(); | |
* |
import { defer, Observable, ObservableInput } from 'rxjs'; | |
import { finalize } from 'rxjs/operators'; | |
/** | |
* This is an RxJS operator that keeps a running counter of the number of active requests. | |
* This can be used to show a spinner for the first of a series of requests, and hide the spinner | |
* once all requests in the series are complete. | |
* | |
* For example: | |
* const activeRequestMonitor: ActiveRequestMonitor = monitorActiveRequests({ |
import { Injectable } from '@angular/core'; | |
import { | |
EMPTY, | |
merge as observableMerge, | |
Observable, | |
of as observableOf, | |
Subject, | |
timer as observableTimer | |
} from 'rxjs'; | |
import { delay, expand, map, takeUntil, takeWhile } from 'rxjs/operators'; |