Skip to content

Instantly share code, notes, and snippets.

View kostandy's full-sized avatar
🎯
Focusing

Dmytro Andriushchenko kostandy

🎯
Focusing
View GitHub Profile
@penguinboy
penguinboy / Object Flatten
Created January 2, 2011 01:55
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@kchez
kchez / e_WrapperTable--FixedWidth.html
Last active August 28, 2023 18:26
Email Wrapper Table - Fixed Width Approach
<!-- WRAPPER TABLE -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="wrappertable" style="table-layout:fixed;">
<tr>
<!--
ALIGNING LAYOUTS TO THE CENTER:
In some cases, you may want the whole email layout to be centered (mainly for desktop clients).
Using the wrapping table cell approach is a clean way of doing it, removing the need for any <center> or <div> tags.
It does mean however you'll need to use the align attribute on all table cells within to avoid content being centered.
-->
<td align="center" valign="top" id="wrappercell">
@zmts
zmts / tokens.md
Last active June 25, 2024 12:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 25, 2024 17:07
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

@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: {},
}
@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);
@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'
@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 / 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"
},
{
function makeSoup() {
const pot = boilPot();
chopCarrots();
chopOnions();
await pot;
addCarrots();
await letPotKeepBoiling(5);
addOnions();
await letPotKeepBoiling(10);
console.log("Your vegetable soup is ready!");