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 / Forrst.icls
Last active March 29, 2023 15:19
WebStorm Forrst Theme
<scheme name="Forrst" version="142" parent_scheme="Default">
<metaInfo>
<property name="created">2023-03-29T17:02:29</property>
<property name="ide">WebStorm</property>
<property name="ideVersion">2023.1.0.0</property>
<property name="modified">2023-03-29T17:03:46</property>
<property name="originalScheme">Forrst</property>
</metaInfo>
<colors>
<option name="CARET_COLOR" value="8961e" />
@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 April 12, 2024 16:41
VSCode settings.json
{
"debug.terminal.clearBeforeReusing": true,
"debug.toolBarLocation": "docked",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.fontSize": 13,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": 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 June 25, 2023 12:04
Date-relative (and relatively universally unique) UUID generation. Inspired by: https://www.npmjs.com/package/druuid
export const toBigInt = (value, radix = 36) => {
return [...value.toString()].reduce((acc, val) => (acc * BigInt(radix)) + BigInt(parseInt(val, radix)), 0n);
};
export const gen = (date = Date.now()) => {
return ((BigInt(date) << (64n - 41n)) ^ (BigInt(crypto.getRandomValues(new Uint8Array(32))
.join('')) % (2n ** (64n - 41n))));
};
export const time = (uuid) => {