Skip to content

Instantly share code, notes, and snippets.

View Konstantin6487's full-sized avatar

Konstantin Bochinin Konstantin6487

View GitHub Profile
@Konstantin6487
Konstantin6487 / closures.rb
Created July 31, 2021 14:49 — forked from iansheridan/closures.rb
A demonstration of Ruby closures by Paul Cantrell
# CLOSURES IN RUBY Paul Cantrell http://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
#
@Konstantin6487
Konstantin6487 / static-dynamic-scope.pl
Created July 11, 2020 15:39 — forked from DmitrySoshnikov/static-dynamic-scope.pl
Static and dynamic scope in Perl
# Lexical and dynamic scopes in Perl;
# Static (lexical) scope uses model of
# environments with frames; dynamic scope
# uses single global var frame.
$a = 0;
sub foo {
return $a;
}
sub staticScope {
@Konstantin6487
Konstantin6487 / async-defer-module.md
Created March 3, 2020 11:11 — forked from jakub-g/async-defer-module.md
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@Konstantin6487
Konstantin6487 / tmux-cheats.md
Created August 23, 2019 14:41 — forked from Starefossen/tmux-cheats.md
My personal tmux cheat sheet for working with sessions, windows, and panes. `NB` I have remapped the command prefix to `ctrl` + `a`.

Sessions

New Session

  • tmux new [-s name] [cmd] (:new) - new session

Switch Session

  • tmux ls (:ls) - list sessions
  • tmux switch [-t name] (:switch) - switches to an existing session
@Konstantin6487
Konstantin6487 / tslint.json
Created September 18, 2018 07:56 — forked from piotrwitek/tslint.json
TSLint rules with ESLint/React extension based on airbnb style guide
{
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,

ESLint + TSLint + TypeScript + Create React App TS

.eslintrc

{
  "extends": [
    "airbnb",
    "prettier",
    "prettier/react",
//Elements without children
const dfs = tree => {
const [element, children] = tree;
return !children ? undefined : children.map(dfs);
};
dfs(['A',
[
['B', [['E'], ['F']]],
@Konstantin6487
Konstantin6487 / Approaches to currying in JavaScript.js
Created May 22, 2017 18:37
Approaches to currying in JavaScript created by Konstantin6487 - https://repl.it/Hpst/28
//http://extralogical.net/articles/currying-javascript.html
//превращение функции с несколькими аргументами в цепной ряд фукнций
/*
var add = function(a, b) {
return a + b;
};
var curriedAdd = function(a) {
return function(b) {
return a + b;
@Konstantin6487
Konstantin6487 / BubbleSort.js
Created May 22, 2017 18:36
BubbleSort created by Konstantin6487 - https://repl.it/Hhms/18
const bubbleSort = (arr = []) => {
let temp, status = false;
if (arr.length === 0 || !Array.isArray(arr)) {
return false;
}
const iter = ([a, b, ...rest], acc = []) => {
switch(true) {
case a > b:
status = true;
return iter([a, ...rest], [...acc, b]);
@Konstantin6487
Konstantin6487 / Composing Functions JS.js
Created May 22, 2017 18:35
Composing Functions JS created by Konstantin6487 - https://repl.it/Ge8r/19
const compose = f => value => f(f(value));
const square = value => Math.pow(value, 2);
const doubleSquare = compose(square);
console.log(doubleSquare(3) + " - doubleSquare(3)");
const compose2 = f => value => f(f(f(value)));
const addTwo = value => value += 2;
const tripleAddTwo = compose2(addTwo);
console.log(tripleAddTwo(2) + " - tripleAddTwo(2)");