Skip to content

Instantly share code, notes, and snippets.

View lnked's full-sized avatar
🧠
I may be slow to respond.

Edik Bulikyan lnked

🧠
I may be slow to respond.
View GitHub Profile
{
"compilerOptions": {
// куда собираем
"outDir": "./build/",
// запрет на any
"noImplicitAny": true,
"module": "ESNext",
// в какой формат копилируем, в данном случае ecmascript 6
"target": "es6",
"jsx": "react-jsx",
@nikparo
nikparo / Effect.jsx
Created February 18, 2021 09:04
Running React parent effects before child effects
// Sometimes you want to run parent effects before those of the children. E.g. when setting
// something up or binding document event listeners. By passing the effect to the first child it
// will run before any effects by later children.
export function Effect({ effect }) {
useEffect(() => effect?.(), [effect]);
return null;
}
//
const fs = require("fs");
// "4\n1\n2\n5\n3"
const input = fs.readFileSync(0).toString();
// [4, 1, 2, 5, 3]
const lines = input.split("\n").map((n) => parseInt(n, 10));
const T = parseInt(lines[0], 10);
@enepomnyaschih
enepomnyaschih / base64.js
Last active March 6, 2024 23:45
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@tylerchilds
tylerchilds / createScrollManager.js
Created June 4, 2019 02:02
Use requestAnimationFrame to handle scrolling smoothly
const createScrollManager = function() {
let callbacks = [];
let scrollPosition = -1;
let animatedKilled = false;
const animate = () => {
requestAnimationFrame(onScroll);
}
function onScroll(){
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
new UglifyJsPlugin({
uglifyOptions: {
compress: {
arrows: false,
booleans: false,
cascade: false,
collapse_vars: false,
comparisons: false,
computed_props: false,
hoist_funs: false,
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
@RubaXa
RubaXa / index.html
Created December 12, 2017 06:36
Repaint: offsetWidth vs. getBoundingClientRect (http://jsbench.github.io/#aed00af2bf5a7393a934c517018060b9) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Repaint: offsetWidth vs. getBoundingClientRect</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>