Skip to content

Instantly share code, notes, and snippets.

View mauricionobrega's full-sized avatar
:shipit:
Focusing

Mauricio Nobrega mauricionobrega

:shipit:
Focusing
View GitHub Profile
@mauricionobrega
mauricionobrega / tuning_nginx_nodejs
Created June 26, 2018 20:24 — forked from carlessistare/tuning_nginx_nodejs
Tuning Nginx for heavy loading with nodejs as upstream. Short requests and a lot of concurrence.
# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 8;
# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# "Max clients" is also limited by the number of socket connections available on the system (~64k)
# run ss -s and u'll see a timewait param
# The reason for TIMED_WAIT is to handle the case of packets arriving after the socket is closed.
@mauricionobrega
mauricionobrega / index.js
Created June 23, 2018 00:26 — forked from marcusgadbem/index.js
Middleware to minify HTML output for express template render engines in which supports callbacks
/* app/controllers/index.js */
module.exports.index = function(req, res) {
res.render('index.html');
};
@mauricionobrega
mauricionobrega / fullParallel.js
Created June 17, 2018 20:35 — forked from telekosmos/fullParallel.js
Asynchronous control flow in node.js
// FullParallel businessLogichronous engine
function fullParallel(callbacks, last) {
var results = [];
var result_count = 0;
callbacks.forEach(function(callback, index) {
callback( function() {
results[index] = Array.prototype.slice.call(arguments);
function getSubdomain(h) {
var parts = h.split(".");
if(parts.length == 2) return "www";
return parts[0];
}
//later on...
exports.index = function(req, res) {
var subdomain = getSubdomain(req.headers.host);
res.render('index', { title: 'Express', subdomain:subdomain });
@mauricionobrega
mauricionobrega / ultimate-ut-cheat-sheet.md
Created May 2, 2018 13:26 — 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


@mauricionobrega
mauricionobrega / middleware-test.js
Created April 25, 2018 14:22 — forked from CodeVachon/middleware-test.js
express middleware mocha test
var middleware = require('middleware'), // the Middleware you want to test
httpMocks = require('node-mocks-http'), // quickly sets up REQUEST and RESPONSE to be passed into Express Middleware
request = {}, // define REQUEST
response = {} // define RESPONSE
;
describe('Middleware test', function(){
context('Valid arguments are passed', function() {
beforeEach(function(done) {
/*
@mauricionobrega
mauricionobrega / curl.md
Created March 28, 2018 13:04 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

[
"AzkabanCoders.dustjs",
"Dart-Code.dart-code",
"EditorConfig.EditorConfig",
"aaron-bond.better-comments",
"eriklynd.json-tools",
"gerane.Theme-Dark-Dracula",
"kumar-harsh.graphql-for-vscode",
"redhat.java",
"vscjava.vscode-java-debug",
{
"editor.rulers": [80,120],
"editor.tabSize": 2,
"explorer.autoReveal": false,
"explorer.enableDragAndDrop": false,
"explorer.openEditors.visible": 0,
"search.useIgnoreFiles": true,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.exclude": {
{
"editor.tabSize": 2,
"explorer.autoReveal": false,
"explorer.enableDragAndDrop": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,