Skip to content

Instantly share code, notes, and snippets.

View domanskyi's full-sized avatar
⛰️

Valentyn Domanskyi domanskyi

⛰️
View GitHub Profile
@domanskyi
domanskyi / useCustomEventListener.ts
Created May 27, 2024 12:10
Simple React hook to propagade events to the parent componets using native events API
import { useCallback, useEffect } from 'react';
type TUseCustomEventListenerRes = {
dispatchEvent: (data: CustomEventInit) => void;
};
/**
* @name dispatchGlobalEvent
* @param {String} eventName The name of the event to dispatch
* @param {Array} meta Any optional data to pass to the event
const input = `$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
@domanskyi
domanskyi / cities.sql
Last active May 27, 2024 12:17
SQL with list of US cities (name, state code, state, county, lat, lon, population, status, country)
This file has been truncated, but you can view the full file.
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('New York','NY','New York','Queens',40.6943,-73.9249,18680025,'public','USA');
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('Los Angeles','CA','California','Los Angeles',34.1141,-118.4068,12531334,'public','USA');
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('Chicago','IL','Illinois','Cook',41.8375,-87.6866,8586888,'public','USA');
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('Miami','FL','Florida','Miami-Dade',25.784,-80.2101,6076316,'public','USA');
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('Dallas','TX','Texas','Dallas',32.7935,-96.7667,5910669,'public','USA');
INSERT INTO city(name,state_code,state,county,lat,lon,population,status,country) VALUES ('Houston','TX','Texas','Harris',29.786,-95.3885,5724418,'public','USA');
INSERT INTO city(name,s
@domanskyi
domanskyi / US_and_Canada_States.js
Last active May 27, 2024 12:24
List of US and Canada states
const states = {
'USA': [
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
@domanskyi
domanskyi / Readme.md
Last active May 27, 2024 12:12
package.json script with ordered params (MacOS, Linux)

Usage:

npm run example "hi there!"

reference