https://golang.google.cn/doc/install
wget https://golang.google.cn/dl/go1.23.2.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
https://golang.google.cn/doc/install
wget https://golang.google.cn/dl/go1.23.2.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
google analytics 访问统计
自定义事件
gtag('event', 'click', {
'event_category': 'button',
'event_label': 'calc'
});
其中 event_label
如有问题请使用 https://gemini.google.com/ 提问。
追踪视频播放
gtag('event', 'video_start', {
'event_category': 'video',
'event_label': 'intro_video'
});
追踪表单提
gtag('event', 'submit', {
'event_category': 'form',
'event_label': 'contact_form'
});
加入购物车
gtag('event', 'add_to_cart', {
'event_category': 'ecommerce',
'event_label': 'product_name',
'value': 19.99,
'currency': 'USD'
});
点击支付事件
gtag('event', 'begin_checkout', {
'event_category': 'ecommerce',
'event_label': 'payment_button',
'value': 19.99,
'currency': 'USD'
});
支付成功
gtag('event', 'purchase', {
'event_category': 'ecommerce',
'event_label': 'order_12345',
'value': 59.99,
'currency': 'USD',
'transaction_id': 'T12345'
});
$str = "汉字";
if (!preg_match_all("/^[\p{Han}]+$/u", $str, $match)) {
//全是汉字
}
依赖
Ruby、 Rails
npm install pm2@latest -g
修改gem、bundle源
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l
确保只有 gems.ruby-china.com
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
Ngnix转发
location / {
try_files /_not_exists_ @backend;
}
location @backend {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:3000;
}
软链
ln -s /data/redmine-5.1/public /www/wwwroot/yourdomain/
启动
pm2 start "bundle exec rails server -e production" --name redmine --cwd /data/redmine-5.1
保存
pm2 save
pm2 startup
修改状态颜色
public/javascripts/application.js
$(function(){
$("#content table.issues tbody tr td").each(function(){
let status_class = $(this).attr('class');
if(status_class == 'status'){
let html = $(this).html();
if(html == '已解决'){
$(this).html("<span style='color:green;'>已解决√</span>");
}else if(html == '新问题'){
$(this).html("<span style='color:red;'>新问题</span>");
}else if(html == '处理中'){
$(this).html("<span style='color:#00BBFF;'>处理中……</span>");
}else if(html == '拒绝'){
$(this).html("<span style='color:#BB5500;'>拒绝</span>");
}else if(html == '关闭'){
$(this).html("<span style='color:#444444;'>关闭</span>");
}else if(html == '待反馈'){
$(this).html("<span style='color:#EEEE00;'>待反馈</span>");
}
}
});
});
以uuid为例,普通二维可能是直接的UUID值,也可能是小程序后台配置的打开普通链接打开小程序,如 https://yourdomain.com/qr/uuid值
其中uuid值为字符、数字组合。以下为事例代码
onLoad(opt) {
_this = this
console.log(opt)
//传参数 uuid
let uuid = opt.uuid
if(uuid && uuid.indexOf('/') !== -1){
this.get_parse_qr(uuid)
}else{
this.uuid = opt.uuid || ''
}
//扫普通二维码
if(opt.q){
this.get_parse_qr(opt.q)
}
//opt.scene 是小程序码
},
methods: {
get_parse_qr(q){
let domain = this.config.domain;
let text = decodeURIComponent(q);
//小程序后台配置了 扫普通链接二维码打开小程序,值如 https://yourdomain.com/qr/
//4是/qr/的长度
let result = text.substr(domain.length+4);
if(result){
this.uuid = result
}
},
}
小程序内扫一扫
removeSpecialCharacters(input) {
// 使用正则表达式匹配并去除 0x1D 字符
return input.replace(/\u001d/g, ''); // 或者用 replaceAll 方法
},
open_qr() {
uni.scanCode({
scanType:['barCode','qrCode','datamatrix','pdf417'],
success: function(res) {
let d = _this.removeSpecialCharacters(res.result)
console.log("res.charSet==",res.charSet)
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + d);
}
});
},
安装GO
1.访问 https://golang.google.cn/dl/
wget https://golang.google.cn/dl/go1.22.5.linux-amd64.tar.gz
2. 访问 https://golang.google.cn/doc/install
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
修改成国内源
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
go env | grep GOPROXY # 查看源信息
mindoc安装源码安装
mkdir /data/
cd /data/
git clone https://github.com/mindoc-org/mindoc.git
cd mindoc
go mod tidy -v
go build -ldflags "-w" -o mindoc main.go
./mindoc install # 执行前,需要修改conf/app.conf文件,配置数据库信息
数据库用mysql,如下
db_adapter="${MINDOC_DB_ADAPTER||mysql}"
db_host="${MINDOC_DB_HOST||127.0.0.1}"
db_port="${MINDOC_DB_PORT||3306}"
db_database="${MINDOC_DB_DATABASE||mindoc}"
db_username="${MINDOC_DB_USERNAME||mindoc}"
db_password="${MINDOC_DB_PASSWORD||111111}"
以上数据请改成真实有值
设置为服务并自启动
vim /etc/systemd/system/mindoc.service
写入
[Unit]
Description=Mindoc
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/data/mindoc
ExecStart=/data/mindoc/mindoc
Restart=on-failure
[Install]
WantedBy=multi-user.target
保存并退出
sudo systemctl daemon-reload
sudo systemctl start mindoc
sudo systemctl status mindoc # 显示正常
sudo systemctl enable mindoc # 设为自启动
Nginx配置
location / {
try_files /_not_exists_ @backend;
}
location @backend {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8181;
}
最后一步
注册软链static目录
ln -s /data/mindoc/static /www/wwwroot/yourdomain/static
ln -s /data/mindoc/uploads /www/wwwroot/yourdomain/uploads
注意 /www/wwwroot/yourdomain/ 为网站目录