Skip to content

Instantly share code, notes, and snippets.

@sergio-august
sergio-august / httpExceptions.js
Created November 27, 2020 16:46
Better error handling in Express with HttpException classes (CommonJS version)
/* eslint-disable require-jsdoc */
/**
* All specific http exceptions should inherit this class
*/
class HttpException extends Error {
/**
*
* @param {number} status HTTP status code
* @param {string} message Error message
*/
@sergio-august
sergio-august / httpExceptions.ts
Created November 27, 2020 16:35
Better error handling in Express with HttpException classes
export abstract class HttpException extends Error {
status: number;
constructor(status: number, message: string) {
super(message);
this.status = status;
this.name = "HttpError";
}
}
export class HttpBadRequestException extends HttpException {
@sergio-august
sergio-august / nodejs-ubuntu-bind-port-80.md
Created April 2, 2020 10:39 — forked from drawveloper/nodejs-ubuntu-bind-port-80.md
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

@sergio-august
sergio-august / gist:30a5111b32e0d2845054c66bf97df045
Created September 5, 2019 21:22 — forked from palexander/gist:2975305
Compiling and running mosh on Dreamhost
# Thanks to @samsonjs for the cleaned up version:
# https://gist.github.com/samsonjs/4076746
PREFIX=$HOME
VERSION=1.2.3
# Install Protocol Buffers
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
tar -xf protobuf-2.4.1.tar.bz2
cd protobuf-2.4.1
@sergio-august
sergio-august / gist:4e928c54ac59e46f329f43a6f0181eaa
Created September 5, 2019 21:21 — forked from samsonjs/gist:4076746
Compiling and running mosh on Dreamhost
PREFIX=$HOME
VERSION=1.2.3
# Install Protocol Buffers
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
tar -xf protobuf-2.4.1.tar.bz2
cd protobuf-2.4.1
./configure --prefix=$PREFIX
make
make install

Два Git аккаунта

В папке ~/%userprofile%/.ssh/ должен быть config, ключи (публичные *.pub и не публичные без расширения) а так же known_hosts

Config :

# Personal Github
Host github.com
User __________
IdentityFile ~/.ssh/id_rsa
@sergio-august
sergio-august / app.js
Created October 8, 2018 21:30 — forked from arvis/app.js
Basic express and mongoose CRUD application
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, mongoose = require('mongoose')
, path = require('path');
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doGet(e){
return handleResponse(e);
}
// Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";