Skip to content

Instantly share code, notes, and snippets.

/**
* Generic emitter of events.
*/
export interface IListenerObject {
listener: any;
remove: any;
}
export class EventSource<T> {
private listeners: Array<{

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

@shobhitsharma
shobhitsharma / ssl-localhost-webpack.md
Last active August 7, 2023 09:13
SSL support for localhost with Webpack

HTTPS using localhost

To generate a local certiticate and using it, please follow these steps (note: replace MY_DOMAIN, MY_FILENAME and MY_PASSPHRASE based on your choice):

Step 1: Generate private key

openssl genrsa -out MY_FILENAME.key 4096
@shobhitsharma
shobhitsharma / Instructions.md
Created October 12, 2018 21:26 — forked from pgilad/Instructions.md
Generate SSL Certificate for use with Webpack Dev Server (OSX)

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \
'use strict';
var Assert = {};
Assert.GE = function(key, value, bound) {
if (!Number.isInteger(value)) throw new Error(key + ' must be an integer');
if (!Number.isInteger(bound)) throw new Error(key + ' bound not an integer');
if (value < bound) throw new Error(key + ' must be at least ' + bound);
};
@shobhitsharma
shobhitsharma / config.md
Created September 7, 2018 19:54 — forked from 0XDE57/config.md
Firefox about:config privacy settings

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable.

I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

@shobhitsharma
shobhitsharma / nginx-tuning.md
Created August 21, 2018 21:23 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@shobhitsharma
shobhitsharma / letsencrypt.md
Created August 17, 2018 11:07 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@shobhitsharma
shobhitsharma / ultimate-ut-cheat-sheet.md
Created August 15, 2018 20:15 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@shobhitsharma
shobhitsharma / flex.md
Created August 9, 2018 22:43
Flexbox Guide

The Complete Illustrated Flexbox Tutorial

When I started to learn flex I wanted to see everything it was capable of. But when it came to examples of all properties, visually I wasn’t able to find a thorough tutorial. So, I created these diagrams that offer a bird’s 🐦 eye view.

If you wish to support my work, CSS Visual Dictionary is my book. All diagrams in this tutorial were taken directly from the manuscript!