Skip to content

Instantly share code, notes, and snippets.

View dezren39's full-sized avatar
🕵️‍♂️
Processing..

Drewry Pope dezren39

🕵️‍♂️
Processing..
View GitHub Profile
@dezren39
dezren39 / get-npm-package-version
Created July 5, 2020 12:35 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# 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 / get-npm-package-version
Last active November 28, 2022 16:30 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# 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 / 1.generate_dockerignore.py
Created July 5, 2020 16:37 — forked from wassname/1.generate_dockerignore.py
Convert .gitignore to .dockerignore: quick and dirty.
"""
Convert .gitignore to .dockerignore: quick and dirty.
This is a quick and dirty script to convert this:
`__pycache__/`
Into this:
```
__pycache__
*/__pycache__
@dezren39
dezren39 / auto-commit-push-create-pr.sh
Created July 5, 2020 16:53
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 / timeout3.sh
Created July 5, 2020 16:54
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 / esm.js
Created July 5, 2020 17:25
esm.js
require = require("esm")(module /*, options*/);
module.exports = require("./index.js");
@dezren39
dezren39 / npm-module-version-check.sh
Created July 5, 2020 17:29
clearly there are options...
# 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 / babel-webpack.md
Created July 6, 2020 05:42 — forked from ncochard/babel-webpack.md
The correct way to compile ES6 using babel...

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 / 01-directory-structure.md
Created July 20, 2020 16:37 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

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 / Links.csv
Created November 6, 2020 00:08 — forked from ptrelford/Links.csv
Mystic Brew