作者归档:杨龙

PHP简易排队限流实现


$fp = fopen(sprintf("tmp/wk_exam_examination.%d.lock", $userid % 10), "w");
if (!flock($fp, LOCK_EX | LOCK_NB)) {
?>
<style>
#info {
text-align: center;
margin: 50px 0;
}

#info td {
font-size: 36px;
color: seagreen;
}
</style>
<div id='info'></div>
<script>
let sec = 5000
setTimeout(function () {
window.location.reload()
}, sec)
setInterval(function () {
sec -= 100
if (sec >= 0) {
let ok = sec / 1000
document.getElementById('info').innerHTML = `<table style="margin: 0 auto;">
<tr><td style='width: 50%; text-align: right;'>页面排队中...</td>
<td style="width: 2em; text-align: center;">${ok}</td><td>秒后将重试!</td></tr></table>`;
}
}, 100)
</script><?php
die;
}

layui表格换行

<style>
    .layui-table-cell {
        height: auto;
        overflow: auto;
        text-overflow: initial;
        white-space: normal;
    }
</style>
去掉按钮的下边距
.layui-table .layui-btn-container .layui-btn {
margin-bottom: 0;
}

js复制文本到剪贴板

https://developer.mozilla.org/zh-CN/docs/Web/API/Clipboard/writeText


    function copyText(text) {
        if (navigator.clipboard) {
            navigator.clipboard.writeText(text).then(
                function () {
                    /* clipboard successfully set */
                },
                function () {
                    /* clipboard write failed */
                },
            );
        } else {
            let oInput = document.createElement('input');
            oInput.value = text;
            document.body.appendChild(oInput);
            oInput.select();
            document.execCommand("Copy");
            oInput.className = 'oInput';
            oInput.style.display = 'none';
        }
    }

    function oCopy(text) {
        copyText(text)
        layer.msg('复制成功!')
    }

solr去重

配置文件:solrconfig.xml

<requestHandler name="/update" class="solr.UpdateRequestHandler" >
  <lst name="defaults">
    <str name="update.chain">dedupe</str>
  </lst>
</requestHandler>

<updateRequestProcessorChain name="dedupe">
  <processor class="solr.processor.SignatureUpdateProcessorFactory">
    <bool name="enabled">true</bool>
    <str name="signatureField">id</str>
    <bool name="overwriteDupes">true</bool>
    <str name="fields">object_id,object_type</str>
    <str name="signatureClass">solr.processor.Lookup3Signature</str>
  </processor>
  <processor class="solr.LogUpdateProcessorFactory" />
  <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

修改fields字段为需要去重的字段

Arm64 Centos docker 启动 solr 问题解决方法

 docker container run -itd --name solr -e SOLR_JAVA_STACK_SIZE=-Xss1m solr -m 2g

指定SOLR_JAVA_STACK_SIZE即可

Starting Solr
Java 17 detected. Enabled workaround for SOLR-16463
[0.001s][warning][pagesize] UseLargePages disabled, no large pages configured and available on the system.

The Java thread stack size specified is too small. Specify at least 448k
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

CSS实现表格对角线

        td {
            background-size: 100% 100%;
            background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KICA8bGluZSB4MT0iMCIgeTE9IjAiIHgyPSIxMDAlIiB5Mj0iMTAwJSIgc3Ryb2tlPSJibGFjayIgLz4NCjwvc3ZnPg==");
        }