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 / 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-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 / settings.json
Last active February 5, 2026 16:26
VSCode settings.json
{
"debug.terminal.clearBeforeReusing": true,
"debug.toolBarLocation": "docked",
"editor.bracketPairColorization.independentColorPoolPerBracketType": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.fontSize": 13,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
@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
@bricss
bricss / druuid.mjs
Last active February 28, 2026 13:10
Date-relative (and relatively universally unique) UUID generation. Inspired by: https://www.npmjs.com/package/druuid
export let epoch = 0;
export const gen = (date = Date.now()) => {
return ((BigInt(date - epoch) << (64n - 41n)) ^ (BigInt(crypto.getRandomValues(new Uint8Array(32)).join('')) % (2n ** (64n - 41n))));
};
export const time = (uuid) => {
return new Date(Number((BigInt(uuid) >> (64n - 41n))) + epoch);
};
@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