Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alex AlexeyPogorelov

🏠
Working from home
View GitHub Profile
View filter.js
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 Feb 17, 2021
useCallbacn in action
View useCallbacn.js
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 Oct 1, 2019 — forked from residentsummer/gostab.sh
Script to stabilize shaky GoPro footage with ffmpeg and libvidstab
View gostab.sh
#!/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
View lines-by-author
git ls-files | xargs -n1 git blame --line-porcelain | sed -n 's/^author //p' | sort -f | uniq -ic | sort -nr
View set and get value from href
// 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);
View show_by_click
// 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 Dec 23, 2016
c (text, type, condition)
View text.js
function c (text, type, condition) {
// made console messages simple
var t;
if (type) {
switch (type) {
case 1:
t = 'info';
break;
case 2:
t = 'warn';