Skip to content

Instantly share code, notes, and snippets.

View unlight's full-sized avatar
💭
Casting fireball

Roman Vasilev unlight

💭
Casting fireball
View GitHub Profile
@Jaid
Jaid / migratingRules.md
Last active September 30, 2024 16:14
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
@tomhicks
tomhicks / plink-plonk.js
Last active November 12, 2024 19:08
Listen to your web pages
@jfcherng
jfcherng / st4-changelog.md
Last active August 18, 2024 07:25
Sublime Text 4 changelog just because it's not on the official website yet.
@WebReflection
WebReflection / differential-js-loader.md
Last active July 28, 2020 12:44
Differential JS Loader

This is an alternative to the Modern Script Loading tchnique, that doesn't need to wait for the load event.

Compatibility

This technique has been successfully tested down to IE9.

<!DOCTYPE html>
<html lang="en">
@WebReflection
WebReflection / inline-js-modules.js
Last active November 14, 2024 22:54
PoC: How to inline ES modules
const env = {
m1: `import {func} from './m2.mjs'; console.log(func());`,
m2: `export function func() { return 'abc'; }`
};
const inlineModule = (env, text) => `data:text/javascript;base64,${
btoa(inlineModules(env, text))
}`;
const inlineModules = (env, text) => text.replace(
@negue
negue / dynamic-loader.component.ts
Last active April 26, 2020 10:00
Lazy Component Loader
import {
Component,
ChangeDetectionStrategy,
ViewChild,
ViewContainerRef,
ComponentFactoryResolver,
Injector, Input, OnChanges,
SimpleChanges, EventEmitter, OnDestroy, Output, ChangeDetectorRef, OnInit
} from '@angular/core';
import {takeUntil} from 'rxjs/operators';
@jfet97
jfet97 / _objectsFlattening.js
Last active June 12, 2019 23:02
objects flattening
const obj = { a: { b: 1, c: 2, d: { e:4 , f:[1,2,3,4,5,6,7,8,9,0]} }, g:42 };
const res = Object.fromEntries(flatProps(objectRecursiveEntries(obj)));
/*
{
"a.b": 1,
"a.c": 2,
"a.d.e": 4,
"a.d.f.0": 1,
"a.d.f.1": 2,
@WebReflection
WebReflection / custom-elements-pattern.md
Last active May 17, 2024 23:30
Handy Custom Elements' Patterns

Handy Custom Elements' Patterns

Ricardo Gomez Angel Photo by Ricardo Gomez Angel on Unsplash

This gist is a collection of common patterns I've personally used here and there with Custom Elements.

These patterns are all basic suggestions that could be improved, enriched, readapted, accordingly with your needs.

@rufoa
rufoa / Jenkinsfile
Created May 13, 2019 02:29
Jenkins [skip ci] implementation for multi-branch declarative pipeline
// change 'agent' lines as appropriate
pipeline {
agent none
stages {
stage('Run CI?') {
agent any
steps {