Skip to content

Instantly share code, notes, and snippets.

View leonidkuznetsov18's full-sized avatar
:electron:
stay hungry, stay foolish

Leonid Kuznetsov leonidkuznetsov18

:electron:
stay hungry, stay foolish
View GitHub Profile

Setup multiple git identities & git user informations

/!\ Be very carrefull in your setup : any misconfiguration make all the git config to fail silently ! Go trought this guide step by step and it should be fine 😉

Setup multiple git ssh identities for git

  • Generate your SSH keys as per your git provider documentation.
  • Add each public SSH keys to your git providers acounts.
  • In your ~/.ssh/config, set each ssh key for each repository as in this exemple:
{
"meta": { "theme": "elegant" },
"basics": {
"name": "Leonid Kuznetsov",
"label": "Software Engineer",
"picture": "",
"email": "js.leonid.kuznetsov@gmail.com",
"phone": "",
"website": "https://leonidkuznetsov.now.sh",
"summary": "I'm a passionate frontend developer with over 8 years of experience across various industries. I specialize in web technologies like Typescript, JavaScript, React, and NextJS and am highly skilled in optimizing web applications for performance and SEO. In addition, I have expertise in backend technologies like NodeJS and Solidity, enabling me to develop full-stack solutions. I also have experience in developing browser and word extensions, SSR and hybrid apps. I am excited to work with new technologies and contribute my skills and knowledge to your organization.",
@leonidkuznetsov18
leonidkuznetsov18 / knn.js
Created December 18, 2022 20:17
KNN algorithm by lodash
const outputs = [
[10, .5, 16, 1],
[200, .5, 16, 4],
[350, .5, 16, 4],
[600, .5, 16, 5],
]
const predictionPoint = 300;
const k = 3
function cropImage(cropMode, sourceWidth, sourceHeight, targetD) {
let result = {};
if (cropMode === 'Fill') {
result.width = targetD;
result.height = targetD;
if (sourceWidth > sourceHeight) {
result.type = 'landscape';
} else if (sourceWidth < sourceHeight) {
result.type = 'portrait';
@leonidkuznetsov18
leonidkuznetsov18 / get_image_size_type.js
Created December 18, 2022 12:05
Get image size type
function getImageSizeType(width, height) {
if (width > height) {
return 'landscape';
} else if (width < height) {
return 'portrait';
} else {
return 'square';
}
}
@leonidkuznetsov18
leonidkuznetsov18 / pdf_to_word.js
Created December 18, 2022 11:48
PDF to Word converter
// Load the PDF as a Blob
const file = await fetch('path/to/pdf.pdf').then(res => res.blob());
// Convert the PDF to a base64-encoded data URI
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
const base64 = reader.result;
// Create a new Blob from the data URI
@leonidkuznetsov18
leonidkuznetsov18 / word_to_pdf.js
Created December 18, 2022 11:46
Convert word to pdf
const doc = new jsPDF();
// Load the Word file as a Blob
const file = await fetch('path/to/word.docx').then(res => res.blob());
// Convert the Word file to a base64-encoded data URI
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
const base64 = reader.result;
@leonidkuznetsov18
leonidkuznetsov18 / password_generator.js
Created December 18, 2022 11:42
React password generator
import React, { useState } from 'react';
function PasswordGenerator() {
const [password, setPassword] = useState('');
const [length, setLength] = useState(8);
const [includeSpecialCharacters, setIncludeSpecialCharacters] = useState(true);
const [easyToRead, setEasyToRead] = useState(true);
const [easyToSay, setEasyToSay] = useState(true);
function generatePassword() {
@leonidkuznetsov18
leonidkuznetsov18 / detect_standard.js
Last active December 18, 2022 10:43
Detect ETH token standard
async function detectStandard() {
// Check if the contract implements the ERC-20 interface
if (implementsERC20(abiERC20)) {
return 'ERC-20';
}
// Check if the contract implements the ERC-721 interface
if (implementsERC721(abiERC721)) {
return 'ERC-721';
}
const data = [
{
"name": "path",
"children": [
{
"name": "to",
"children": [
{
"name": "file1",
"value": true,