This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const readline = require('readline'); | |
| const hint = (min, max) => ( | |
| 'Please guess a number between %min and %max, hint(%h): ' | |
| .replace(/\%min/, min) | |
| .replace(/\%max/, max) | |
| .replace(/\%h/, Math.floor((min+max)/2)) | |
| ); | |
| const getnum = (msg, callback) => { | |
| const rl = readline.createInterface({ | |
| input: process.stdin, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| name=grin-miner | |
| exec=/usr/bin/$name | |
| screen -X -S $name quit | |
| screen -dmS $name bash -c "cd $HOME/$name; $name" | |
| cat > $HOME/bin/$name.crontab <<EOF | |
| 1 */2 * * * sh $HOME/bin/$name.sh >> /tmp/$name.log 2>&1 | |
| EOF | |
| crontab -i $HOME/bin/$name.crontab | |
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| [ -z $1 ] && echo "!no user" && exit 1 | |
| [ -z $2 ] && echo "!no pass" && exit 1 | |
| cd $(realpath $(dirname $0)) | |
| rm -rf .tmp | |
| mkdir -p .docker .tmp | |
| [ ! -f .docker/Dockerfile ] && \ | |
| cat >.docker/Dockerfile<<EOF | |
| FROM "wppurking/ocserv" | |
| RUN apt-get update && \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # ------------------------------------------------------------------ | |
| # [Script] init_ssh_nopass.sh | |
| # [Author] Hai Ji <jhsea3do@gmail.com> | |
| # main script | |
| # ------------------------------------------------------------------ | |
| # assumption: all nodes must have sshpass tool installed | |
| # https://unix.stackexchange.com/questions/230084/send-the-password-through-stdin-in-ssh-copy-id | |
| # [ ! -x "sshpass" ] && yum install -y sshpass; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://superuser.com/questions/590630/sed-how-to-replace-line-if-found-or-append-to-end-of-file-if-not-found | |
| sed '/^FOOBAR=/{h;s/=.*/=newvalue/};${x;/^$/{s//FOOBAR=newvalue/;H};x}' infile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ssh -vvvv $host | |
| # pledge: network | |
| cat /etc/pam.d/postlogin | |
| #%PAM-1.0 | |
| # This file is auto-generated. | |
| # User changes will be destroyed the next time authconfig is run. | |
| session [success=1 default=ignore] pam_succeed_if.so service !~ gdm* service !~ su* quiet | |
| session [default=1] pam_lastlog.so nowtmp showfailed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # ------------------------------------------------------------------ | |
| # [Script] bin/init.sh | |
| # [Author] Hai Ji <shjihai@cn.ibm.com> | |
| # main script | |
| # ------------------------------------------------------------------ | |
| PRJ_NAME=bkce | |
| PRJ_PATH=$(realpath "$(dirname $0)/..") | |
| CWD=$(pwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| FILE_DIR=${FILE_DIR:-"/tmp/docker"} | |
| LOCL_DIR=${LOCL_DIR:-"/usr/local"} | |
| INST_DIR=${INST_DIR:-"/home/docker"} | |
| INST_GRP=${INST_GRP:-"docker"} | |
| INST_GID=${INST_GID:-"2376"} | |
| INST_VER=${INST_VER:-"18.09.1"} | |
| INST_NET=${INST_NET:-"172.17.0.1/16"} | |
| INST_SILENT=0 | |
| function load_cfg { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python -u | |
| import sys, json | |
| from pygments import highlight | |
| from pygments.lexers import JsonLexer | |
| from pygments.formatters import Terminal256Formatter | |
| while True: | |
| line = sys.stdin.readline() | |
| if line.strip(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * docker pipeline sample | |
| */ | |
| node { | |
| // create volume for root user | |
| sh """ | |
| docker volume create ansible-root; | |
| """ |