• zsh环境变量设置

    这两天在使用环境变量的时候突然发现设置以后,只要重启终端后之前设置的环境变量会消失。最开始是在.bash_profile这个文件添加的环境变量,于是在/etc/profile也添加了环境变量但结果还是一样,只要关闭终端重启就会失效。

    这时突然想到会不会是zsh搞的鬼,因为之前安装了zsh

    full

    于是发现宿主目录下有一个.zshrc配置文件

    └─[0] <> ls -a
    .                                      .zcompdump-Jong Pro-5.2
    ..                                     .zsh-update
    .CFUserTextEncoding                    .zsh_history
    .DS_Store
    

    ...

    READ ALL

  • SecurtCRT不能保存密码的解决方法

    前段时间重新换电脑使用以后,SecurtCRT的会话需要全部重建,结果发现一个问题,即使每次勾选了保存密码这个选项

    full

    但会话断开重连还是要求输入密码,开始没有这么在意,后来总是这样有点麻烦,于是卸了N次重装还是不行,好不容易在网上找到了解决方案,在Global Options下把Use Keychain取消即可

    full

    ...

    READ ALL

  • 快速排序法 Quicksort

    Tony Hoare

    快速排序法(Quicksort)是目前排序算法里最常用的算法之一,由Tony Hoare于1959年开发,61年发布

    引用Wiki

    Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. Developed by Tony Hoare in 1959,[1] with his work published in 1961,[2] it is still a commonly used algorithm for sorting. When implemented well, it can be about two or three times faster than its main competitors, merge sort and heapsort.[3]

    ...

    READ ALL

  • Golang如何跨平台编译到Linux

    有时候我们在开发时会使用Win或者Mac电脑,但部署上线时可能会涉及到跨平台编译,比如在Mac上编译出Linux执行文件

    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
    

    解释以下参数

    • CGO_ENABLED=0 不需要使用CGO
    • GOOS=linux 我们要编译的目标系统
    • GOARCH=amd64 CPU架构,amd64应该是多数通用的
    • -o app 编译输出的可执行文件名称

    ...

    READ ALL

  • hex与rgb(a)互相转换

    hex与rgb都能代表颜色,使用效果上一样的,但有时需要做一些计算时就需要转化,特别是hex转rgb后做一些计算,比如颜色拾取器等等。

    hex转rgb

    function hexToRgb (hex) {
      var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
      hex = hex.replace(shorthandRegex, function (m, r, g, b) {
        return r + r + g + g + b + b;
      });
    
      var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
      return result ? 'rgb(' + [
        parseInt(result[1], 16),
        parseInt(result[2], 16),
        parseInt(result[3], 16)
      ].join(',') + ')' : hex;
    }
     
    console.log(hexToRgb('#C0F'));    // Output: rgb(204,0,255)
    console.log(hexToRgb('#CC00FF')); // Output: rgb(204,0,255)
    

    ...

    READ ALL

  • lite-server一个轻便的开发程序

    lite-server是使用NodeJS写的一款轻量WebServer程序,用于开发阶段使用

    Github: https://github.com/johnpapa/lite-server

    安装

    1、先安装NodeJS,如果没有安装请到nodejs.org下载安装最新版本 2、然后打开命令行执行

    npm install lite-server -g
    

    苹果电脑需要加sudo

    sudo npm install lite-server -g
    

    执行lite-server命令,如果能启动一个WebServer就表示安装成功

    ...

    READ ALL

  • Linux echo单行或cat多行字符串到文件

    在Linux命令行中,我们需要在把一段字符串添加到文件末尾可以这么干

    # echo 'Add text' > file
    

    假如要添加两行的话,也可以这样

    # echo 'Line1' > file
    # echo 'Line2' > file
    

    看着可以,但其实不是太理想,我们可以使用EOF关键字

    # cat <<EOF > file
    Line1
    Line2
    EOF
    

    要注意转义$和`符号,如

    # cat <<EOF > file
    `date`
    $VAR
    EOF
    

    cat file看一下

    ...

    READ ALL

  • Gitlab搭配Gitlab-CI配置

    full

    使用Gitlab做VCS可以很轻松的搭配Gitlab-CI做持续集成。

    安装

    Gitlab8以上已集成CI,安装gitlab-ci-server就能使用,以CentOS为例

    curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
    sudo yum install gitlab-ci-multi-runner
    

    ...

    READ ALL

  • umount 提示 device is busy 解决方法

    想umount一个不用的磁盘,结果提示:

    [root@qttc mydata]# umount /mydata     
    umount: /mydata: device is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))
    

    于是只好用fuser命令来查看磁盘占用情况:

    [root@qttc mydata]# fuser -m -v /mydata
                         USER        PID ACCESS COMMAND
    /mydata:             root      16016 ..c.. bash
                         root      25011 ..c.. bash
    

    ...

    READ ALL

  • 用wget下载JDK

    经常需要在服务器端下载JDK,但下载JDK需要同意一个Licence才能下载,浏览器做这个动作很容易,只需要点一下同意在点击链接下载即可,但在Linux下用wget下载就需要添加一些参数了

    wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
    

    ...

    READ ALL