Skip to content

Instantly share code, notes, and snippets.

View kostandy's full-sized avatar
🎯
Focusing

Dmytro Andriushchenko kostandy

🎯
Focusing
View GitHub Profile
@tresni
tresni / README.md
Created September 8, 2020 17:49
Enabling Yubikey for sudo on OSX

Intro

Primarily, I use TouchID for sudo authentication on OSX, but I also tend to be connected to a CalDigit TS3 Plus dock and external monitors with my laptop lid closed. TouchID does not work in that situation.

In my quest to have another solution I found the instructions from Yubikey[1][2]. Unfortunately, the instructions are not well laid out, with formatting issues and some necessary information just missing. I hope to rectify that with this document.

Prerequisites

This has been tested on MacOS 10.14.6 and should work on MacOS 10.15. This README assumes you are using Homebrew; it should be possible to configure everything w

@rgabaydullov
rgabaydullov / index.js
Created August 25, 2020 09:23
Vue error handling example
/* учитывайте, что глобальный метод window.onerror
не будет ловить исключения без Vue.config.errorHandler */
Vue.config.errorHandler = (error, vm, info) => {
return middlewareErrorHandler(error, info);
}
// сюда попадут все ошибки, которые находятся за пределами исполнения Vue
window.onerror = (
message,
function makeSoup() {
const pot = boilPot();
chopCarrots();
chopOnions();
await pot;
addCarrots();
await letPotKeepBoiling(5);
addOnions();
await letPotKeepBoiling(10);
console.log("Your vegetable soup is ready!");
@kostandy
kostandy / jsonMetric.js
Last active July 5, 2019 08:38
The performance metric of JSON handling
function jsonReturner() {
return [
{
"albumId": 1,
"id": 1,
"title": "accusamus beatae ad facilis cum similique qui sunt",
"url": "https://via.placeholder.com/600/92c952",
"thumbnailUrl": "https://via.placeholder.com/150/92c952"
},
{
@kostandy
kostandy / rot13.js
Created March 5, 2019 09:06
ROT13 replaces each letter by its partner 13 characters further along the alphabet. For example, HELLO becomes URYYB (or, conversely, URYYB becomes HELLO again). Read more - https://en.wikipedia.org/wiki/ROT13
const rot13 = message => {
const a = message.split('');
return a.map(s => {
const c = s.charCodeAt();
if (c <= 65 || c >= 123 || s === ' ') return s;
return String.fromCharCode(
c <= 78 && c < 90 || c >= 97 && c < 110 ? c+13 : c-13
);
}).join('');
}
@kostandy
kostandy / FileRename.js
Last active August 14, 2018 14:55
This little script allow you rename files in folder by list of names from any file which contains text
const fs = require('fs'); // Include File System Module to project
let listOfNames; // Initialization of variable
let pathToListOfNames = './example.txt'; // Path to text file with list of names
let pathToFiles = './media/images'; // Path to files which need to rename
let formatFiles = 'jpg'; // Specify your image format (Example: jpg, png, gif, etc.)
try {
listOfNames = fs.readFileSync(pathToListOfNames, 'utf-8')
.split('\n'); // Reading a file by strings and splitting it into an array by '\n'
@Godofbrowser
Godofbrowser / axios.refresh_token.1.js
Last active April 26, 2024 12:57 — forked from culttm/axios.refresh_token.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@adeelibr
adeelibr / Abort Controller In Axios
Last active April 20, 2024 00:50
Abort Controllers In Axios
import React, { Component } from 'react';
import axios from 'axios';
class Example extends Component {
signal = axios.CancelToken.source();
state = {
isLoading: false,
user: {},
}
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 20, 2024 23:48
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@zmts
zmts / tokens.md
Last active June 19, 2024 09:18
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов