Skip to content

Instantly share code, notes, and snippets.

@Samjin
Samjin / express4-response-methods.js
Last active October 6, 2022 07:02 — forked from prof3ssorSt3v3/app.js
Express Sending Responses of various types from YouTube tutorial.
"use strict";
// https://expressjs.com/en/4x/api.html#res
const express = require("express");
const app = express();
const port = process.env.port || 3000;
app.set("view engine", "pug");
app.set("views", process.cwd() + "/views");
app.get("/", (req, res) => {
//handle route: get requests for "/"
const dns = require('dns');
const http = require('http');
const https = require('https');
const tls = require('tls');
const net = require('net');
const request = require('request');
const httpAgent = new http.Agent();
const httpsAgent = new https.Agent();
@Samjin
Samjin / headers-timeout-keep-alive.js
Created December 15, 2021 17:28 — forked from shuhei/headers-timeout-keep-alive.js
A test case for server.headersTimeout + keep alive (fails on Node v10.15.2 and newer)
const http = require("http");
const net = require("net");
const server = http.createServer((req, res) => {
req.resume();
res.end("hello");
});
server.keepAliveTimeout = 6 * 1000;
server.headersTimeout = 4 * 1000;
@Samjin
Samjin / UV_THREADPOOL_SIZE.md
Created September 2, 2021 22:11 — forked from rjoydip-zz/UV_THREADPOOL_SIZE.md
How you can set `UV_THREADPOOL_SIZE` value?

When you need to set value to "UV_THREADPOOL_SIZE"?

  • Libuv has a default thread pool size of 4, and uses a queue to manage access to the thread pool - the upshot is that if you have 5 long-running DB queries all going at the same time, one of them (and any other asynchronous action that relies on the thread pool) will be waiting for those queries to finish before they even get started.

  • Note, however, that tuning UV_THREADPOOL_SIZE may make more sense for a standalone application like a CLI written in Node.js. If you are standing up a bunch of Node.js processes using the cluster module then I would be surprised if tuning UV_THREADPOOL_SIZE was particularly beneficial for you. But if your application resembles the web tooling benchmarks then tuning UV_THREADPOOL_SIZE may help with performance.

@Samjin
Samjin / multiple_ssh_setting.md
Created April 6, 2017 07:22 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"