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.map-port-to-local() { | |
local LOCAL_HOST=$SSH_MAP_LOCAL_HOST | |
local LOCAL_PORT=$SSH_MAP_LOCAL_PORT | |
if [[ -z "$SSH_MAP_REMOTE_SERVER" ]] || [[ -z "$SSH_MAP_REMOTE_PORT" ]]; then | |
echo "Usage: z.ssh.map-port-to-local" | |
echo " env export [email protected] [Required]" | |
echo " env export SSH_MAP_REMOTE_PORT=12345 [Required]" | |
echo " env export SSH_MAP_REMOTE_HOST=127.0.0.1 [Default: 127.0.0.1]" |
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
# bash assistant commands | |
# [General] | |
alias z.cls='clear' | |
alias z.history.clear='rm -f ~/.bash_history && history -c' | |
alias z.uuid='cat /proc/sys/kernel/random/uuid' | |
alias z.pss='ps -A -opid,cmd' | |
alias z.journalctl.flush='sudo journalctl --flush --rotate --vacuum-time=1s' |
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/env bash | |
if [[ -z "$2" ]]; then | |
echo './add-apache2-copyright.sh <path> <ext>'; | |
exit; | |
fi | |
for i in $(find $1 -type f -name "*.$2") | |
do | |
HAS_CR_COMMENT=$(cat $i | grep 'www.apache.org') |
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
// A JS implementation of PBKDF2. | |
// For study only, don't use this. | |
// Use NodeJS native implementation `crypto.pbkdf2` instead. | |
const Crypto = require('node:crypto'); | |
function hmac(hmacAlgo, key, data) { | |
return Crypto.createHmac(hmacAlgo, key).update(data).digest(); | |
} | |
const BUF_INT32_BE = Buffer.alloc(4); |
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
import * as $crypto from 'crypto'; | |
const WEPAY_MCH_ID = 12345678; | |
const WEPAY_API_KEY = ''; | |
const NONCE_STR = $crypto.randomBytes(16).toString('hex'); | |
const REQ_SIGN = $crypto.createHash('md5') | |
.update(`mch_id=${WEPAY_MCH_ID}&nonce_str=${NONCE_STR}&sign_type=MD5&key=${WEPAY_API_KEY}`) | |
.digest('hex') |
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 | |
## See https://stackoverflow.com/a/48029079/6559859 | |
for k in $(docker ps --format='{{.ID}}') | |
do | |
echo "" > $(docker inspect --format='{{.LogPath}}' $k) | |
done |
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/bash | |
MONGO_DOCKER_MAX_MEMORY=512M | |
MONGO_DOCKER_PORT=27017 | |
MONGO_DOCKER_DATA_DIR=/data/db | |
MONGO_DOCKER_NAME=Mongo-Server | |
MONGO_LOCAL_PORT=27017 | |
MONGO_LOCAL_DATA_DIR=/docker/mongo/db |
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
/** | |
* Calcuate the used scrolls of a weapon. | |
* | |
* @param baseAttack The base attack | |
* @param totalAttack The total attack | |
* @param sparkAttack The ATTACK added by spark | |
* @param appliedScrolls The quantity of scrolls applied. | |
* @param appliedStars The quantity of stars applied. | |
*/ |
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
MQ_DOCKER_PORT=5672 | |
MQ_DOCKER_ADMIN_USER="user" | |
MQ_DOCKER_ADMIN_PASS="password" | |
MQ_DOCKER_ADMINCP_PORT=15672 | |
MQ_DOCKER_PATH=/var/lib/rabbitmq | |
MQ_DOCKER_NAME="RabbitMQ-Server" | |
MQ_DOCKER_MEMORY=256M | |
MQ_LOCAL_PATH=/docker/rabbitmq | |
MQ_LOCAL_HOST=0.0.0.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
FROM php:fpm | |
RUN pecl install -o -f redis \ | |
&& rm -rf /tmp/pear \ | |
&& docker-php-ext-enable redis \ | |
&& docker-php-ext-install mysqli pdo pdo_mysql | |
CMD ["php-fpm"] |
NewerOlder