android java gzip解压

    public String decompress(byte[] compressed) throws IOException {
        final int BUFFER_SIZE = 32;
        ByteArrayInputStream is = new ByteArrayInputStream(compressed);
        GZIPInputStream gis = new GZIPInputStream(is, BUFFER_SIZE);
        StringBuilder string = new StringBuilder();
        byte[] data = new byte[BUFFER_SIZE];
        int bytesRead;
        while ((bytesRead = gis.read(data)) != -1) {
            string.append(new String(data, 0, bytesRead));
        }
        gis.close();
        is.close();
        return string.toString();
    }

// 解压
           String cc = "H4sIAAAAAAAAA3s6ddlTVAQAXAODIhIAAAA=";
           try {
               this.decryptedText.setText(this.decompress(Base64.decode(cc.toCharArray())));
           } catch (IOException e) {
               e.printStackTrace();
           }

openssl_private_encrypt 最大只能加密117字符😂

On my PHP5 build, the limit is 117 characters (936 bits, strange number). That’s because public key encryption is CPU intensive, and meant to be used on short values. The idea is to use this function to encrypt a secret key that is in turn used to encrypt data using a more efficient algorithm, such as RC4 or TripleDES.openssl_public_encrypt

nginx: [warn] duplicate MIME type “text/html”

我检查配置文件发现疑似gzip漏写了text/html,加上去后反而报警告了,百度发现:

https://blog.csdn.net/liangyuannao/article/details/21378113

解决办法:去掉下面一行中的“text/html”。

gzip_types  text/plain text/html  text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

原因:text/html根本就不需要写的,gzip默认就会压缩它的,只不过以前的nginx版本不提示这个警告而已,新版本的会出这个警告。

laravel 获取真实ip的事项

# 这个逻辑可以放在中间件里,判断白名单(127.0.0.1或你的其他代理服务器ip)
$ip = $request->ip();
        if (in_array($ip, ['127.0.0.1']))
            $request->setTrustedProxies($request->getClientIps(), Request::HEADER_X_FORWARDED_ALL);

# nginx 配套配置,如果你是nginx转发,按照这个标准来
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;


# 获取IP
echo $request->ip();

X-Forwarded-For 相关连接:https://en.wikipedia.org/wiki/X-Forwarded-For

blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

FORBIDDEN/12/index read-only / allow delete (api)

官方解决方法:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

_all 可以改为自己的索引名称,也可以直接执行

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

原文链接:https://www.cnblogs.com/zhja/p/9717536.html

Git更安全的强制推送 -force-with-lease

Git 的 push --force 具有破坏性,因为它无条件地覆盖远程存储库,无论你在本地拥有什么。使用这个命令,可能覆盖团队成员在此期间推送的所有更改。然而,有一个更好的办法,当你需要强制推送,但仍需确保不覆盖其他人的工作时,-force-with-lease 这条指令选项可以帮助到你。


作者:LeviDing
链接:https://juejin.im/post/5985b9c56fb9a03c376de762
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

统计php-fpm内存占用总量

ps auxf|grep www_sockets | grep -v grep | awk ‘{print $6}’ | awk ‘{sum+=$1} END {print “Memory =”, sum/1024/1024, “GB”}’

根据需求定制 红色部分是你要修改的部分