Skip to content

Instantly share code, notes, and snippets.

View AleksandrChukhray's full-sized avatar

Aleksandr Chukhrai AleksandrChukhray

  • Ukraine, Kherson
View GitHub Profile
@AleksandrChukhray
AleksandrChukhray / tools.txt
Last active July 13, 2023 13:14
List of tools
js
test
jest(test runner, mock library, assertion library) - https://jestjs.io/
mock library - sinon - https://sinonjs.org/
assertion library - chai - https://www.chaijs.com/
test runner - mocha - https://mochajs.org/
enzyme - render and dom manipulation library
internationalization
i18next - https://www.i18next.com/
react-intl - https://formatjs.io/docs/react-intl/
@AleksandrChukhray
AleksandrChukhray / insertion_sort.js
Created September 16, 2020 12:34
insertion sort algorithm
function insertionSort(arr){
for(let i=1; i < arr.length; i++){
let key = arr[i];
let j = i - 1;
while (j >= 0 && arr[j] > key){
arr[j+1] = arr[j];
j--;
}
// Merge Sort Implentation (Recursion)
function mergeSort (unsortedArray) {
// No need to sort the array if the array only has one element or empty
if (unsortedArray.length <= 1) {
return unsortedArray;
}
// In order to divide the array in half, we need to figure out the middle
const middle = Math.floor(unsortedArray.length / 2);
// This is where we will be dividing the array into left and right
function MergeSort(array){
if (array.length === 2){
if(array[0] > array[1]) return [array[1], array[0]];
return array;
};
let arrLength1 = Math.floor(array.length/2);
let arr1 = array.slice(0, arrLength1);
@AleksandrChukhray
AleksandrChukhray / index.css
Created July 21, 2020 16:18
Three dots on the end of line
.three-dots {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
function fragment(html) {
var elt = document.createElement("div"); // Пустой элемент
var frag = document.createDocumentFragment(); // Пустой фрагмент
elt.innerHTML = html; // Содержимое элемента
while (elt.firstChild) // Переместить все узлы
frag.appendChild(elt.firstChild); // из elt в frag
return frag; // И вернуть frag
}
function isDraggable() {
var div = document.createElement('div');
return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)
}
js> 2.3 % 1
0.2999999999999998
const k = Object.create(Object.prototype); // => {} with Object.prototype
const l = Object.create(null) // without prototype
const m = new Object(); // => {} with Object.prototype
const f = {} // => {} with Object.prototype
const a = [1, 2]; // => [1,2]
const b = Array(10); // => [empty * 10];
const k = new Array(10); // => [empty *10];
const m = Array.prototype.constructor(10, 12, 13); // => [10, 12, 13];
const l = Array.prototype.constructor(10); // => [empty * 10];
const f = new Array(10, 12, 13); // => [10, 12, 13];