Skip to content

Instantly share code, notes, and snippets.

View SynCap's full-sized avatar

Constantin Losk SynCap

View GitHub Profile
@SynCap
SynCap / ANSI.md
Created August 2, 2021 09:07 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
@SynCap
SynCap / .editorconfig
Created July 28, 2021 03:48
Common editor config for CLosk
# editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@SynCap
SynCap / Rename-GitBranch.psm1
Last active September 27, 2023 11:53
Rename Git branch locally and remote with PowerShell
# Raname current branch Locally and Remote
function Rename-GitBranch {
[CmdletBinding()]
param(
[Parameter(mandatory=$true)][String] $OldName,
[Parameter(mandatory=$true)][String] $NewName,
[String] $UpstreamName = 'origin'
)
# Rename the local branch to the new name
@SynCap
SynCap / parseXML.js
Last active July 11, 2021 11:26
parseXML, JavaScript
const parseXML = str => {try{ return (new window.DOMParser()).parseFromString(str, "text/xml") } catch(e) { return undefined} }
@SynCap
SynCap / numberPad.js.md
Created June 30, 2021 05:03
Pad Number left with care about sign

numberPad.js

Disadvantages of String.padStart()

  • works only in modern browsers and environments;
  • don't care about negative
  • works only on String primitives not a Number
(-4+'').padStart(7,'0')
@SynCap
SynCap / debounce-n-throttle.js
Created June 30, 2021 04:41
Debounce & Throttle functions – Javascript
/**
* Debounce - delay the run of the functions (spread in time of all calls)
*
* @param {<type>} func The function
* @param {<type>} delay The delay
* @return {<type>} { description_of_the_return_value }
* @example
debouncedBtn.addEventListener(
'click',
debounce(function() {
@SynCap
SynCap / mdGen.JS.MD
Last active June 30, 2021 05:14
Parse content of popular sites and convert main article to MarkDown

mdGen - convert page article to MarkDown

I use this script within DevTools' Snippets of Chromium based browsers (Chrome, Yandex Browser, MS Edge, Opera)

Earlier FireFox has a Scratchpad with wich you can store and use this script. In modern FireFox switch console to multistring mode and paste script, then press Ctrl+Enter

This script is part of toolbox for prepare data and use the personal Knowlage

@SynCap
SynCap / README.MD
Last active June 30, 2021 05:17
Javascript & Typescript: calculate Orthodox Easter sacral dates | Дата Православной Пасхи и других дат Подвижного круга

Пасхалии / Orthodox Easter Dates (Javascript)

Рассчёт даты православной Пасхи и дат праздников Подвижного Круга, праздников, даты которых зависят от Пасхи

Calculate the Orthodox Easter date and other Easter depended dates

описание алгоритма / algorithm explanation -- https://ru.wikipedia.org/wiki/Пасха

@SynCap
SynCap / README.MD
Last active July 28, 2021 06:46
Awesome Git Aliases

Add this to your ~/.gitconfig file.

[alias]

alias = config --get-regexp ^alias\\.
branches = branch --all
camend = commit --amend -m
co = checkout
d = difftool
@SynCap
SynCap / README.MD
Last active December 28, 2020 11:06
Real GROUP BY in JavaScript (ES2015)

GROUP BY with JavaScript

rmProp(obj: Object, prop: String)

Small helper to get SHALLOW copy of obj where prop ELIMINATED

const rmProp = (obj, prop) => ( (({[prop]:_, ...rest})=>rest)(obj) )