Coder Social home page Coder Social logo

fullstack-dev-scripts's Introduction

Fullstack Dev Scripts

A collection of scripts/snippets/etc I use during full stack development.

(I still use tldr pages as a cheat sheet for specific tooling examples. This repo is intended to contain scripts to achieve certain goals, and not as a generic reference for any particular toolset.)

Table of contents

npm/yarn package managment

list all top level JS dependencies

jq -r '.dependencies , .devDependencies | to_entries | .[] | .key' package.json | tr '\n' ' '

With versions:

jq -r '.dependencies | to_entries[] | .key as $k | .value as $v | "\($k)@\($v)"' package.json | tr '\n' ' '

find all linked packages

find node_modules -maxdepth 1 -type l -ls

JavaScript

Debugging

See: https://nodejs.org/api/debugger.html#debugger

breakOnException in particular is useful for debugging programs that gobble up stack traces

node inspect foo.js

Jest Tests

NODE_INSPECT_RESUME_ON_START=1 node inspect node_modules/.bin/jest --runInBand --coverage false /path/to/test.js

CLI Script

#!/usr/bin/env node

/**
 * @file Tool to do stuff
 *
 * Usage:
 *
 *   $ ./path/to/script <foo> <bar>
 */

async function main({ foo, bar }) {
    // do stuff
}

if (!process.env.NODE_ENV && require.main === module) {
    const [ , , foo, bar] = process.argv;
    
    main({ foo, bar }).catch(e => {
        console.error('\n======= Error caught in ./path/to/my/script =======');
        console.error(e);
        process.exit(1);
    });
}

Bash

killing all processes related to X

This is usually a super bad idea. Probably don't run this, unless you're feeling super lazy.

ps fux | grep my_service_here | tr -s ' ' | cut -d' ' -f2 | xargs kill

change the value of a constant in a directory

find /path/to/directory -type f -name "*.yaml" | xargs -I{} sed -i -e 's/mem: 2800/mem: 4096/g' {}

tree (with ignored directories)

tree -a -I 'node_modules|\.git'

bash script

#!/bin/bash
set -euo pipefail

# https://stackoverflow.com/a/246128/4396258
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT="${DIR}/.."

if [ "$#" -ne 1 ]
then
    echo '/path/to/script <foo>'
    exit 1;
fi

FOO="$1"
echo $FOO

Docker

run a hello world docker container (with cleanup)

docker run -it --rm ubuntu bash

build & run a container

docker build -t myapp1 .
docker run -it --rm --name app-instance myapp1

fullstack-dev-scripts's People

Contributors

magicmark avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.