Skip to content

Instantly share code, notes, and snippets.

View sandeep-cs-dev's full-sized avatar

Sandeep Patel sandeep-cs-dev

View GitHub Profile
@sandeep-cs-dev
sandeep-cs-dev / LetsEncrypt.md
Created November 19, 2018 10:20 — forked from davestevens/LetsEncrypt.md
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@sandeep-cs-dev
sandeep-cs-dev / http2server.node.js
Created December 12, 2019 19:21
Basic Http2 server nodejs
const http2 = require('http2');
const fs = require('fs')
let options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt'),
allowHTTP1: true
}
const server = http2.createSecureServer(options, function(req, res) {
@sandeep-cs-dev
sandeep-cs-dev / http2-client.js
Created December 12, 2019 19:34
Basic http2 client in nodejs
const http2 = require('http2');
const fs = require('fs')
let res = [];
let postbody = JSON.stringify({
message: "http2 client"
});
let baseurl = 'https://localhost:8080'
let path = '/'
let options = {
ca: fs.readFileSync('server.crt'),
@sandeep-cs-dev
sandeep-cs-dev / README-Template.md
Created December 23, 2019 21:25 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@sandeep-cs-dev
sandeep-cs-dev / sampleREADME.md
Created December 23, 2019 21:26 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@sandeep-cs-dev
sandeep-cs-dev / nginx-tuning.md
Created December 26, 2019 18:18 — 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.

const { Worker } = require("worker_threads");
const imageResizer = function (imagePath, size,outputPath) {
return new Promise((resolve, reject) => {
const worker = new Worker(__dirname + "/image-resize-worker.js", {
workerData: {imagePath:imagePath, size:size,outputPath:outputPath}
});
const { parentPort, workerData } = require("worker_threads");
const sharp = require("sharp");
async function resize() {
const { imagePath,size,outputPath } = workerData;
console.log("=======workerData======",workerData);
// sharp(imagePath).metadata().then((res)=>{
'use strict';
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const min = 2;
let primes = [];
function generatePrimes(start, range) {
let isPrime = true;
let end = start + range;
for (let i = start; i < end; i++) {
for (let j = min; j < Math.sqrt(end); j++) {
if (i !== j && i%j === 0) {
const encrptfile = require('./encrypt-file.js')
const filePath = __dirname+"/test.txt";
encrptfile(filePath).then(function(res){
console.log(res);
})