Skip to content

Instantly share code, notes, and snippets.

View DrPep's full-sized avatar

Nigel Pepper DrPep

View GitHub Profile
@DrPep
DrPep / app.e2e-spec.ts
Created October 22, 2021 23:18 — forked from firxworx/app.e2e-spec.ts
NestJS Integration/E2E Testing Example with TypeORM, Postgres, JWT
import { Test, TestingModule } from '@nestjs/testing'
import { INestApplication, LoggerService } from '@nestjs/common'
import * as request from 'supertest'
import { AppModule } from './../src/app.module'
class TestLogger implements LoggerService {
log(message: string) {}
error(message: string, trace: string) {}
warn(message: string) {}
debug(message: string) {}
@DrPep
DrPep / zsh-elapsed-time.md
Created July 25, 2021 17:05 — forked from knadh/zsh-elapsed-time.md
Elapsed and execution time for commands in ZSH

Elapsed and execution time display for commands in ZSH

Append this to your ~/.zshrc file.

function preexec() {
 timer=$(($(date +%s%0N)/1000000))
@DrPep
DrPep / GenerateDataKeyPairConversion.js
Created January 26, 2021 23:33 — forked from mlmitch/GenerateDataKeyPairConversion.js
Convert AWS KMS GenerateDataKeyPair Output to PEM in NodeJS
const AWS = require('aws-sdk')
const Crypto = require('crypto')
AWS.config.region = 'us-east-1'
var kms = new AWS.KMS()
keyArn = 'Put AWS KMS Key ARN Here'
// Set the KeyPairSpec to the type of key you want to generate.
@DrPep
DrPep / jwtRS256.sh
Created December 1, 2020 17:27 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@DrPep
DrPep / Knex-Migrations-Seeding.md
Created June 10, 2020 00:15 — forked from NigelEarle/Knex-Migrations-Seeding.md
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@DrPep
DrPep / install-nvm-zsh.txt
Created January 5, 2020 01:41 — forked from mike-casas/install-nvm-zsh.txt
install nvm on mac with zsh shell
After install zsh
- brew update
- brew install nvm
- mkdir ~/.nvm
after in your ~/.zshrc or in .bash_profile if your use bash shell:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
@DrPep
DrPep / generate.js
Created August 7, 2019 22:15
Documentation for Kubernetes Javascript Client Functions
const request = require('request-promise-native')
const fs = require('fs')
const util = require('util')
const log_file = fs.createWriteStream(__dirname + '/kubernetes-client-functions.md', { flags: 'w' })
log = function (d) {
//
log_file.write(util.format(d) + '\n')
}
@DrPep
DrPep / Error-Handling-Patterns-Express.md
Created February 20, 2019 23:48 — forked from zcaceres/Error-Handling-Patterns-Express.md
error handling patterns in Express

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@DrPep
DrPep / docker-cheat-sheat.md
Created August 30, 2018 19:07 — forked from dwilkie/docker-cheat-sheat.md
Docker Cheat Sheet

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes

@DrPep
DrPep / Knex-Setup.md
Created May 4, 2018 00:12 — forked from NigelEarle/Knex-Setup.md
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init