Skip to content

Instantly share code, notes, and snippets.

View delusionxb's full-sized avatar

delusionxb delusionxb

View GitHub Profile
#!/usr/bin/env node
/**
* ArgsHelper is to help a worker script to define and parse command line args in good shape
*
* 1. call const argsHelper = new ArgsHelper()
*
* 2. define args, description and examples
* if parent mode (./worker.js -a A -b BB -c)
* script without sub-command but only options and args
import React, { Component } from 'react';
import echarts from 'echarts/lib/echarts';
import 'echarts/lib/chart/pie';
import 'echarts/lib/component/title';
import config from './config';
/**
* https://www.jianshu.com/p/2e6789187d30
* https://segmentfault.com/a/1190000010259486
* https://segmentfault.com/a/1190000017416333
#!/bin/bash
source ${HOME}/underworld_sh/styx/LogsHelper.sh 'toStdout'
alterSpace() {
num=${#1}
max=$2
gap=$((max-num))
i=0
space=' '
const cleanRoom = () => {
return new Promise((resolve, reject) => {
resolve('Room cleaned');
});
}
const removeGarbage = (result) => {
return new Promise((resolve, reject) => {
resolve(`${result}, Garbage removed`);
});
@delusionxb
delusionxb / ArgsHelper.sh
Created December 25, 2018 02:06
shell script helps to build worker script to accept args in key-value pairs
#!/bin/bash
#
# source BaseEnvHelper.sh to use, instead of sourcing this script directly
# used to help other scripts to make their args organized
# invoke 'SetRequestedArg' / 'SetDescription' / 'SetExample' first
# then invoke 'VerifyAllArgs "$@"'
# create empty arrays to store arguments with corresponding names
# shortNameArray to store shortName and so on
shortNameArray=()
@delusionxb
delusionxb / python3_jwt_example.py
Created December 24, 2018 11:55
python3 jwt example
#!/usr/bin/env python3
import jwt, time
from app.main.config import Config
import logging
logger = logging.getLogger('ROOT.auth')
def generate_jwt(auth_data, expire_time=Config.JWT_EXPIRATION):
logger.info('generate_jwt() with data: {}'.format(auth_data))