Skip to content

Instantly share code, notes, and snippets.

View iampeterbanjo's full-sized avatar
💭
Error24: not enough hours in the day

Peter Banjo iampeterbanjo

💭
Error24: not enough hours in the day
View GitHub Profile

Note: for Jest to detect a memory leak and throw an error both arguments are required i.e. detectLeaks and logHeapUsage.

10:45 nestjs-cats (master) ✗ yarn test --detectLeaks --logHeapUsage
yarn run v1.17.3
$ jest --detectLeaks --logHeapUsage
 PASS  src/auth/auth.controller.spec.ts (61 MB heap size)
 PASS  src/cats/cats.service.spec.ts (61 MB heap size)
 PASS  src/app.controller.spec.ts (61 MB heap size)
 FAIL  src/cats/cats.controller.spec.ts
let character = {};
updateCharacter = (path, value) => {
character[path] = value;
}
const Character = function() {
this.moves = [];
this.firstName = ''
this.lastName = ''
(function() {
console.log('Hello from the snippet');
const user = {
name: 'Cassie Cage'
};
const exampleTarget = {
firstname: 'Cassie',
surname: 'Cage',
};
@iampeterbanjo
iampeterbanjo / pull-data-processing.js
Created May 31, 2019 14:13
Pull data processing pipeline
/*
* Prototype of a data processing pipeline
* that uses strings as an example.
* the idea is to be fault tolerant by processing
* each word and so allow filtering of bad data
* instead of a batch processing approach
* which can cause the pipeline to halt on errors
* without any good data make it through to
* completion.
*/
@iampeterbanjo
iampeterbanjo / aws-password-change.sh
Created May 30, 2018 06:12
AWS change user password using CLI
# https://stackoverflow.com/a/45253010/95055
# Step 1: Get a session token for the desired user:
aws cognito-idp admin-initiate-auth --user-pool-id %USER POOL ID% --client-id %APP CLIENT ID% --auth-flow ADMIN_NO_SRP_AUTH --auth-parameters USERNAME=%USERS USERNAME%,PASSWORD=%USERS CURRENT PASSWORD%
# Step 2: Issue the challenge response:
aws cognito-idp admin-respond-to-auth-challenge --user-pool-id %USER POOL ID% --client-id %CLIENT ID% --challenge-name NEW_PASSWORD_REQUIRED --challenge-responses NEW_PASSWORD=%DESIRED PASSWORD%,USERNAME=%USERS USERNAME% --session %SESSION KEY FROM PREVIOUS COMMAND with ""%
@iampeterbanjo
iampeterbanjo / package.json
Created April 13, 2018 16:27
Node API boilerplate
{
"name": "node-api",
"version": "0.0.1",
"description": "Node API",
"keywords": ["Node.js", "API"],
"dependencies": {
"axios": "^0.16.2",
"cors": "^2.8.4",
"dotenv": "^4.0.0",
"express": "^4.15.3",
// setup test environment for jest and jsdom to
// allow code like window.location.href = '/'
// # setupEnvironment.js
const JSDOMEnvironment = require('jest-environment-jsdom');
module.exports = class JSDOMEnvironmentGlobal extends JSDOMEnvironment {
constructor(config) {
super(config);
@iampeterbanjo
iampeterbanjo / install-dokku.sh
Last active February 5, 2018 08:09
Install dokku
wget -nv -O - https://get.docker.com/ | sh
# setup dokku apt repository
wget -nv -O - https://packagecloud.io/gpg.key | apt-key add -
export SOURCE="https://packagecloud.io/dokku/dokku/ubuntu/"
echo "deb $SOURCE trusty main" | tee /etc/apt/sources.list.d/dokku.list
apt-get update
# install dokku
apt-get install dokku
@iampeterbanjo
iampeterbanjo / fix-zfs.sh
Created January 28, 2018 20:00
Fix zfs module not loading
sudo apt install zfs-dkms
sudo modprobe zfs
# replace 0.6.5.6 with your version of zfs
dkms remove -m zfs -v 0.6.5.6 --all
dkms remove -m spl -v 0.6.5.6 --all
dkms add -m spl -v 0.6.5.6
dkms add -m zfs -v 0.6.5.6
dkms install -m spl -v 0.6.5.6
dkms install -m zfs -v 0.6.5.6
@iampeterbanjo
iampeterbanjo / juju-localhost-bootstrap.sh
Last active January 28, 2018 19:52
Boostrap juju controller on localhost with LXD
sudo apt install lxd zfs zfsutils-linux
groups
newgrp lxd
sudo lxd init
juju bootstrap localhost lxd-controller