| React | Svelte | |
|---|---|---|
| Since | 2011 (before ES6) | 2016 (after ES6) |
| Type | Library (slower) | Compiler (faster) |
| Reactivity | Hooks, runtime | Plain variables, compile-time |
| Virtual DOM (2 DOMs) | Yes | No |
| Performance | Mostly ok, DOM diffing, easy to screw up | Very fast by default |
| Memory usage | High | Low |
This file contains hidden or 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 PathMe { | |
| moves: string[] = []; | |
| constructor() { | |
| this.moves = []; | |
| return this; | |
| } | |
| moveTo(x: number, y: number) { |
This file contains hidden or 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
| #!/bin/bash | |
| echo "Searching for rc packages..." | |
| matches=$(find / -type d -path "*/node_modules/rc" 2>/dev/null) | |
| echo -e "Checking for compromised versions...\\n" | |
| for match in $matches | |
| do | |
| egrep 'version\":\s*\"((1.2.9)|(1.3.9)|(2.3.9))' "$match/package.json" && echo -e $match\\n | |
| done |
This file contains hidden or 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
| #!/bin/bash | |
| partNo=$1 | |
| storeId=$2 | |
| notifyUrl=https://ntfy.sh/$3 | |
| FILE=$4/${partNo/\//-}-$storeId | |
| if [ ! -f "$FILE" ]; then | |
| echo "$FILE does not exist." | |
| echo -n "1" > $FILE | |
| fi |
- get hammersponn:
brew install --cask hammerspoon - drop the file into yout init.lua dir
- import & bind in your init.lua:
local toggleGoogleMeetMic = require('google-meet-mic')
hs.hotkey.bind({"shift"}, "F16", toggleGoogleMeetMic)
This file contains hidden or 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
| [user] | |
| name = Your Name | |
| email = [email protected] | |
| [alias] | |
| A = add -A | |
| a = add | |
| aa = add --all | |
| ae = add --edit | |
| ai = add --interactive | |
| amend = commit --amend -C HEAD |
This file contains hidden or 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
| Grundgesetz für Web Components | |
| ------------------------------ | |
| § 1 Web Components sind HTML-Elemente und müssen sich wie HTML-Elemente verhalten. Sie sind kein 1:1-Ersatz für andere Komponenten-Konzepte, sondern universelle, einfach zu benutzende Erweiterungen des HTML-Vokabulars. Ihre Attribute und APIs müssen so konzipiert sein, das sie HTML-Autoren nicht überraschen. Das stellt sicher, dass Web Components universelle Plugins sind, die in jedem Browser und Framework gut funktionieren. Insbesonders zu beachten ist: | |
| § 1.1 Web Components müssen einen nützlichen Use Case anbieten, der allein mit HTML-Mitteln umgesetzt werden kann. JavaScript-APIs können den Funktionionsumfang einer Web Component beliebig erweitern, dürfen aber nicht zur Pflicht werden (vgl. <video>). Das stellt sicher, dass jeder Mensch, der ein bisschen HTML kann, Web Components nutzen kann. | |
| § 1.2 Web Components müssen Fail-Safe sein. Sie dürfen keine JavaScript-Exceptions werfen sondern müssen wie native HTML-Elemente mit jeder Art von |
- Install
@module-federation/nextjs-mf.
yarn add @module-federation/nextjs-mf- Add resolutions to
package.json:
"resolutions": {
This file contains hidden or 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 Fibonacci(number: Int = 100) { | |
| val sequence = mutableListOf(0, 1, 1) | |
| val isPartOfSequence by lazy { sequence.contains(number) } | |
| init { | |
| require(number <= 0) { "Only positive integers allowed in Fibonacci sequence." } | |
| if (number > 1) { | |
| var old = 1; var current = 1; var next: Int | |
| while (current + (current / 2) <= number) { |
This file contains hidden or 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
| // Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
| // Remove any duplicates from an array of primitives. | |
| const unique = [...new Set(arr)] | |
| // Sleep in async functions. Use: await sleep(2000). | |
| const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
| // or | |
| const sleep = util.promisify(setTimeout); |
NewerOlder