Skip to content

Instantly share code, notes, and snippets.

@julienetie
julienetie / eslint.config.js
Created October 7, 2024 17:05
Standard JS flat config for ESLint 9.x: eslint.config.js
/*! eslint-config-standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
// Importing necessary ESLint plugins using ES module syntax
import pluginN from 'eslint-plugin-n'
import * as pluginImport from 'eslint-plugin-import'
import pluginPromise from 'eslint-plugin-promise'
import globals from 'globals'
const config = {
languageOptions: {
@julienetie
julienetie / class.csv
Created September 21, 2024 18:53
Class PL comparison
Language Inheritance Encapsulation Polymorphism Constructors Static Members Multiple Inheritance Method Overriding Method Overloading
C class NA NA NA NA NA NA NA NA
C++ class
C# class
Swift class
Zig class NA NA NA NA NA NA NA NA
Rust class NA NA NA NA NA NA NA NA
Go class NA NA NA NA NA NA NA NA
Odin class NA NA NA NA NA NA NA NA
D class
@julienetie
julienetie / structs.csv
Created September 21, 2024 18:52
Structs PL comparison
Language Inheritance Encapsulation Polymorphism Constructors Static Members Multiple Inheritance Method Overriding Method Overloading
C struct
C++ struct
C# struct
Swift struct
Zig struct
Rust struct
Go struct
Odin struct
D struct
@julienetie
julienetie / structs-classes.csv
Last active September 21, 2024 19:01
Structs vs Classes
Language Inheritance Encapsulation Polymorphism Constructors Static Members Multiple Inheritance Method Overriding Method Overloading
C struct
C class NA NA NA NA NA NA NA NA
C++ struct
C++ class
C# struct
C# class
Swift struct
Swift class
Zig struct
@julienetie
julienetie / husky-pnpm-pre-commit-error-on-linux
Last active March 24, 2024 04:25
husky-pnpm-pre-commit-error-on-linux
See comments
@julienetie
julienetie / detect-browser.js
Last active April 5, 2024 12:47
Detect the operating system (os), browser and browser version without relying on depreciated ways.
const navigatorErrorMessage = 'Could not find `userAgent` or `userAgentData` window.navigator properties to set `os`, `browser` and `version`'
const removeExcessMozillaAndVersion = /^mozilla\/\d\.\d\W/
const browserPattern = /(\w+)\/(\d+\.\d+(?:\.\d+)?(?:\.\d+)?)/g
const engineAndVersionPattern = /^(ver|cri|gec)/
const userAgentData = window.navigator.userAgentData
const userAgent = window.navigator.userAgent
const unknown = 'Unknown'
const empty = ''
const brandList = ['chrome', 'opera', 'safari', 'edge', 'firefox']
.parent-selector {
background: lime;
> .child-selector {
color: crimson;
}
}
@julienetie
julienetie / comments.json
Last active March 30, 2023 14:34
Comments JSON
[
{
"id": "5a6ce86d2af929789500e7ca",
"author": "Edsger W. Dijkstra",
"quote": "The computing scientist’s main challenge is not to get confused by the complexities of his own making."
},
{
"id": "5a6ce86f2af929789500e7f3",
"author": "Edsger W. Dijkstra",
"quote": "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
import { pasteInto } from '../../anti-framework.js'
let n = 0
// The view callback prevents conditions and loops and operators at runtime.
const counterView = pasteInto('#root', ({ n }) => `
<button value="-">-</button>
<button value="+">+</button>
<span>${n}</span>
`)
@julienetie
julienetie / calculate-linear-regression.js
Created March 24, 2022 00:59
Linear Regression experiment
//const data = [1.5, 3.8, 6.7, 9.0, 11.2, 13.6, 16]
const data = [4, 4, 3, 5, 4, 3, 2, 2, 3, 4, 1, 1, 3]
const x = data.map((_, i) => i + 1)
const y = data
const xy = data.map((value, i) => (i + 1) * value)
const xPow2 = data.map((_, i) => (i + 1) ** 2)
//const sumOfX =data.reduce((acc, _, i) => acc + i