Skip to content

Instantly share code, notes, and snippets.

View seniv's full-sized avatar
🐙

Ivan Seniv seniv

🐙
View GitHub Profile
const mongoose = require('mongoose');
class MongoManager {
constructor (config) {
this._config = config;
}
getMongoUrl() {
return this._config.MONGODB_URI;
}
connect () {
@seniv
seniv / nginxproxy.md
Created August 26, 2018 11:11 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@seniv
seniv / snippets.code-snippets
Created January 6, 2019 17:04
My VS Code snippets
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
"Import GraphQL Tag": {
"scope": "javascript,typescript,javascriptreact,typescriptreact",
"prefix": "imgql",
@seniv
seniv / BadApp.js
Last active October 21, 2019 19:49
Apollo Client performance
import React from 'react';
import { ApolloProvider, useSubscription } from '@apollo/react-hooks';
import { RootNavigator } from './navigation';
import { client } from './apollo';
import { mySubscription } from './graphql';
function App() {
useSubscription(mySubscription, {
// directly pass instance of apollo client because subscription used
// before ApolloProvider, and client cannot be taken from context
@seniv
seniv / pre_commit.sh
Created March 18, 2020 16:03
Block commits on master and develop branches (add to "pre-commit" hook)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ $BRANCH == 'develop' -o $BRANCH == 'master' ]
then
echo "ERROR: Making commits to master or develop branches are not allowed."
exit 1
fi