Skip to content

Instantly share code, notes, and snippets.

View Vovan-VE's full-sized avatar

Vladimir Vovan-VE

  • Russia, Irkutsk
View GitHub Profile
@Vovan-VE
Vovan-VE / _benchmark.php
Last active October 29, 2019 16:08
Test if value is array or not, when value mostly is null
<?php
/**
* Compare performance of alternative functions
*
* Cases functions in `$functions` are all should perform the same task, but in different
* implementation. This benchmark function runs every cases functions and display a report to
* STDOUT, so you can compare performance.
*
* Example:
@Vovan-VE
Vovan-VE / README.md
Last active December 25, 2018 04:10
Test markdown for docs

Title

Array of elements of single type:

# Field Type Description
1 foo Array<[App.Foo][]> Foos, surely.
2 bar Array<[App.Bar][]> Bars.
3 bar Array <[App.Bar][]> Bars.
@Vovan-VE
Vovan-VE / fix-lists.js
Created June 20, 2019 00:09
Quill Lists Fix (redux ready)
/*
* Quill 1.* cannot next block elements inside <li> including nested <ul>,<ol>.
* To achieve nested lists it uses flat linear lists with CSS class `ql-indent-\d+` on <li>.
* Nesting <ul> inside <ol> or vice-versa cause topmost list to break in two adjacent lists.
*
* There is the only solution: fix bad HTML after getting it from Quill and break it back before
* passing to Quill again for editing.
*/
const mkNode = (tagName = 'div') => document.createElement(tagName);
@Vovan-VE
Vovan-VE / example.action-types.ts
Last active July 19, 2021 14:31
TypeScript: redux-thunk & redux-promise-middleware together
import { Action } from 'redux';
import { AsyncAction, AsyncFulfilledAction } from './redux-thunk-promise';
import { ApiResult } from 'api/...';
export const FETCH = '.../FETCH';
export const FETCH_PENDING = '.../FETCH_PENDING';
export const FETCH_FULFILLED = '.../FETCH_FULFILLED';
export const FETCH_REJECTED = '.../FETCH_REJECTED';
export type FetchAction = AsyncAction<typeof FETCH, ApiResult>;
@Vovan-VE
Vovan-VE / .gitconfig
Last active June 23, 2021 03:12
My personal ~/.gitconfig
[core]
filemode = true
eol = lf
safecrlf = false
autocrlf = input
symlinks = true
sharedRepository = all
whitespace = blank-at-eol,space-before-tab,blank-at-eof,tab-width=4
editor = nano
@Vovan-VE
Vovan-VE / running-browser-launcher.sh
Last active February 27, 2021 08:08
Browser launcher to reuse already running browsers before start new one
#!/bin/bash
################################################################################
# This launcher will proxy arguments to one of already running browsers,
# or will run new browser.
################################################################################
#
# I currently use two browsers. First primary (Opera) is for work, and it's full
# of opened tabs. Second (Vivaldi) is for any another things when First is not
# running I just don't want to start it with all of it's opened tabs.
@Vovan-VE
Vovan-VE / README.md
Created June 22, 2021 09:11
mysqldump to pg_dump

dump-my2pg

Read data from MySQL like mysqldump does, but output data to STDOUT like pg_dump does.

Notice: Only data will be dumped with COPY query. Nothing else.

SYNOPSIS

dump-my2pg [options] DBNAME [TABLE...]
@Vovan-VE
Vovan-VE / mysqldump-merge.pl
Created June 22, 2021 10:58
Merge series of single row INSERT from `mysqldump` into series of multi-INSERT
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Getopt::Long;
sub usage(;$) {
my ($exit) = @_;
@Vovan-VE
Vovan-VE / README.md
Last active May 4, 2023 15:34
WinPlex SLT file format

WinPlex *.slt file format

WinPlex stores demos (solutions) in *.slt files.

SLT files are stored in Solution subfolder in the game directory. Every SLT file named as:

<levelset-file-name>.<level-index>.slt

For example:

@Vovan-VE
Vovan-VE / json-uglify.sh
Created January 20, 2024 08:00
JSON Uglify (Bash)
#!/bin/bash
SELF="$( basename "$0" )"
# new-line char is skipped here
while read -r LINE; do
while [ -n "$LINE" ]; do
# skip whitespaces
[[ "$LINE" =~ ^[$' \t\r\n']+ ]] && {
PART="${BASH_REMATCH[0]}"