Skip to content

Instantly share code, notes, and snippets.

View odykyi's full-sized avatar
🍍
(async () => { /* ...loading */ })();

odykyi

🍍
(async () => { /* ...loading */ })();
View GitHub Profile
git remote set url.sh
0. git remote -v
1.1 git remote add origin [email protected]:USERNAME/REPOSITORY.git
1.2 git remote add origin https://github.com/USERNAME/REPOSITORY.git
2.1 git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
2.2 git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
import http from 'k6/http';
// import { sleep } from 'k6';
// const http = require('k6/http')
// const { sleep } = require('k6')
import * as fs from 'fs'
// const fs = require('fs')
const queries = JSON.parse(fs.readFileSync('./easygraphql-load-tester-queries.json'))
// const familySchema = fs.readFileSync(path.join(__dirname, 'api/public/schema.graphql'), 'utf8')
@odykyi
odykyi / formats.js
Created October 29, 2019 14:20
date formats for momentjs
const formats = [
'HH:mm:ss',
'DD/MM/YYYY',
'D MMMM YYYY',
'D MMMM YYYY HH:mm',
'dddd D MMMM YYYY HH:mm',
'DD.MM.YYYY HH:mm',
'MM-DD-YYYY HH:mm:ss',
'YYYY-MM-DD HH:mm',
'YYYY-MM-DD HH:mm:ss',
@odykyi
odykyi / file.js
Last active April 12, 2021 06:13
const hashCode = str => str.split('').reduce((prevHash, currVal) =>
(((prevHash << 5) - prevHash) + currVal.charCodeAt(0)) | 0, 0);
const sortByTime = (trx, nextTrx) => new Date(trx.time) - new Date(nextTrx.time);
const getMinutesFromDates = (startDate, endDate) => {
const difference = new Date(endDate).getTime() - new Date(startDate).getTime();
return (difference / 60000);
};
const findDuplicateTransactions = (transactions = []) => {
let map = new Map();
@odykyi
odykyi / encodeRLE.js
Last active October 10, 2019 12:19
Js Javascript / Run-length encoding algorithm / RLE encode encoding
function encode(code) {
if (!code) return '';
let encode = '';
for (let i = 0; i < code.length; i++) {
let count = 1;
for (let j = i; j < code.length; j++) {
if (code[i] !== code[j+1]) break;
count++;
i++;
@odykyi
odykyi / queue.js
Created June 23, 2019 14:57
node js javascript queue implementation example data structure
console.time('queue');
const assert = require('assert'); // for tests
class Queue {
constructor() {
this.list = []
}
isEmpty() {
return !this.list.length;
@odykyi
odykyi / stack.js
Created June 23, 2019 11:38
node js javascript stack implementation example data structure
console.time('stack');
const assert = require('assert'); // for tests
class Stack {
constructor() {
this.list = []
}
isEmpty() {
return !this.list.length;
@odykyi
odykyi / joinBase64Strings.js
Created October 5, 2018 11:28
base64 strings join concat nodejs
function joinBase64Strings(base64Str1, base64Str2) {
const bothData = Buffer.from(base64Str1, 'base64').toString('binary') + Buffer.from(base64Str2, 'base64').toString('binary');
const joinedBase64Result = Buffer.from(bothData.toString(), 'binary').toString('base64');
console.log('joinedBase64Result', joinedBase64Result);
return joinedBase64Result;
}
@odykyi
odykyi / JS.MD
Created September 6, 2018 07:41
JavaScript idiosyncrasies https://odykyi.github.io/javascript-idiosyncrasies/ javascript js brainfuck es6 es7 ecmascript ecmascript6 ecmascript2015 ecmascript2016 ecmascript2017 ecmascript5 react reactjs vue vuejs vuejs2 angular angularjs

JavaScript idiosyncrasies

https://odykyi.github.io/javascript-idiosyncrasies/

This is a collection of things in JavaScript that may not be well recognized, espcially to beginners.

Disclaimer: Some of these snippets are simply to demonstrate the quirky parts of JavaScript and by no means encourage best practices and should never be seen in production code.


@odykyi
odykyi / await-of.js
Created August 9, 2018 08:24
no try/catch in async/await ( nodejs node node.js js error handling arrow function)
module.exports = function of(promise) {
return Promise.resolve(promise)
.then((ret) => ret)
.catch((err) => {
if (!err) {
let error = new Error("Rejection with empty value");
error.originalValue = err;
err = error;
}