Skip to content

Instantly share code, notes, and snippets.

🕵️‍♂️
Processing..

Drewry Pope dezren39

🕵️‍♂️
Processing..
View GitHub Profile
@dezren39
dezren39 / 01-directory-structure.md
Created Jul 20, 2020 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.
View 01-directory-structure.md

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@dezren39
dezren39 / babel-webpack.md
Created Jul 6, 2020 — forked from ncochard/babel-webpack.md
The correct way to compile ES6 using babel...
View babel-webpack.md

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@dezren39
dezren39 / npm-module-version-check.sh
Created Jul 5, 2020
clearly there are options...
View npm-module-version-check.sh
# these can all be npm scripts, but anything can be an npm script
# a
echo $(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
# b
echo $(cat ./package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed -E 's/(version)|[:,\",]//g' | tr -d '[[:space:]]')
# c
echo $(node --eval="process.stdout.write(require('./package.json').version)")
View esm.js
require = require("esm")(module /*, options*/);
module.exports = require("./index.js");
View timeout3.sh
#!/bin/bash
#
# The Bash shell script executes a command with a time-out.
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
# is blocked, then the subsequent SIGKILL (9) terminates it.
#
# Based on the Bash documentation example.
# Hello Chet,
# please find attached a "little easier" :-) to comprehend
@dezren39
dezren39 / auto-commit-push-create-pr.sh
Created Jul 5, 2020
auto-commit-push-create-pr.sh
View auto-commit-push-create-pr.sh
#!/bin/bash
# Author: Drewry Pope
# Any copyright is dedicated to the Public Domain.
# https://creativecommons.org/publicdomain/zero/1.0/
if [ -z "$*" ] || [ -z "$1" ] || [ "$1" = "help" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "--h" ] ; then
printf '\n\nUsage:\n\n./auto-commit-push-create-pr.sh [--headless] <commit-msg> \n\n'
printf 'Prerequisites: '"'"'git'"'"', '"'"'gh'"'"' \n\n'
printf 'This script will: \n\n'
printf ' # \/ \/ Adds all files. Use care !! !! \n'
printf ' git add . \n\n'
@dezren39
dezren39 / 1.generate_dockerignore.py
Created Jul 5, 2020 — forked from wassname/1.generate_dockerignore.py
Convert .gitignore to .dockerignore: quick and dirty.
View 1.generate_dockerignore.py
"""
Convert .gitignore to .dockerignore: quick and dirty.
This is a quick and dirty script to convert this:
`__pycache__/`
Into this:
```
__pycache__
*/__pycache__
@dezren39
dezren39 / get-npm-package-version
Last active Jul 5, 2020 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
View get-npm-package-version
# these can all be npm scripts, but anything can be an npm script
# a
echo $(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
# b
echo $(cat ./package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed -E 's/(version)|[:,\",]//g' | tr -d '[[:space:]]')
# c
echo $(node --eval="process.stdout.write(require('./package.json').version)")
@dezren39
dezren39 / get-npm-package-version
Created Jul 5, 2020 — forked from yvele/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
View get-npm-package-version
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
echo $PACKAGE_VERSION
@dezren39
dezren39 / enable-detailed-monitoring-on-all-ec2.sh
Created May 12, 2020
Enable Detailed Monitoring for all EC2 Instances with PowerShell one-liner
View enable-detailed-monitoring-on-all-ec2.sh
aws ec2 monitor-instances --instance-ids (aws ec2 describe-instances | ConvertFrom-Json).Reservations.Instances.InstanceId
You can’t perform that action at this time.