Skip to content

Instantly share code, notes, and snippets.

View ackvf's full-sized avatar
🏡
Remote Fullstack Node.js / Frontend React.js

Qwerty (Vítězslav Ackermann Ferko) ackvf

🏡
Remote Fullstack Node.js / Frontend React.js
View GitHub Profile
@ackvf
ackvf / ComponentWithGenerics.ts
Last active October 9, 2024 10:57
React utils
// Jan 2023
/**
* Provides better intellisense for JSX Components at call-site by allowing them to accept additional generics.
*
* In some cases it also switches `onChange` handler from `(value: string) => void` to `(event: HTMLInputEvent<..>) => void`
* to be used with `useFormState()` hook's e.g. `onInputChange` which accepts `EventStub` (`(ev: { target: { name, value }}) => void`).
*
* @example
* interface FormState {a, b}
*
@ackvf
ackvf / README.md
Last active November 5, 2024 20:00
TS/JS utility functions

TS/JS utility functions

other gists
🔗 TypeScript type toolbelt
🔗 React utils


  • accessTrap - Object and Array Proxy to count number of property accesses to map used/unused properties. It maintains referential stability using a caching mechanism to not disrupt React.js render flow.
@ackvf
ackvf / README.md
Last active November 8, 2024 04:04
Bookmarklets and script snippets
@ackvf
ackvf / README.md
Last active January 26, 2024 05:10
Crypto scripts
@ackvf
ackvf / README.md
Last active April 13, 2022 16:26
eToro scripts

How to use this?

enable balance

Create new Bookmark

add new bookmark page

Edit Bookmark details

@ackvf
ackvf / README.md
Last active September 19, 2024 11:44
TypeScript type toolbelt
@ackvf
ackvf / CommService.ts
Created February 10, 2021 15:19
Services
import CoreAPIService from './CoreAPIService';
import { CommentInterface } from '../interfaces/requestInterface';
class CommService {
// CREATE
addCommentToRequest = async (requestId: number, data: FormData) =>
CoreAPIService.post(`comments/${requestId}`, data, { 'Content-Type': 'multipart/form-data' })
.then<CommentInterface>(response => response.data);
@ackvf
ackvf / compose-functions.ts
Last active April 29, 2020 11:42
Typed compose
/**
* @name compose
* @summary Composes Higher-Order-Functions from right to left so that they are executed from left to right.
* note: To compose Higher-Order-Components, use compose.ts
*
*
* @description
* Two overloads are available:
* A) Matches the composed signature of whole compose to the wrapped function.
* B) As an escape hatch, it is possible to explicitly define the resulting OuterSignature with a generic, ignoring the HOFs types.
@ackvf
ackvf / eventloop.js
Last active November 14, 2019 17:30
Understanding the Event Loop
function callback(arg) {
setTimeout(console.log, 0, arg, ' # 4 timeout ');
setImmediate(console.log, arg, ' # 5 immediate');
process.nextTick(console.log, arg, ' # 2 nextTick ');
(async () => { await undefined; console.log(arg, ' # 3 await '); })();
console.log(arg, '# 1 sync ');
}
setTimeout(callback, 0, ' # 4 timeout ');
setImmediate(callback, ' # 5 immediate');
@ackvf
ackvf / higherOrderComponent.tsx
Last active January 18, 2023 01:04
TypeScript sessions
import React from 'react';
import PropTypes from 'prop-types';
import { IMetricsServiceClient } from '@containers/App/model';
export interface IWithMetricsServiceClient {
metricsServiceClient: IMetricsServiceClient;
}