资源技巧,笔记
个人笔记本

VYOS 开源路由简易编译教程/镜像构建

这是一篇简短的文章,展示了如何构建自己的 VyOS LTS iso 映像。已经在 Debian Buster(Debian 10)通过测试!~

安装 Docker

$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
$ sudo apt-get update
$ sudo apt-get install -y docker-ce

$ sudo usermod -aG docker <Your username>

注:国内网络环境可参考 https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/

阅读全文»

VYOS 安装与基础命令

安装

vyos@vyos:~$ install image
Welcome to the VyOS install program.  This script
will walk you through the process of installing the
VyOS image to a local hard drive.
Would you like to continue? (Yes/No) [Yes]: Yes
Probing drives: OK
Looking for pre-existing RAID groups...none found.
The VyOS image will require a minimum 2000MB root.
Would you like me to try to partition a drive automatically
or would you rather partition it manually with parted?  If
you have already setup your partitions, you may skip this step
 
Partition (Auto/Parted/Skip) [Auto]:
 
I found the following drives on your system:
 sda    4294MB
 
Install the image on? [sda]:
 
This will destroy all data on /dev/sda.
Continue? (Yes/No) [No]: Yes
 
How big of a root partition should I create? (2000MB - 4294MB) [4294]MB:
 
Creating filesystem on /dev/sda1: OK
Done!
Mounting /dev/sda1...
What would you like to name this image? [1.2.0-rolling+201809210337]:
OK.  This image will be named: 1.2.0-rolling+201809210337
Copying squashfs image...
Copying kernel and initrd images...
Done!
I found the following configuration files:
    /opt/vyatta/etc/config.boot.default
Which one should I copy to sda? [/opt/vyatta/etc/config.boot.default]:
 
Copying /opt/vyatta/etc/config.boot.default to sda.
Enter password for administrator account
Enter password for user 'vyos':
Retype password for user 'vyos':
I need to install the GRUB boot loader.
I found the following drives on your system:
 sda    4294MB
 
Which drive should GRUB modify the boot partition on? [sda]:
 
Setting up grub: OK
Done!



vyos@vyos:~$ reboot
Proceed with reboot? (Yes/No) [No] Yes

阅读全文»

Golang 第三方库学习 · xlsx

介绍

xlsx 是对新版本的Excel进行简单读写操作的golang第三方库,支持的文件格式是.xlsx

源码

第三方库源码:
https://github.com/tealeg/xlsx

本文源码:
https://github.com/Chain-Zhang/third-lib

安装

go get github.com/tealeg/xlsx



阅读全文»

Golang 源码解析 DetectContentType 检测文件类型

我们可以使用 golang 中的 net/http 包的来查找文件的内容类型或 mime 类型。

DetectContentType 函数实现了 http://mimesniff.spec.whatwg.org/ 描述的算法,用于确定数据的 Content-Type .

该函数会检查数据的前 512 字节,然后返回一个合法的 MIME 类型,例如 application/json 或类似 image/jpg .

如果不能确定数据的类型,将返回 "application/octet-stream" .

阅读全文»

上游库更新后,如何同步一个 fork

fork 了别人的仓库后,原作者又更新了仓库,如何将自己的代码和原仓库保持一致?

同步一个 fork

Configuring a remote for a fork

  • 给 fork 配置一个 remote
  • 使用 git remote -v 查看远程状态。
git remote -v
# origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
# origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
  • 添加一个将被同步给 fork 远程的上游仓库
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

阅读全文»