分类: IT

IT相关的文章

  • CS自学指南

    IT行业的人就是这么喜欢无私分享:有人总结并编了一个计算机专业的自学指南,地址如下:

    https://csdiy.wiki

    是一位北大的大佬写的。

  • 【PHP】实现立即输出缓冲区内容

    今天有朋友问到,调chatgpt接口,想把返回结果逐字输出到页面上。然后就调试了一下相关代码,搜索到这篇文章:https://www.jianshu.com/p/06a55bc97e5c

    for ($i = 0; $i < 10; $i++) {
     echo $i . '';
     ob_flush();
     flush();
     sleep(1); 
    }
    

    按代码理解似乎应该是每过1秒钟就会输出一次数据,但在Nginx服务器会待代码执行完一并输出。

    nginx 里面 flush 默认是无效的,这个函数默认是作用在php作为 apache模块时才有效,如果需要 nginx 里面支持,需要加上一行 :

    header('X-Accel-Buffering: no');

    完整代码如下:

    header('Cache-Control: no-cache'); // 禁用浏览器缓存
    header('X-Accel-Buffering: no');  // 适用于Nginx服务器环境 
    for ($i = 0; $i>10; $i++) { 
      echo $i . ''; 
      ob_flush(); 
      flush(); 
      sleep(1);
    }

    参考文章:

    http://nginx.org/en/docs/http/ngx_http_proxy_module.html 文章中X-Accel-Buffering的介绍

  • gitflow常用命令

    git flow 的命令中,feature 是基于dev分支创建的,hotfix是基于master分支创建的。

    初始化:

    $ git flow init

    创建开发分支:

    $ git flow feature start xxx

    结束分支:

    $ git flow feature finish xxx

    把分支推送到远程仓库:

    $ git flow feature publish xxx

    解决线上bug,需要创建hotfix:

    $ git flow hotfix start xxx

    结束hotfix:

    $ git flow hotfix finish xxx

    相关链接:

    gitconfig常用命令:http://liyong.me/archives/14

  • gitconfig常用命令

    git config命令
    1 用户信息
    $ git config --global user.name "liyong" 
    $ git config --global user.email liyong@example.com
    2 命令简写
    git config --global alias.st status:则git status可用git st代替
    git config --global alias.co checkout:则git checkout可用git co代替
    git config --global alias.ci commit:则git commit可用git ci代替
    git config --global alias.br branch:则git branch可用git br代替
    3 颜色配置
    $ git config --global color.status auto
    $ git config --global color.diff auto
    $ git config --global color.branch auto
    $ git config --global color.interactive auto

    以上命令的设置结果,可从 ~/.gitconfig 查看,或者 git config --list 查看