Skip to content

Instantly share code, notes, and snippets.

View vbguard's full-sized avatar
:octocat:
I'm coding

Viktor Bulvarenko vbguard

:octocat:
I'm coding
View GitHub Profile
const allVisitsStream = visitsModel
.find()
.populate('contact')
.populate('helper')
.populate('helpRequest')
.cursor()
;
const transformer = (doc) => {
return {
@vbguard
vbguard / ecosystem.config.js
Created August 7, 2020 12:04
pm2 config file
module.exports = {
apps : [{
name: 'name',
script: 'index.js',
watch: true,
instances: 2,
exec_mode: "cluster",
env_production: {
"NODE_ENV": 'production',
"PORT": 20004
@vbguard
vbguard / mongoDBBackup.sh
Last active July 22, 2020 08:32
Backup mongo database with all collection to folder in shell
# (1) prompt user, and read command line argument
read -p "Run the backUp DB script now? (y|n) : " answer
# (2) handle the command line argument we were given
while true
do
case $answer in
[yY]* ) read -p "Enter DB port: " port
read -p "Enter DB name: " dbName
read -p "Enter output file path with name or name: " output
import React from 'react'
let firstRoute = true;
export default (getComponent) => class AsyncComponent extends React.Component {
static Component = null;
mounted = false;
// Remembers scroll positions based on location->key
@vbguard
vbguard / user.model.js
Created December 10, 2019 17:16
MongoDB user model methods
userSchema.virtual('tasks', {
ref: 'Task',
localField: '_id',
foreignField: 'owner'
})
userSchema.methods.toJSON = function () {
const user = this
const userObject = user.toObject()

Keybase proof

I hereby claim:

  • I am vbguard on github.
  • I am vbguard (https://keybase.io/vbguard) on keybase.
  • I have a public key ASD6O_2Jze0TjZh-NA6gKAuSCzXXj_gQA47nm4H3zxtWiQo

To claim this, I am signing this object:

@vbguard
vbguard / global npm package install
Created December 4, 2019 01:48
global npm package install
==== Web development ============
======= Mobile development ========
npm install expo-cli --global - start react-native (ios, androin, web)
======== AWS ========
npm install -g @aws-amplify/cli - AWS Auth + Host and other feature for Mobile
@vbguard
vbguard / nginx.conf
Created December 4, 2019 00:57
example domain nginx.conf
##
# Put this file in /etc/nginx/conf.d folder and make sure
# you have a line 'include /etc/nginx/conf.d/*.conf;'
# in your main nginx configuration file
##
##
# Redirect to the same URL with https://
##
@vbguard
vbguard / node_nginx_ssl.md
Created December 3, 2019 00:23 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

function checkAuth(nextState, replaceState) {
let { loggedIn } = store.getState();
// check if the path isn't dashboard
// that way we can apply specific logic
// to display/render the path we want to
if (nextState.location.pathname !== '/dashboard') {
if (loggedIn) {
if (nextState.location.state && nextState.location.pathname) {
replaceState(null, nextState.location.pathname);