This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tag(selector, attrs, innerText = '') { | |
let _tag = selector.match(/^(\w[\w-_\d]*)/)?.[1]; | |
let _id = selector.match(/#([\w_]+[\w-_\d]*)/)?.[1]; | |
let _classes = Array.from(selector.matchAll(/\.([\w_]+[\w-_\d]*)/g)).map(m => m?.[1]); | |
let el = document.createElement(_tag ?? 'div'); | |
if (_id) { | |
el.setAttribute('id', _id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http2 = require('http2'); | |
const fs = require('fs'); | |
const zlib = require('zlib'); | |
let mimeTypes = require('mime-types'); | |
const server = http2.createServer(onRequest); | |
function getAsyncFileStream(filePath) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function() { | |
let textarea = document.getElementById('comment'); | |
let sc = document.createElement('div'); | |
sc.classList.add('autocomplete-suggestions'); | |
sc.setAttribute('autocomplete', 'off'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScrollCalendar extends HTMLElement { | |
connectedCallback() { | |
let observer = new IntersectionObserver((entries) => { | |
let el = entries[0]; | |
if (el.isIntersecting) { | |
observer.unobserve(this.firstElementChild); | |
observer.unobserve(this.lastElementChild); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface AnimationOptions { | |
stagger?: number; | |
} | |
NodeList.prototype.animate = function(keyframes: AnimationKeyFrame | AnimationKeyFrame[], options: number | AnimationOptions) { | |
const elements: HTMLElement[] = Array.prototype.slice.call(this); | |
(function next(elements: Array<HTMLElement>) { | |
if (elements.length < 1) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Inject, Injectable, InjectionToken, LOCALE_ID, Optional} from '@angular/core'; | |
import {DateAdapter} from '@angular/material'; | |
import {DateTime} from 'luxon/build/node/luxon'; | |
declare var DateTime: { | |
year: number; | |
month: number; | |
day: number; | |
weekday: number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function random(n, b = 0) { | |
return Math.random() * (b-n) + n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _randomBool(oddsOfTrue = 1) { | |
let r; while (!(r = !~~(Math.random() * 2)) && --oddsOfTrue > 0); | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'dataSize' | |
}) | |
export class DataSize implements PipeTransform { | |
private suffixes = ['KB', 'MB', 'GB', 'TB', 'EB', 'YB']; | |
// Specified input units (MB default (1000000)) |