Skip to content

Instantly share code, notes, and snippets.

View bricss's full-sized avatar
🦉
Understand Create Evaluate

Yahor Siarheyenka bricss

🦉
Understand Create Evaluate
View GitHub Profile
(function() {'use strict';
/**
* Handlebars addition helper.
*
* Usage:
* {{addition 10 to="10"}}
* {{addition key to="20"}}
* {{addition key to="-5"}}
*/
Handlebars.registerHelper('addition', function(context, options) {
@bricss
bricss / viewport.check.js
Last active June 8, 2019 22:11
Wild way of viewport breakpoints checkout(s)
/*!
* @media (min-width: 1200px) {
* body:after {
* content: 'widescreen';
* display: none;
* }
* }
*/
export default () => window.getComputedStyle(document.body, ':after').getPropertyValue('content');
@bricss
bricss / iso-8601-rex.mjs
Last active February 4, 2023 00:35
RegExp for ISO 8601 date string validation
export const isoDateRex = /^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/;
@bricss
bricss / config.yml
Last active February 4, 2023 16:25
MongoDB config sample
net:
ipv6: true
storage:
dbPath: "C:/MongoDB/data"
directoryPerDB: true
journal:
enabled: true
wiredTiger:
engineConfig:
cacheSizeGB: 2
@bricss
bricss / git-broom.sh
Last active February 17, 2023 17:16
Remove remote merged branches from Git repo
#!/usr/bin/env bash
# Removes remote merged branches from Git repo
# Usage: `sh git-broom.sh`
protect='(dev|main|master|release)'
git fetch --prune --tags origin
git branch --remotes --merged origin | grep origin | grep -v $(git symbolic-ref --short HEAD) | egrep -v $protect | sed s/origin\\/// | xargs git push origin --delete
@bricss
bricss / git-drain.sh
Last active February 17, 2023 17:20
Ignores active Git repo change(s)
#!/usr/bin/env bash
# Ignores active change(s) in Git repo
# Mostly useful within CICD pipelines
# Usage: `sh git-drain.sh`
git status --porcelain | cut -c4- | xargs -n1 git update-index --assume-unchanged
@bricss
bricss / git-report.sh
Last active February 24, 2023 13:40
Generates monthly Git reports
#!/usr/bin/env bash
# Generates monthly Git reports
# Usage: `sh git-report.sh [ample]`
author=$(git config user.name)
ample=$(expr "$1" == 'ample')
date=$(date +%Y-%m-%d)
foretime=$(date +%Y-%m-01)
fullpath="$PWD"
target=reports/report-${date}
@bricss
bricss / pre-commit
Last active March 17, 2023 01:48
Warns before committing if staged files contains focused tests
#!/usr/bin/env bash
# Warns before committing if staged files contains focused tests
# Bypass with `git commit --no-verify`
dict=(describe.only it.only test.only)
status=0
for keyword in "${dict[@]}"; do
rex="/^s*${keyword%.*}.*(?=${keyword#*.})/"
files=$(git diff --staged -G${rex} --name-only)
@bricss
bricss / pre-push
Last active March 17, 2023 01:49
Warns before pushing to protected branches
#!/usr/bin/env bash
# Warns before pushing to protected branches
# Bypass with `git push --no-verify`
current=$(git rev-parse --abbrev-ref HEAD)
protect='^(main|master|release|patch-*)'
status=0
if [[ "$current" =~ $protect ]]; then
while true; do
@bricss
bricss / pre-push
Last active March 17, 2023 01:51
Warns before pushing to protected branches
#!/usr/bin/env bash
# Warns before pushing to protected branches
# Bypass with `git push --no-verify`
countdown=15
current=$(git rev-parse --abbrev-ref HEAD)
protect='^(main|master|release|patch-*)'
status=0
if [[ "$current" =~ $protect ]]; then