Skip to content

Instantly share code, notes, and snippets.

View 197291's full-sized avatar
:octocat:

Yuriy Provotorov 197291

:octocat:
  • Taganrog
View GitHub Profile
@197291
197291 / SQL_QUERY
Created April 1, 2020 10:39
SQL_QUERY_GET_OPERATING_HOURS
SELECT b.id as build_id, b.name, c.city_name
FROM public."Buildings" b LEFT JOIN
public."Cities" c
ON c.id = b.city_id JOIN
public."OperatingHours" h
ON h."BuildingId" = b.id JOIN
public."Reservations" r
on r."BuildingId"=b.id
WHERE c.id = 3
GROUP BY b.id, c.city_name
@197291
197291 / SQL_RANGE_QUERY
Created January 5, 2020 14:08
SQL_QUERY
SELECT b.id as build_id, b.name, c.city_name
FROM public."Buildings" b LEFT JOIN
public."Cities" c
ON c.id = b.city_id LEFT JOIN
public."OperatingHours" h
ON h."BuildingId" = b.id LEFT JOIN
public."Reservations" r
on r."BuildingId"=b.id
WHERE c.city_name = $city AND a.size = $size
GROUP BY b.id, c.city_name
{"lastUpload":"2019-09-29T13:46:35.234Z","extensionVersion":"v3.4.3"}
@197291
197291 / ProtectedRoute.jsx
Created July 1, 2019 20:26
Auth HOC, React.js
// Test every passed-in auth verification function.
const verifyAuth = (authCriteria, props) => {
if (authCriteria.length === 0) return true;
return authCriteria.every(criterion => criterion(props));
};
// Authentication HoC
const withAuth = ({
authCriteria = [],
redirectPath = '/',
@197291
197291 / React Hooks
Created June 27, 2019 18:10
React Hooks
const useFetch = (url) => {
const [data, setData] = useState(null);
useEffect(() => {
let mounted = true;
const abortController = new AbortController();
(async () => {
const res = await fetch(url, {
signal: abortController.signal,
});
const data = await res.json();
@197291
197291 / TSLInt-Prettier-CreateReactApp-TypeScript-setup.md
Created June 21, 2019 19:53 — forked from rimatla/TSLInt-Prettier-CreateReactApp-TypeScript-setup.md
Create React App + TypeScript Linting with TSLint and Prettier setup for on VSCode

Ps: The current setup was done on 01-04-19

Project Dependency Versions at the time 👇

  "react": "^16.7.0",
  "react-dom": "^16.7.0",
  "react-scripts": "2.1.3",
  "typescript": "^3.2.2"
  "tslint": "^5.12.0",
  "tslint-config-prettier": "^1.17.0",
export function logClass(target: Function) {
// Save link for original constructor
const original = target;
// function generate instance of class
function construct(constructor, args) {
const c: any = function () {
return constructor.apply(this, args);
}
c.prototype = constructor.prototype;
import * as React from 'react';
import { KeyCodeMap } from 'constants/core/key-code-map';
import { getComponentDisplayName } from 'helpers/common/get-component-display-name';
interface State {
selectedRowIndex: number;
mouseIndex: number;
scrollElement: any;
rowsLength: number;
function isCryptSolution(crypt, solution) {
const map = {};
for(let m of solution) {
map[m[0]] = m[1];
}
for(let i in crypt) {
const line = crypt[i];
type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>>
& { [K in Keys]-?:
Required<Pick<T, K>>
& Partial<Record<Exclude<Keys, K>, undefined>>
}[Keys]
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>>
& {