分类目录归档:杂记

IPv6字符串表示最大长度(字符数)

45个字符,数据库设计时存储IPv6需要 varchar(45)

45 characters.

You might expect an address to be

0000:0000:0000:0000:0000:0000:0000:0000

8 * 4 + 7 = 39

8 groups of 4 digits with 7 : between them.

But if you have an IPv4-mapped IPv6 address, the last two groups can be written in base 10 separated by ., eg. [::ffff:192.168.100.228]. Written out fully:

0000:0000:0000:0000:0000:ffff:192.168.100.228

(6 * 4 + 5) + 1 + (4 * 3 + 3) = 29 + 1 + 15 = 45

Note, this is an input/display convention – it’s still a 128 bit address and for storage it would probably be best to standardise on the raw colon separated format, i.e. [0000:0000:0000:0000:0000:ffff:c0a8:64e4] for the address above.

docker初探小记


# 启动个nginx
docker run --detach --publish 80:80 --name webserver nginx
# 停止nginx
docker container stop webserver
# 删除容器
docker container rm webserver

–detach等于-d 后后台运行的意思

可参考链接:
http://www.runoob.com/docker/docker-command-manual.html

CentOS 7安装docker:

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io

Google 应用内购买结算资料

实现应用内购买结算:

https://developer.android.google.cn/google/play/billing/billing_integrate.html?hl=zh-cn

字段参考:

https://developer.android.google.cn/google/play/billing/billing_reference.html?hl=zh-cn#getBuyIntent

# PHP服务端验证
$inappPurchaseData = Request::input('INAPP_PURCHASE_DATA');
$inappDataSignature = Request::input('INAPP_DATA_SIGNATURE');
$googlePublicKey = 'xxxx'; # google后台能获取到的

$publicKey = "-----BEGIN PUBLIC KEY-----" . PHP_EOL . chunk_split($googlePublicKey, 64, PHP_EOL) .
"-----END PUBLIC KEY-----";

$publicKeyHandle = openssl_get_publickey($publicKey);
$verify = openssl_verify($inappPurchaseData, base64_decode($inappDataSignature), 
$publicKeyHandle, OPENSSL_ALGO_SHA1);

# $verify == 1 则验证通过, 0 表示验证失败

solr内存配置,solr时区配置

配置文件位置:/etc/default/solr.in.sh

配置内存
SOLR_JAVA_MEM=”-Xms1g -Xmx6g
这两个配置分别为最小内存和最大内存
配置時區
SOLR_TIMEZONE=”Asia/Shanghai”

其他配置
SOLR_PID_DIR=”/mnt/www/solr”
SOLR_HOME=”/mnt/www/solr/data”
LOG4J_PROPS=”/mnt/www/solr/log4j.properties”
SOLR_LOGS_DIR=”/mnt/www/solr/logs”
SOLR_PORT=”8983″

CouchDB 笔记

CouchDB PHP客户端:https://github.com/sn01615/couchdb-client

创建数据库
curl -X PUT http://127.0.0.1:5984/test

获取数据库列表
curl -X GET http://127.0.0.1:5984/_all_dbs

创建数据库
curl -vX PUT http://127.0.0.1:5984/albums-backup

删除数据库
curl -vX DELETE http://127.0.0.1:5984/albums-backup

保存一条数据
curl -X PUT http://127.0.0.1:5984/test/6e1295ed6c29495e54cc05947f18c8af -d ‘{“title”:”There is Nothing Left to Lose”,”artist”:”Foo Fighters”}’

获取一条数据
curl -X GET http://127.0.0.1:5984/test/6e1295ed6c29495e54cc05947f18c8af

创建用户名密码
HOST=”http://127.0.0.1:5984″
curl -X PUT $HOST/_config/admins/username -d ‘”password”‘

要在配置文件里设置密码

使用用户名密码获取数据
HOST=”http://username:password@127.0.0.1:5984″
curl -X GET $HOST/test/6e1295ed6c29495e54cc05947f18c8af

继续阅读