环境

  • Ubuntu 16.04

参考

步骤

  1. 更新源
    sudo apt update
    sudo apt upgrade
  2. 安装依赖
    sudo apt install ca-certificates curl openssh-server postfix

    如果只在本地网络使用,postfix设置时选择 Local only

  3. 下载官方安装脚本
    curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
  4. 安装gitlab-ce
    sudo apt install gitlab-ce
  5. 修改gitlab配置文件(位于 /etc/gitlab/gitlab.rb),配置URL
    找到 external_url ‘https://yourdomain’ 一行,修改为自己的域名或IP地址。
    没有SSL证书或者使用IP时将https改为http

    external_url 'http://192.168.xxx.xxx'
  6. 重新配置gitlab
    sudo gitlab-ctl reconfigure

    耗时较长

  7. 配置成功后输入IP/域名,设置管理员账户密码,之后即可访问Gitlabhost

I want to setup a local network printer for me and my roomates, so they can print papers remotely without sending file to me then I have to do the operation.

At the very beginning, I installed Windows Server 2016 on a miniPC, it works perfectly fine but the CPU (Atom D425 1.8GHz) is really a pain in the ass when I try to do other jobs(Remote Display, IIS Hosting, etc). So I change the OS to Ubuntu and the performace becomes better.

Sharing a printer on Ubuntu is not that hard(it’s more complicated than its on Windows which has a GUI configuration and you just need to click some buttons), we just need to configure the printer in the system then install CUPS.

Environment

  • Ubuntu 16.04

Steps

  1. Plug the printer in and set it up.
    • In Ubuntu desktop, go to Settings -> Printers, then click the Add button. The left panel shows all the ports that already connected to the machine, choose the printer then choose the right driver, the system will take care of the rest configurations.
    • You can print a test page to check whether the printer is working when it’s done.
  2. Install CUPS
    1. Open Terminal(you can open it by pressing CTRL+ALT+T on desktop).
    2. Execute commands:
      sudo apt update
      sudo apt install cups

      After the installation, CUPS Web Page will listening on port 631, visit http://127.0.0.1:631 to get access to CUPS.

    3. 19-04-13 Update:
      I checked the settings again and realized that you don’t have to setup a reverse proxy, CUPS(version 2.1.3) will automatically listen on the external IP. But you still have to disable https if you don’t have a SSL certification or using a IP address.
      Open CUPS’ config file, located at /etc/cpus/cpusd.conf and add this line(the full config file documentation is here):

      DefaultEncryption Never

      Then restart CPUS service:

      sudo service cups restart
      # or use this
      sudo systemctl restart cups.service

      Visit http://[IP address or domain]:631 to see the web interface.
      Old stuff:

      If you want to visit CUPS web page on your other devices, you can install nginx to setup a simple reverse proxy.

      sudo apt install nginx

      Open a file named [your name].conf under /etc/nginx/conf.d/, then paste:

      server {
          listen 632;
          server_name cups;
          location / {
               proxy_pass http://127.0.0.1:631;
          }
      }

      Save changes, quit, execute commands:

      sudo nginx -t # test config file
      sudo nginx -s reload

      Then visit http://[your machine’s ip]:632 to get access to CUPS.

  3. Once you open the CUPS webpage, go to Administration, check the Share printers connected to this system box, then click Change Settings.
    • Type in your system account if it asks authentication.

If you successfully configured the printer in the system, CUPS will automatically detect the printer and share it in your local network. You just need to add the network printer on the other devices.

 

接触一下python plotly这个数据可视化的模块,万万没想到,走出去的第一步就踩进泥坑,描述一下我想要实现的功能:

用柱状图显示部分省份2018年的GDP以及GDP增长速度。也就是以城市为X坐标,GDP和增长率为Y坐标(左右各一个),每个城市两个柱形,显示10组这样的数据。

万万没想到,第一步就遇到了官方bug。

环境

  • python 3.6.6
  • plotly 3.7.1

参考

plotly的使用

  1. pip安装plotly
    pip install plotly
  2. 项目中引入plotly模块
    import plotly, json
    from plotly import graph_objs as go
  3. 通过官方文档熟悉其用法后,可以简单绘制出 y=x x∈[1, 4] 的函数图
    import plotly
    from plotly import graph_objs as go
    
    trace1 = go.Scatter(
        x=[1, 2, 3, 4],
        y=[1, 2, 3, 4]
    )
    
    data = [trace1]
    
    plotly.offline.plot(data, auto_play=True)

从陷入泥潭到实现目标

首先去收集了一下2018年部分省份的GDP信息,并以json格式存储到Data文件中,长这样:

{
    "cities":[{
        "name": "广州",
        "gdp": 21705.29,
        "speed": 7
    },
    {
        "name": "江苏",
        "gdp": 21093.3,
        "speed": 7.1
    },
    {
        "name": "山东",
        "gdp": 18900.6,
        "speed": 6.7
    },
    {
        "name": "浙江",
        "gdp": 11691,
        "speed": 7.4
    },
    {
        "name": "河南",
        "gdp": 10611,
        "speed": 7.9
    },
    {
        "name": "四川",
        "gdp": 8590.2,
        "speed": 8.2
    },
    {
        "name": "湖北",
        "gdp": 8188.84,
        "speed": 7.6
    },
    {
        "name": "上海",
        "gdp": 7863.40,
        "speed": 6.8
    },
    {
        "name": "湖南",
        "gdp": 7777.65,
        "speed": 8
    },
    {
        "name": "河北",
        "gdp": 7564,
        "speed": 6
    }]
}

Continue reading “python plotly数据可视化(踩坑纪实)”