Skip to content

Instantly share code, notes, and snippets.

View maxmarinich's full-sized avatar
🎯
Focusing

maxmarinich maxmarinich

🎯
Focusing
View GitHub Profile
@maxmarinich
maxmarinich / NonBlockingThreadCalculation.html
Last active December 5, 2022 13:28
Non blocking thread calculation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
</head>
<body>
<div style="display: inline-block">
<h3 id="sequence"></h3>
<button id="start">Start</button>
@maxmarinich
maxmarinich / consoleColors.js
Created February 19, 2022 16:17 — forked from abritinthebay/consoleColors.js
The various escape codes you can use to color output to StdOut from Node JS
// Colors reference
// You can use the following as so:
// console.log(colorCode, data);
// console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`);
//
// ... and so on.
export const reset = "\x1b[0m"
export const bright = "\x1b[1m"
export const dim = "\x1b[2m"
@maxmarinich
maxmarinich / grepKeys.js
Created March 30, 2020 09:16
Grep any string in NodeJS
const fs = require('fs');
const path = require('path');
const readDir = require('./readDir');
function grepKeys(sourceDir = '', outDir = '') {
const re = /(\$t\(['"]|\$t\(\\['"]|\$t\(\\\\['"])(.*?)(['"]|\\['"]|\\\\['"])/g;
const include = ['.vue', '.ts', 'json', '.js'];
const exclude = ['.Stories.ts', '.stories.ts', '.spec.ts'];
@maxmarinich
maxmarinich / .shell * DELETE
Last active February 20, 2020 09:56
Remove Node JS, Find/Remove node_modules
find . -name node_modules -exec rm -rf {} \;
git branch | grep -v "develop" | grep -v "master" | xargs git branch -D
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
const punctuation = /^[~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]*$/g;
const letters = /^[^0-9~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]*$/g;
const usernamr = /^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/;
const replaceFirstTwoAndLastFour = (str, symbol) => {
const re = /^(.{2})|(.{4})$/g
return str.replace(re, replacer)
function replacer(match) {
return symbol.repeat(match.length)
export function debounce(func, ms = 0) {
let timer = null
return function(...args) {
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
func.apply(this, args)
import React from 'react'
import { connect } from 'react-redux'
export default (Component) => {
class WithConfig extends React.Component {
render() {
return <Component { ...this.props } />
}
}
@maxmarinich
maxmarinich / search-in.js
Last active June 14, 2018 15:07
Find values in array by tags
const searchIn = (string, haystack) => {
const result = []
const matches = []
const values = string.replace(/[^\wа-яё\s]/gi, '')
haystack.forEach((item) => {
let matchesCount = 0
values.split(' ').forEach((needle) => {
if (needle && item.tags.toLowerCase().includes(needle.toLowerCase())) {
@maxmarinich
maxmarinich / pre-commit-eslint
Last active March 19, 2018 07:38 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
# chmod +x .git/hooks/pre-commit
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
git merge-base HEAD BRANCH_YOU_BRANCHED_FROM (HEAD -> dev, master... )
git reset --soft COMMIT_HASH
git commit -am 'This is the new re-created one commit'
git push -f