Skip to content

Instantly share code, notes, and snippets.

View MRGRD56's full-sized avatar
🦙

KIRILL GOLIKOV MRGRD56

🦙
View GitHub Profile
@MRGRD56
MRGRD56 / useful-nuget-packages.md
Last active July 12, 2022 09:27
Useful NuGet Packages

Useful NuGet Packages

WPF Controls & Styles

  • MaterialDesignThemes
  • HandyControl

Machine Learning & AI

  • Microsoft.MLNet
  • Emgu.CV
@MRGRD56
MRGRD56 / useful-npm-packages.md
Last active July 12, 2022 09:27
Useful NPM Packages

Useful NPM Packages

HTTP Client

  • axios

CSS Preprocessors

  • node-sass ^5.0.0

Reactive Programming

  • rxjs
@MRGRD56
MRGRD56 / user-agents.md
Last active July 12, 2022 09:27
user-agents

Windows 11, Chrome

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Android 11, Chrome

Mozilla/5.0 (Linux; Android 11; 2109119DG) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.104 Mobile Safari/537.36
@MRGRD56
MRGRD56 / java-collector-from-map-to-entries.java
Created April 14, 2022 08:19
Java collector toMapFromEntries
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public final class AppCollectors {
private AppCollectors() { }
public static <K, V> Collector<? super Map.Entry<K, V>, ?, Map<K, V>> toMapFromEntries() {
return Collectors.toMap(Map.Entry<K, V>::getKey, Map.Entry<K, V>::getValue);
}
@MRGRD56
MRGRD56 / js-sql-to-csv.md
Created April 20, 2022 14:37
SQL to CSV
const fieldsStrings = $value.split(',\n');
fieldsStrings.map(fieldString => {
    const regex = /\s*(\S+)\s+(\S+)\s*(.*)\s*/ms;
    const [, columnName, columnType, columnParams] = regex.exec(fieldString);
    return `${columnName},${columnType}${columnParams ? ',' + columnParams.replace(/\s\s+/g, ' ') : ''}`;
}).join('\n');

$value

@MRGRD56
MRGRD56 / js-boolean-logic.js
Last active July 12, 2022 09:26
JS Boolean Logic
const and = (a, b) => a ? b : a;
const or = (a, b) => a ? a : b;
@MRGRD56
MRGRD56 / switchKeyboardLayout.js
Created July 12, 2022 09:25
switch keyboard layout from English to Russian in JavaScript
// based on: https://ru.stackoverflow.com/a/962892/393687
function switchKeyboardLayout(str) {
const lettersMap = {
"q":"й", "w":"ц", "e":"у", "r":"к", "t":"е", "y":"н", "u":"г",
"i":"ш", "o":"щ", "p":"з", "[":"х", "]":"ъ", "a":"ф", "s":"ы",
"d":"в", "f":"а", "g":"п", "h":"р", "j":"о", "k":"л", "l":"д",
";":"ж", "'":"э", "z":"я", "x":"ч", "c":"с", "v":"м", "b":"и",
"n":"т", "m":"ь", ",":"б", ".":"ю", "/":"."
};
@MRGRD56
MRGRD56 / switch-layout.ts
Last active July 29, 2022 19:22
Switch keyboard layout from English to Russian and from Russian to English in JavaScript. Смена раскадки клавиатуры с английского на русский и с русского на английский JavaScript. QUERTY ЙЦУКЕН
const EN_LAYOUT = '`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?';
const RU_LAYOUT = 'ё1234567890-=йцукенгшщзхъ\\фывапролджэячсмитьбю.Ё!"№;%:?*()_+ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,';
const mapLayouts = (sourceLayout: string, targetLayout: string): Record<string, string> => {
if (sourceLayout.length !== targetLayout.length) {
throw new Error('Different length of layouts');
}
const result: Record<string, string> = {};
@MRGRD56
MRGRD56 / MapBuilder.java
Last active September 23, 2022 04:38
Java Map Builder (uses Spring Boot)
package com.mrgrd56.javamapbuilder;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
/**
@MRGRD56
MRGRD56 / Switch.ts
Created August 4, 2022 13:03
JavaScript custom switch case class (with TypeScript)
class Switch<T, V = never> {
constructor(private readonly object: T) {}
static of<T>(object: T) {
return new Switch(object);
}
private readonly conditions = new Map<T, () => unknown>();
private defaultValue: { current: () => unknown } | undefined = undefined;