Skip to content

Instantly share code, notes, and snippets.

View vladi-strilets's full-sized avatar

Volodymyr Strilets vladi-strilets

  • Europe
View GitHub Profile
@vladi-strilets
vladi-strilets / db.js
Last active April 5, 2020 17:46
mongodb client handler node.js
// db.js
const MongoClient = require("mongodb").MongoClient;
const url = "YOUR_URL";
var client;
const getClient = async () => {
if (client && client.isConnected()) {
console.log("DB CLIENT ALREADY CONNECTED");
@vladi-strilets
vladi-strilets / someroute.js
Last active April 5, 2020 18:08
mongodb client handler node.js #2
// routes/someroute.js
const express = require("express");
const router = express.Router();
const getClient = require("../db");
router.get("/", async (req, res) => {
try {
const client = await getClient();
const db = client.db("YOUR_BD_NAME");
const collection = db.collection("YOUR_COLLECTION_NAME");
@vladi-strilets
vladi-strilets / HistoryListener.js
Last active August 25, 2020 18:49
Dispatch redux action on history location route change with React Router v5
// HistoryListener.js
import React, { useEffect, useState } from "react";
import { connect } from "react-redux";
import { useHistory } from "react-router-dom";
import { someAction } from "./../redux/someReducer/actions";
const HistoryListener = ({
children,
// MDTP
@vladi-strilets
vladi-strilets / install-zsh-windows-git-bash.md
Created September 29, 2021 20:36 — forked from fworks/install-zsh-windows-git-bash.md
Zsh / Oh-my-zsh on Windows Git Bash
@vladi-strilets
vladi-strilets / FormInputController.tsx
Last active December 15, 2023 19:18
Custom reusable controller for react-hook-form and TypeScript + NativeBase
import { FormControl, Input } from 'native-base'
import React from 'react'
import {
Control,
Controller,
FieldError,
Path,
RegisterOptions,
} from 'react-hook-form'