Skip to content

Instantly share code, notes, and snippets.

const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const controlOut = document.getElementById('radious-output');
const control = document.getElementById('radious');
control.oninput = () => {
controlOut.textContent = r = control.value;
};
const mouse = { x: 0, y: 0 };
@hinell
hinell / ES2015 Var Destructuring.js
Last active June 8, 2019 13:34
Measures performance of the variable assignment by destructuring. See my post here: https://twitter.com/biteofpie/status/1137079144301379586
function bench (name, iterations = 500, fn) {
const t0 = performance.now();
for (let i = 0; i < iterations; i++) fn(i)
let d = performance.now() - t0;
d = Math.ceil(d);
let ops = iterations / d;
document.documentElement.style.height =
document.documentElement.style.width =
document.body.style.height =
document.body.style.width = "100%"
canvas = document.createElement(`canvas`);
canvas.canvasRes = function (){
var {width, height} = document.body.getBoundingClientRect();
var d = document.body.getBoundingClientRect();
canvas = this;
/*****************************
* Collect tracks v.2
* Collecting tracks for the purpose of exporting them into archive
*/
console.clear()
HTMLElement.prototype.$ = HTMLElement.prototype.querySelector
HTMLElement.prototype.$$= HTMLElement.prototype.querySelectorAll
NodeList.prototype.map = Array.prototype.map;
String.prototype.contains = function(str){ return new RegExp(str).test(this) }
/********************
Name : SC.Tracks snippet
Version : 0.1.2
Last-Modified : 18.04.19
Description :
The programm walks over tracks:
Tracks.nodes = [
1track
2track <---- tracks.current
3track
#!sh
#--------<SETTING UP DEFAULT FOLDERS>--------
BackUpFolder=/e/Backup;
BackUpFolderUser=$BackUpFolder/user;
echo "| Info"
echo "| Script : User Files Backup script"
echo "| AUTHOR : Alexnader Davronov"
@hinell
hinell / MouseEventX.ts
Created February 2, 2019 19:35
MouseEventX
// Interface for relative cursor position calculation
const MouseEventX = class extends MouseEvent {
constructor(name, init, target){
super(name, init)
if(target instanceof HTMLElement){
let tRect = target.getBoundingClientRect();
tRect.widthHalf = tRect.width / 2;
tRect.heigtHalf = tRect.height/ 2;
// Local cursor coordinates
let x = init.clientX - tRect.x;
@hinell
hinell / list of state management tools.md
Last active December 5, 2019 14:11
Modern state management tools for JavaScript and TypeScript

COMPREHENSIVE MODERN LIST OF DATA STATE MANAGEMENT TOOLS

Updated: June 2019 Author: github@Hinell

TOOL DESCRIPTION
[setState][setState] Basic tool built in React library
[MobX][MobX] Simple, scalable state management.
[MobX-State-Tree][MobX-State-Tree] Model Driven State Management
[Redux][Redux] Predictable state container for JavaScript apps

Approximate translation of the Old Russian wedding song - Ты река ль, моя реченька.

Wedding folk song (Novgorod state).

You are my river, aren't you(?)
You are so calmly running
You are my child, aren't you(?)
You are sitting and don't smiling