This file contains 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' | |
z.file.new.sh() { |
This file contains 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 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 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 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 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 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 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 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"] |
This file contains 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
/** | |
* Calculate the ignore ratio of monster defense. | |
* | |
* @param base The base ignore ratio, (Value: 0 ~ 1) | |
* @param ignoreItems The items of ignore addition to be added, (Value: 0 ~ 1) | |
*/ | |
function calcIgnoreMobDefnese(base, ignoreItems) { | |
return Math.floor(ignoreItems.reduce((p, v) => p + (1 - p) * v, base) * 100) / 100; | |
} |
NewerOlder