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
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 / 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

defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) };
existing_indexes = Model.collection.indexes.map { |i| i['key'].keys };
missing_indexes = defined_indexes - existing_indexes
# => []
extra_indexes = existing_indexes - defined_indexes - [['_id']]
# => []
#################################################################################
@vbguard
vbguard / macos+ntfs
Created October 4, 2019 21:47 — forked from exAspArk/macos+ntfs.sh
Mount writable NTFS disk with osxfuse + ntfs-3g
sudo mkdir /Volumes/NTFS
diskutil list
sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other
rsync -v --progress ~/Downloads/something /Volumes/NTFS/
sudo umount /Volumes/NTFS
@vbguard
vbguard / self-signed-ssl-mongo.sh
Created October 4, 2019 21:45 — forked from exAspArk/self-signed-ssl-mongo.sh
Self-signed SSL Certificate with OpenSSL on MacOS | MongoDB
openssl genrsa -out CAroot.key 2048
openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below
openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt
cat CAroot.crt CAroot.key > CAroot.pem
openssl genrsa -out mongod.key 2048
openssl req -new -key mongod.key -out mongod.csr
openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt
cat mongod.crt mongod.key > mongod.pem
@vbguard
vbguard / f2bufwnginx.md
Created May 16, 2019 11:23 — forked from Telling/f2bufwnginx.md
Setup fail2ban (v0.8.11) with ufw and nginx

Setup fail2ban (v0.8.11) with ufw and nginx on Ubuntu 14.04

Install fail2ban & ufw

If you haven't already, install fail2ban and ufw:

sudo apt-get install fail2ban ufw

Now make a copy of the fail2ban configuration, and name it jail.local:

const promisify = (func) => () => new Promise((resolve) => func(resolve));
const showBackground = (resolve) => {
setTimeout(() => {
console.log('showBackground works!!!');
resolve();
} , 3000);
};
const slideSidebar = (resolve) => {
@vbguard
vbguard / cors.nginxconf
Created March 26, 2019 14:25 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew cask install iterm2
# update iterm2 settings -> colors, keep directory open new shell, keyboard shortcuts
brew install bash # latest version of bash
# set brew bash as default shell
brew install fortune
brew install cowsay
brew install git
@vbguard
vbguard / webstoemp-gulpfile.js
Created January 11, 2019 07:07 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");