Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@l2ysho
l2ysho / get.memory.ts
Last active January 25, 2021 09:00
Inspect Memory Usage in Node.js
import Joi from '@hapi/joi'
import { Request, Response, NextFunction } from 'express'
export const schema = Joi.object().keys({
body: Joi.object(),
query: Joi.object(),
params: Joi.object()
})
const formatMemmoryUsage = (data: any) => `${Math.round(data / 1024 / 1024 * 100) / 100} MB`
@l2ysho
l2ysho / app.ts
Last active January 6, 2021 07:40
sentry setup
const app = express()
Sentry.init({
dsn: process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENV,
debug: process.env.SENTRY_LOGGING === 'true' || false,
release: `${process.env.npm_package_name}@v${process.env.npm_package_version}`,
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Tracing.Integrations.Express({
@l2ysho
l2ysho / nmap.sh
Created January 3, 2021 22:24
set of usefull nmap commands
#scan network hosts
nmap -sP 192.168.1.0/24
#check open ports
nmap -sT 192.168.1.1
#check specific ports
nmap -sT -p 80,443 192.168.1.0/24
#check specific ports - stealth scan (without 3-way handshake)
@l2ysho
l2ysho / .npmrc
Created September 26, 2019 19:10
Usefull config files
save-exact=true
message="v%s"
@l2ysho
l2ysho / postgres.txt
Created September 26, 2019 18:53
Postgress usefull cli comands
pg_dump -U [user] -d [database] -h [host] -p [port] -f [filename] -O -F tar
pg_restore -O -d [database] [filename]
# -O => --no-owner => cancel ownership of object to match original db
# -F => --format => tar -> Output a tar-format archive suitable for input into pg_restore.
@l2ysho
l2ysho / morgan.ts
Last active January 15, 2020 09:15
express utils and middlewares
/**
* Logging with morgan
* Custom log format
* Logging to file from config
*/
import Morgan from 'morgan'
import config from 'config'
import path from 'path'
import * as rotator from 'file-stream-rotator'