Skip to content

Instantly share code, notes, and snippets.

View NickNaso's full-sized avatar
🎯
Focusing

Nicola Del Gobbo NickNaso

🎯
Focusing
View GitHub Profile
{
"targets": [
{
"target_name": "example_addon",
"sources": [ "example_addon.c" ],
"include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ],
"dependencies": [ "<!@(node -p \"require('node-addon-api').gyp\")" ]
}
]
}
@xameeramir
xameeramir / default nginx configuration file
Last active May 4, 2024 17:27
The default nginx configuration file inside /etc/nginx/sites-available/default
# Author: Zameer Ansari
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@indexzero
indexzero / bench.log
Created September 27, 2017 05:37
winston@3 gets very close to pino
Benchmark: ""pino"" is the fastest.
- winston1 faster than winston2 by 1.1696
- winston3 faster than winston1 by 1.5686
- bunyan faster than winston1 by 1.0245
- pino faster than winston1 by 1.8904
- winston3 faster than winston2 by 1.8347
- bunyan faster than winston2 by 1.1983
- pino faster than winston2 by 2.2109
- winston3 faster than bunyan by 1.5311
- pino faster than winston3 by 1.2051
@Mohamed3on
Mohamed3on / batchPrettier.md
Last active April 5, 2024 17:03
Run prettier on all JS files in a directory
  1. Install prettier
  2. Make a .prettierignore file, and add directories you'd like prettier to not format, for example: **/node_modules
  3. Run prettier --write "**/*.js" *Don't forget the quotes.
  4. Optional: if you want to format JSON/SCSS files too, replace js with json/scss.
@PurpleBooth
PurpleBooth / Dockerfile
Last active March 21, 2024 09:33
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@adrai
adrai / app.js
Last active November 13, 2023 08:40
aws-serverless-fastify
const fastify = require('fastify');
function init(serverFactory) {
const app = fastify({ serverFactory });
app.get('/', (request, reply) => reply.send({ hello: 'world' }));
return app;
}
if (require.main === module) {
// called directly i.e. "node app"

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

@chicoxyzzy
chicoxyzzy / nvm-node-nightlies.md
Last active February 6, 2024 16:44
Installing Node Nightlies via nvm

You can install Node Nightlies/RCs via nvm using NVM_NODEJS_ORG_MIRROR environment variable.

Install latest Node RC

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/rc/ nvm i node

Install latest Node.js Nightly

NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm i node
@NickNaso
NickNaso / proxy.js
Last active January 25, 2023 18:40
Log or modify the request body in the node-http-proxy before to pass it to the express.js application
/*******************************************************************************
* Copyright (c) 2017 Nicola Del Gobbo
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the license at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
* IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
* MERCHANTABLITY OR NON-INFRINGEMENT.
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js