tcooling / scripts

A repo with some useful scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scripts

A repo with some useful scripts.

Table of Contents

  1. Jenkins
  2. Node.js
  3. Javascript
  4. Python

Jenkins

Blue-Green Deployment is a method of deploying an application with 0 downtime. This variation will also deploy the correct number of instances by checking with CloudFoundry to find the number of instances currently running for that app and redploy the same number.

You must call the deploy method with the following arguments:

def deploy(String credentialsId, String organisation, String space, String appName, String pathToArtifact, String pathToManifest, String host, String domain)

You use the colourText methods to wrap a print statement in an ANSI colour to improve readability when looking through the logs of a Jenkins build.

Example Usage:

colourText("info","Hello, world!")

Node.js

Winston is a logging tool for Node.js, this script adds colour and filenames to your logs.

Usage instructions:

  1. Install Winston
npm install --save winston
  1. Import logger.js
const logger = require('./logger')(module);
  1. Start logging
logger.info('Hello, world!')

Javascript

pipe.js allows you to 'pipe' any number of input parameters through any number of functions. It can be useful when you need to pass an input through a number of functions in an immutable way.

Example usage:

import { pipe } from './pipe';

const addOne = (x) => x + 1;
const multiplyBy5 = (x) => x * 5;

const result = pipe(addOne, multiplyBy5)(2) // 15

siccode.js allows you to get the description that corresponds with a SIC code.

There are backticks in siccode.js, so do a simple find + replace if you are unable to use them.

Example usage:

  1. Import the variable
import industryCodeDescription from './siccode';
  1. Get the description that corresponds with your SIC code
const sic = '01110';
const description = (industryCodeDescription[sic] === undefined)
      ? 'No industry code description found' : industryCodeDescription[sic];

Python

compose.py allows you to compose multiple functions together so that the result of each function is passed as an argument to the next.

Example usage:

from compose import compose

add_one = lambda x: x + 1
multiply_by_five = lambda x: x * 5

inc_then_multiply_by_five = compose(add_one, multiply_by_five)

print(inc_then_multiply_by_five(2)) # 15

About

A repo with some useful scripts

License:MIT License


Languages

Language:JavaScript 91.3%Language:Groovy 8.4%Language:Python 0.2%