Skip to content

Instantly share code, notes, and snippets.

View kino6052's full-sized avatar
🏠
Working from home

Kirill Novik kino6052

🏠
Working from home
View GitHub Profile
I Wear Mask I Don't Wear Mask
Mask Helps Spread is Lowered Spread is Increased
Mask Doesn't Help Spread is Same Spread is Same
Admit That Lake Should be Protected Deny That Lake Should be Protected
No Danger to the Lake Exists Lake Lives Lake Lives
Danger to the Lake Exists Lake Lives Lake Dies
const getRandomNumbers = (length: number) => {
const value = Array.from(Math.round(Math.random()*(Math.pow(10, length))).toString()).reverse();
return new Array(length).fill('0').map((v, i) => value[i] || v).reverse().join('');
}
const generateId = (amount: number, length: number) => new Array(amount).fill(0).map((a, i, b) => `${i && '-'}${getRandomNumbers(length)}`).join('')
@kino6052
kino6052 / webpack.config.js
Created October 27, 2018 19:27
webpack-configuration-example
const path = require( 'path' );
const webpack = require( 'webpack' );
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = ( env, options ) => {
return {
entry: './src/block.js',
output: {
path: path.resolve( __dirname, 'build' ),
@kino6052
kino6052 / alert-on-scroll-to-bottom.js
Last active September 10, 2018 08:06
Determine if user scrolled all the way to the bottom
// https://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom
window.onscroll = function(ev) {
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
alert("you're at the bottom of the page");
}
};
@kino6052
kino6052 / array-remove-value-by-index.js
Last active August 31, 2018 11:24
Elegant way to remove value from an array by index
let array = [1, 2, 3];
let index = 1; // Any index
let filteredArray = array.filter((el, i) => i !== index); // [1, 3]