Skip to content

Instantly share code, notes, and snippets.

View souljorje's full-sized avatar
🤔

Georgiy Bukharov souljorje

🤔
  • Tbilisi, Georgia
View GitHub Profile
@souljorje
souljorje / arraysCombinations.js
Last active August 8, 2023 15:29
Combinations of multiple arrays values (cartesian product) JavaScript
const getAllCombinations = (arraysToCombine) => {
const divisors = [];
let combinationsCount = 1;
for (let i = arraysToCombine.length - 1; i >= 0; i--) {
divisors[i] = divisors[i + 1] ? divisors[i + 1] * arraysToCombine[i + 1].length : 1;
combinationsCount *= (arraysToCombine[i].length || 1);
}
const getCombination = (n, arrays, divisors) => arrays.reduce((acc, arr, i) => {
acc.push(arr[Math.floor(n / divisors[i]) % arr.length]);
@souljorje
souljorje / external-links.js
Last active March 30, 2021 13:20
Confirmation for following external links
@souljorje
souljorje / transliterateRuToEN.js
Created May 1, 2020 09:25
Transliteration from Russian to English JS
// https://stackoverflow.com/a/36310163/12496886
export const transliterateRuToEN = (text) => text
.replace(/\u0401/g, 'YO')
.replace(/\u0419/g, 'I')
.replace(/\u0426/g, 'TS')
.replace(/\u0423/g, 'U')
.replace(/\u041A/g, 'K')
.replace(/\u0415/g, 'E')
.replace(/\u041D/g, 'N')
@souljorje
souljorje / transliterateGeToEn.js
Last active May 1, 2020 15:50
Transliteration from Georgian to English JS
/***
inspired by https://stackoverflow.com/a/36310163/12496886
transliterateGeToEN('აბგდევზთიკლმნოპჟრსტღყშცჩძწჭხჯჰ') // "abgdevztiklmnopzhrstghkhshcchdztschxjh"
***/
export const transliterateGeToEN = (text) => text
.replace(/\u10D0/g, 'a')
.replace(/\u10D1/g, 'b')
.replace(/\u10D2/g, 'g')
.replace(/\u10D3/g, 'd')
@souljorje
souljorje / custom-lists.scss
Created February 2, 2020 11:54
ul custom bullet & ol custom numbers
ul {
list-style: none;
li {
&:before {
content: "";
color: red;
font-weight: 700;
display: inline-block;
width: 1em;
@souljorje
souljorje / fetchImage.js
Last active June 1, 2023 11:08
Fetch image and convert to File (axios)
// https://stackoverflow.com/questions/48470407/client-side-convert-png-file-stream-into-file-object
// Example src http://localhost:1337/uploads/bbf9e6e15a3841fba491dfd3972da6a4.jpg
// @returns bbf9e6e15a3841fba491dfd3972da6a4
const getImgName = (url) => url.slice(url.lastIndexOf('/') + 1, url.indexOf('.'));
const srcToFile = async (src, fileName = getImgName(src)){
const response = await axios.get(src, {
responseType: 'blob'
});
@souljorje
souljorje / .bash_profile
Last active May 30, 2022 10:16
Aliases for git bash
# ----------------------
# Git Aliases
# ----------------------
alias g='git'
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
@souljorje
souljorje / git-stash-extract
Last active September 14, 2018 07:49
Extract single file from git stash
git checkout stash@{index} -- <filename> <filename> ...
@souljorje
souljorje / launch.js
Created September 12, 2018 10:10
Config for vscode chrome debugger for Vue and Nuxt apps
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vue: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/*",
"breakOnLoad": true,
@souljorje
souljorje / iOS-scroll-fix.js
Last active May 28, 2018 07:18
Fix for page scrolling issue on iOS on input focus in fixed element.
open() {
const offset = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
document.body.style.top = (offset * -1) + 'px';
document.body.classList.add('iOS-scroll-fix');
}
close() {
const offset = parseInt(document.body.style.top, 10);
document.body.classList.remove('iOS-scroll-fix');
document.body.style.top = 0;