Skip to content

Instantly share code, notes, and snippets.

@batazo
batazo / index.html
Created September 27, 2024 10:59
ZIP IMAGE WITH JS
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>IMAGE ZIP</title>
</head>
<body>
<button class="download_button">LETÖLTÉS</button>
@batazo
batazo / react+18.3.1.patch
Created June 22, 2024 20:46
React useBetterState diff patch
diff --git a/node_modules/react/cjs/react.development.js b/node_modules/react/cjs/react.development.js
index 8735990..6cc608f 100644
--- a/node_modules/react/cjs/react.development.js
+++ b/node_modules/react/cjs/react.development.js
@@ -1621,6 +1621,11 @@ function useState(initialState) {
var dispatcher = resolveDispatcher();
return dispatcher.useState(initialState);
}
+function useBetterState(initialState) {
+ var dispatcher = resolveDispatcher();
@batazo
batazo / .gitlab-ci.yml
Created January 24, 2024 00:33 — forked from transitive-bullshit/.gitlab-ci.yml
GitLab CI Detox React Native Example
stages:
- E2E
.ios_base:
tags:
- macOS
- swiftlint
cache:
paths:
- node_modules
@batazo
batazo / PrivateInstanceMethods.js
Created July 3, 2022 19:10
Private instance methods and accessors
class Banner extends HTMLElement {
// Private variable that cannot be reached directly from outside, but can be modified by the methods inside:
#slogan = "Hello there!"
#counter = 0
// private getters and setters (accessors):
get #slogan() {return #slogan.toUpperCase()}
set #slogan(text) {this.#slogan = text.trim()}
@batazo
batazo / Class-static.js
Created July 3, 2022 19:07
STATIC FIELDS
class Translator {
static translations = {
yes: 'ja',
no: 'nein',
maybe: 'vielleicht',
};
static englishWords = [];
static germanWords = [];
static { // (A)
for (const [english, german] of Object.entries(this.translations)) {
@batazo
batazo / Temoral-Function.js
Created July 3, 2022 19:00
Temporal Functions
const date = Temporal.Now.plainDateISO(); // Gets the current date
date.toString(); // returns the date in ISO 8601 date format
// If you additionally want the time:
Temporal.Now.plainDateTimeISO().toString(); // date and time in ISO 8601 format
@batazo
batazo / Class static initialization blocks.js
Created July 3, 2022 18:54
Class static initialization blocks
class User {
isActive = false;
get getStatus(){
if(!this.#isActive){
throw new Error('User is not active');
}
return this.#isActive;
}
}
@batazo
batazo / error.cause.js
Created July 3, 2022 18:48
error.cause
try {
const result = 2 / 0;
console.log(result);
} catch (error) {
console.err(error);
throw new Error('Something went wrong', { cause: error });
}
@batazo
batazo / RegExp match indices.js
Created July 3, 2022 18:45
RegExp match indices
const fruits ="Fruits:apples, oranges, pears";
const regex = /(apples)/gd;
const matches = [...fruits.matchAll(regex)];
console.log(matches[0]);