Skip to content

Instantly share code, notes, and snippets.

pranaysoni pranaysonisoft

Block or report user

Report or block pranaysonisoft

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pranaysonisoft /
Created Jul 6, 2019 — forked from NigelEarle/
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
pranaysonisoft / postgresql_recursive.sql
Created Aug 10, 2018 — forked from dankrause/postgresql_recursive.sql
An example of creating a recursive postgresql query to generate data about parent-child relationships within a single table.
View postgresql_recursive.sql
parent INTEGER
INSERT INTO test (id, parent) VALUES
(1, NULL),
(2, 1),
pranaysonisoft / index.js
Created Jun 21, 2018 — forked from zerbfra/index.js
node-postgres connection and query with async/await
View index.js
const pg = require('pg')
// create a config to configure both pooling behavior
// and client options
// note: all config is optional and the environment variables
// will be read if the config is not present
var config = {
user: '', // env var: PGUSER
database: '', // env var: PGDATABASE
password: '', // env var: PGPASSWORD
pranaysonisoft /
Created Jun 19, 2018 — forked from basharovV/
How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Express and Node

How to configure HTTPS with Lets Encrypt, Nginx reverse proxy, Express and Node

  1. Have a Node app ready for production.
  2. Create an app.js file in your project directory:
const express = require('express');
const path = require('path');
const app = express();

// Allow dotfiles - this is required for verification by Lets Encrypt's certbot
pranaysonisoft /
Created Jun 2, 2018 — forked from jjlorenzo/
Ubuntu 16.04 setup with NGINX http/2 and letsencrypt


This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.


After creating the server (droplet on DigitalOcean) log in with

pranaysonisoft / nginx.conf
Created May 5, 2018 — forked from Stanback/nginx.conf
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service ( of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
View nginx.conf
# Note (November 2016):
# This config is rather outdated and left here for historical reasons, please refer to for the latest setup information
# Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol
server {
listen 80;
listen [::]:80;
root /path/to/your/htdocs;
pranaysonisoft / nginx.overrides
Created May 4, 2018 — forked from kennwhite/nginx.overrides
Restart / Reload Nginx without Entering Sudo Password
View nginx.overrides
# Enter this command to create a sudoers override/include file:
# sudo visudo -f /etc/sudoers.d/nginx.overrides
# (Make sure you actually have this in your /etc/sudoers - Run `sudo visudo` to check)
# #includedir /etc/sudoers.d
# This file assumes your deployment user is `deploy`
# Nginx Commands
Cmnd_Alias NGINX_RESTART = /usr/sbin/service nginx restart
pranaysonisoft / ngxdis
Created May 4, 2018 — forked from fideloper/ngxdis
Nginx scripts for enable and disabling a site. This will create or destroy a symlink between a real config file in /etc/nginx/sites-available and a symlink in /etc/nginx/sites-enabled.
View ngxdis
#!/usr/bin/env bash
if [ $EUID -ne 0 ]; then
echo "You must be root: \"sudo ngxdis\""
exit 1
# -z str: Returns True if the length of str is equal to zero.
if [ -z "$1" ]; then
echo "Please choose a site."
pranaysonisoft /
Created Feb 15, 2018 — forked from cecilemuller/
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

You can’t perform that action at this time.