Skip to content

Instantly share code, notes, and snippets.

View AlexeyPogorelov's full-sized avatar
🏠
Working from home

Alex AlexeyPogorelov

🏠
Working from home
View GitHub Profile
@AlexeyPogorelov
AlexeyPogorelov / filter.js
Created February 17, 2021 11:36
filter (or / and)
const getCheckFunction = (params, isAnd) => {
const action = isAnd ? "every" : "some";
const entries = Object.entries(params);
return (object) => {
return entries[action](([key, value]) => object[key] === value);
};
};
const filter = (array, params, isAnd) => {
return array.filter(getCheckFunction(params, isAnd));
@AlexeyPogorelov
AlexeyPogorelov / useCallbacn.js
Last active February 17, 2021 11:37
useCallbacn in action
import { useCallback, useRef } from "react";
const Elem = ({ index, onClick }) => {
const onClickRef = useRef(onClick);
const handleEvent = useCallback(() => {
onClickRef.current(index);
}, [index, onClickRef]);
return <button onClick={handleEvent}>{index}</button>;
};
@AlexeyPogorelov
AlexeyPogorelov / gostab.sh
Created October 1, 2019 17:40 — forked from residentsummer/gostab.sh
Script to stabilize shaky GoPro footage with ffmpeg and libvidstab
#!/bin/bash
# Run without args to see usage
##### Configuration #####
# Maximum shakiness and accuracy
DETECT_OPTS="shakiness=10:accuracy=15"
# Fish-eye correction for GoPro H3+B 16:9 Wide
# http://stackoverflow.com/questions/30832248/is-there-a-way-to-remove-gopro-fisheye-using-ffmpeg/40659507#40659507
@AlexeyPogorelov
AlexeyPogorelov / lines-by-author
Created April 30, 2019 11:55
Git lines by author
git ls-files | xargs -n1 git blame --line-porcelain | sed -n 's/^author //p' | sort -f | uniq -ic | sort -nr
// set and get value from href
function hrefValue (key, value) {
'use strict';
var result,
regexp,
replacer,
href = window.location.href;
regexp = new RegExp(key + '=([^\;\&\n]+)');
replacer = function (match, val) {
return match.replace(val, value);
// SHOW BY CLICK
//
// This self-invoking function returns init function. If you dynamicly modify or add new DOM structure, you can easyly run plugin for new elements.
// Init function needs one argument. Argument can be a DOM node or jQuery object containing element(s) for init.
// Basicly you can change selector by changing "selector" variable. Also you can give your dynamicly created trigger elements a className by changing "triggerClass" variable.
// In the "triggerText" array you can find text for trigger nodes or set it by adding custom "data-show-text" and "data-hide-text" attributes
// Please send BUG reports or any proposals to alexey.intertech@gmail.com
;(function showByClick ($) {
if (!$) {
@AlexeyPogorelov
AlexeyPogorelov / text.js
Last active December 23, 2016 04:21
c (text, type, condition)
function c (text, type, condition) {
// made console messages simple
var t;
if (type) {
switch (type) {
case 1:
t = 'info';
break;
case 2:
t = 'warn';