View nginx.conf
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
View restify-joi-validation.js
const {BadRequestError} = require('restify/lib/errors');
const Joi = require('joi');
module.exports = function validationPlugin() {
const fields = ['params', 'query', 'body'];
return function validationMiddleware(req, res, next) {
if (!req.route || !req.route.validate) {
return next();
}
View 1-restify-server-cheatsheet.js
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
View http-status-codes.md

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
View git-no-ff.sh
#!/bin/sh
git config --global merge.ff no
git config --global merge.commit no
# However, the problem with this is that git pull = git fetch + git merge.
# So whenever you pull from the remote server,
# you'd be creating an ugly merge commit when
# a simple fast-forward would be warranted.
# To solve this, set pull.ff to yes:
git config --global pull.ff yes
View zsh-recommendations.md

Installing

  1. install zsh on your Linux system
  2. install Oh-my-zsh

Recommended Plugins

plugins=(git gitfast web-search sudo node npm docker python pip django aws fabric common-aliases dirhistory fasd last-working-dir command-not-found)
View ipv4-apt.md

Force IPv4 Only apt-get (Ubuntu)

Once

sudo apt update -o Acquire::ForceIPv4=true

Permanent

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4