Skip to content

Instantly share code, notes, and snippets.

View milichev's full-sized avatar

Vadym Milichev milichev

View GitHub Profile
@milichev
milichev / README.md
Created November 14, 2024 15:31
Jest Matchers

Jets Matchers

Examples

Expect Matchers

expect(response).toEqualDeeplyContaining({status: 'OK', body: { orders: [{ id: 1}]}});
@milichev
milichev / TrackChangedDepsComponent.tsx
Created November 13, 2024 14:41
How to track the changed React hook deps between renders
// create an object with all the hook deps
const debug = useRef({
currentCampaignId,
data: getCampaignQuery.data,
getValues,
isInitialFormDataSettled,
reset,
setValue,
stepsData,
storageStepsState,
@milichev
milichev / eslint-ignore.js
Last active January 24, 2022 10:59
suppress react-hooks eslint warnings
/**
* Accepts eslint `stdout` and processes all error messages related to React Hooks, if any.
*
* Essentially, the "fix" is only about adding a respective `eslint-disable-line` comments to mute the error unless it is addressed appropriately.
*
* Requires the following modules available:
* - lodash
*
* Usage:
*
@milichev
milichev / Set-TextAnsiCodes.psm1
Last active April 24, 2020 23:55
ANSI Colors
<#
.SYNOPSIS
Provides possibility to colorize text in console using ANSI sequences.
#>
using namespace System.Drawing
function ToColor {
[CmdletBinding()]
param (
@milichev
milichev / InstallUtils.psm1
Created April 16, 2020 13:34
PowerShell utilities
#region Scripting
function Test-IsConsoleHost {
@('ConsoleHost', 'Visual Studio Code Host') -contains ($host.name)
}
function Get-PromptParam {
[CmdletBinding()]
param (
[string] $name,
const pipeData = function(fn) {
return function(data) {
return Promise.resolve(fn(data)).then(function(res) {
if (res === void 0) {
return data;
}
const keys = Object.keys(res).filter(function(prop) {
return res.hasOwnProperty(prop);
});
return Promise.all(keys.map(function(prop) {
@milichev
milichev / replaceAbsoluteImports.js
Created December 27, 2018 01:21
Traverses .ts source files in a project and replaces all absolute imports with aliases to relative ones, according to paths in tsconfig.json
const fs = require("fs");
const path = require("path");
const globby = require("globby");
const srcPath = fn("../src");
const aliases = getAliases();
(async () => {
const files = await findFiles();
files
@milichev
milichev / ReactComponent.tsx
Created May 17, 2018 12:16
WebStorm Templates
import * as React from 'react';
export interface ${NAME}Props {
}
interface ${NAME}State {
}
export class ${NAME} extends React.Component<${NAME}Props, ${NAME}State> {
@milichev
milichev / 1 source.json
Last active November 30, 2017 18:39
BIC surveys
[
{
"surveytype": "BICBD",
"surveyid": 173,
"bisid": 94,
"countryid": 1,
"countryname": "United States",
"countrycode": "US",
"industryid": 17,
"industryname": "Traditional Retail Banks",
@milichev
milichev / cassandra.yaml
Last active November 16, 2017 03:54
Connection problem with Cassandra datastax nodejs-driver
# Cassandra storage config YAML
# NOTE:
# See http://wiki.apache.org/cassandra/StorageConfiguration for
# full explanations of configuration directives
# /NOTE
# The name of the cluster. This is mainly used to prevent machines in
# one logical cluster from joining another.
cluster_name: 'Test Cluster'