Skip to content

Instantly share code, notes, and snippets.

let index = 0;
function getIndex(): number {
index += 1;
return index;
}
const mapPointerToMap = new WeakMap<TPointer, number>();
type TPointer = object | unknown[];
export function createKeyByPointers(...pointers: TPointer[]): string {
@AStaroverov
AStaroverov / gist:56448f9baa560b4b7489ecf8ca0c36c8
Created May 16, 2019 14:25
preHTML - wrapper function fo dynamic tags lit-html
import { html } from 'lit-element';
import { TemplateResult } from 'lit-html';
let str: string;
let valuesLength: number;
const cacheTemplateStringsToPreparedTemplateStrings = new WeakMap<TemplateStringsArray, string[]>();
const cacheTemplateStringsToNeedlessValuesIndexes = new WeakMap<TemplateStringsArray, number[]>();
// Сonvert dynamic tags to template strings
@AStaroverov
AStaroverov / preHTML
Created September 26, 2018 10:11
lit-html with dynamic tags
import { html } from '@polymer/lit-element/src/lit-element';
let string: string;
let valuesLength: number;
export function preHTML (strings: TemplateStringsArray, ...values: any[]) {
const newStrings: string[] = [];
const newValues: any[] = [];
valuesLength = values.length;
@AStaroverov
AStaroverov / gist:a7f00829a5e2a1186a28b0f49dfaa51f
Created April 27, 2018 08:54
EventEmitter with fastest off
const TIME_PER_FRAME_FOR_GC = 5; // 5 mc
const rIC = window.requestIdleCallback || window.setTimeout;
const noop = () => {};
const getTime = () => window.performance.now();
export class Emitter {
constructor () {
this._destroyed = false;
this._eventsForGC = new Set();
this._mapEventToFnWrapper = new Map();
@AStaroverov
AStaroverov / js
Last active August 3, 2017 13:35
JS decorator: async extend class
import forEach from 'lodash/lodash'
class Defer {
constructor () {
this.resolve = null
this.reject = null
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve
this.reject = reject
function importScript (path) {
var tag = 'script'
var scriptTag = document.createElement(tag),
firstScriptTag = document.getElementsByTagName(tag)[0];
scriptTag.src = path
firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag);
}
importScript('https://rawgit.com/AStaroverov/Scheduler/master/Scheduler.js')
general {
output_format = "i3bar"
colors = true
interval = 5
}
order += "wireless wlan0"
order += "ethernet eth0"
order += "battery 0"
order += "cpu_temperature 0"
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!