Github action code for deploy blog

in .github/workflows/action.yml: name:auto deployment# 名字自取on:push:branches:- master # 这里的意思是当 master 分支发生push的时候,运行下面的jobs,这里先改为github-actionsjobs:deploy:# 任务名自取runs-on:ubuntu-20.04 # 在什么环境运行任务steps:- uses:actions/checkout@v2 # 引用actions/checkout这个action,与所在的github仓库同名with:submodules:false# Fetch Hugo themes (true OR recursive) 获取submodule主题fetch-depth:0# Fetch all history for .GitInfo and .Lastmod- name:Setup Hugo # 步骤名自取uses:peaceiris/actions-hugo@v2 # hugo官方提供的action,用于在任务环境中获取hugowith:hugo-version:'0.89.2'# 获取最新版本的hugoextended:true- name:Buildrun:hugo --minify # 使用hugo构建静态网页- name:Deploy Githubuses:peaceiris/actions-gh-pages@v3 # 一个自动发布github pages的actionwith:# github_token: ${{ secrets.GITHUB_TOKEN }} 该项适用于发布到源码相同repo的情况,不能用于发布到其他repoexternal_repository:Andyliu92/Andyliu92.github.io # 发布到哪个repopersonal_token:${{ secrets.ACCESS_TOKEN }} # 发布到其他repo需要提供上面生成的personal access tokenpublish_dir:./public # 注意这里指的是要发布哪个文件夹的内容,而不是指发布到目的仓库的什么位置,因为hugo默认生成静态网页到public文件夹,所以这里发布public文件夹里的内容publish_branch:master # 发布到哪个branch- name:Upload Websiteuses:burnett01/rsync-deployments@5.1with:switches:-avzhpath:"./public/*"remote_path:"/home/ubuntu/www/Blogs/Personal"remote_host:"101.42.141.88"remote_port:"22"remote_user:ubunturemote_key:${{ secrets.COMFLUTER_TOKEN}}# - name: Upload Website# uses: zhenyuWang/Upload-File-Action@v1....

August 24, 2022 · 1 min · Andyliu

利用Git Hook实现服务器端文件提交大小限制

利用git hooks,在服务器端每次接收到push的时候进行文件信息检查,若超过限制则拒绝提交。 具体实现:在update hook中对提交的文件进行检查,利用git log命令查询所有新提交的分支,利用git cat-file 命令递归查询文件树、查询文件大小,若超限则返回1拒绝提交。 #!/bin/bash # # An example hook script to block unannotated tags from entering. # Called by "git receive-pack" with arguments: refname sha1-old sha1-new # # To enable this hook, rename this file to "update". # # Config # ------ # hooks.allowunannotated # This boolean sets whether unannotated tags will be allowed into the # repository. By default they won't be. # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository....

May 7, 2022 · 3 min · Andyliu

Debug golang program in vscode

Basic config install delve use debug config template in vscode Debug with stdin input The default delve debug mod doesn’t support stdin input. To tackle this issue, use the method of launching a delve debug server and attach program to debug server instead. tasks.json { "tasks": [ { "label": "Delve debug server", "type": "shell", "command": "cd \"${fileDirname}\" && source /etc/profile && ~/go/bin/dlv debug --headless --listen=:2346 --api-version=2", "problemMatcher": [], "group": { "kind": "build", "isDefault": false } } ], "version": "2....

May 1, 2022 · 1 min · Andyliu

Linux环境下使用vscode进行c/c++语言debug

VScode中debug运行逻辑概述 工作区 VScode由两种运行模式:单文件打开模式和文件夹打开模式。界面上最明显的区分是VScode底部的颜色条如果是紫色的,说明在单文件打开模式,如果为天蓝色,即处于文件夹打开模式。 在文件夹打开模式下,左侧文件浏览器界面可以看到当前文件夹路径下的所有文件以及文件夹。这个所谓的“当前文件夹路径”在VScode中被称为“工作区路径”。如果不清楚当前的工作区路径,在VScode中新建——注意不是显示之前隐藏的终端——一个终端后所处在的路径就是当前的工作区路径,由VScode自动帮你切换好了。可以在打开后不更改路径的情况下使用pwd命令打印当前的绝对路径。 Debug相关配置文件 以${workspaceFolder}表示当前工作区文件夹,则与这个工作区相关的所有VScode的配置文件都放在${workspaceFolder}/.vscode文件夹下,若要进行c语言程序的debug,需要用到两个文件: launch.json 这个文件里面记录的是与debug直接相关的配置,包括debug任务名称、debug程序(c语言对应gdb)、相关参数等等。对于python这种不需要编译的解释性语言,仅用这个文件就够了。但是c语言是编译型语言,在调用gdbdebug之前还需要调用gcc进行编译,对应到launch.json里面就要配置一个参数"preLaunchTask",里面调用接下来要说的tasks.json文件里的配置进行编译。 tasks.json 这个文件就是一些常用任务的配置,写成配置文件后就可以一键运行,而不用每次都敲繁琐的命令行了。在debug的相关配置中常用来填写编译(build)任务的相关配置,里面可以指定使用的编译器、使用的语言版本、编译参数等等。 debug相关设置以及快捷键 F5在debug启动前为“启动debug”命令,在debug启动后为“继续”命令(继续运行直到遇到下一个断点暂停) F9在光标所在的行设置断点 F10下一步,遇到函数不会进入 F11下一个语句,遇到函数会进入函数 shift + F11单步跳出,即执行完当前函数并返回后暂停程序 shift + F5停止debug 或者在遇到断点后点击debug工具栏里的按钮也可以 有可能启动debug之后弹出的终端界面在debug console中,而非terminal中,此时进行的输入不会被引导到stdin中,而是会交给调试器。点击下图中红框圈起来的terminal(中文翻译应该是“终端”)即可回到正常的终端,此时进行的输入将直接进入stdin交给程序。 更多进阶玩法参见微软官方文档 一次C语言Debug的流程(配合下文给出的配置) 在左侧的debug面板中选择debug任务名称(由于下文给出的配置中实际上只含有1个配置,会被默认选中,这步可以被跳过。但是如果有多个debug配置则需要先选中一个。) 打开含有main函数的c语言源文件,待会编译的时候默认当前打开的文件中含有main函数 摁下F5键,启动一个debug流程 vscode按照选择的任务名称读取${workspaceFolder}/.vscode/launch.json文件,发现里面有参数"preLaunchTask" 于是vscode调用${workspaceFolder}/.vscode/tasks.json文件中指定的编译任务,调用gcc完成c程序的编译 完成编译后,vscode继续按照${workspaceFolder}/.vscode/launch.json文件中定义的debug配置调用gdb启动debug过程 程序遇到断点后暂停,此时可以在左侧debug面板中查看变量、调用栈等等信息 按下弹出的debug工具栏最右侧的红色方块停止debug 配置文件 windows和linux下的配置文件有所不同,请根据运行环境选择。在写入配置文件前请确认在终端中可以正常使用gcc和gdb命令。 Linux tasks.json { "tasks": [ { "type": "cppbuild", "label": "C/C++: gcc build active file", "command": "/usr/bin/gcc", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}", "-lpthread" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": ["$gcc"], "group": "build", "detail": "compiler: /usr/bin/gcc" } ], "version": "2....

April 30, 2022 · 2 min · Andyliu

Linux基础

文件内容添加

March 1, 2022 · 1 min · Andyliu

Python基础

python流程控制 python可迭代对象和迭代器对象 iter()返回一个迭代器 能够被迭代器迭代的对象就是可迭代对象 生成器对象 可以惰性生成需要使用的元素,有利于大规模数据操作。用到时再生成 使用生成器表达式生成:(i**2 for i in range(1,5))

February 28, 2022 · 1 min · Andyliu

PA1 数据的表示、类型、存取、运算

PA1-1 数据的表示和存取 计算机:用以处理信息的设备。故第一步要解决数据、信息如何存取、表示。 PA1 典型数据存取 数据的类型及其机器级表示 数据(真值)的类型: 无符号整数 带符号整数 定点/浮点数 非数值型:字母、操作码等 机器数:二进制位串 编码过程: 无符号整数:直接编码,直接做进制转换即可 带符号整数: 原码:直接编码+符号位(正0负1) 补码: 机器数的存取 机器数的定义 主存(RAM):随机存取存储器 我们讲的大小以字节为单位 i386中定义:word(字):2字节,double word(long,双字):4字节,32位 i386::3位机 随机存取:以O(1)的时间读写任意位置的数据 大端方式和小端方式 问题:如果一个需要存取的数据超过了一个字节,怎么存: 例:0x 12 34 56 78 小端方式:低有效字节在低地址 0x3 : 0x12 0x2 : 0x34 0x1 : 0x56 0x0 : 0x78 大端方式:低有效字节在高地址 对于存储器的模拟 如何使用C语言模拟? 使用字节类型的数组进行模拟 主存 内存访问接口: 理解主存的模拟方式 通用寄存器 CPU内部的通用寄存器 寄存器最长:32位 整个A寄存器:EAX,低16位部分:AX,AX中的高8位:AH,低8位:AL。 make test_pa-1测试是否通过 PA1-2 整数的表示与运算 整数的表示 无符号整数: 关注最大位数以及最大表示区间 带符号整数: 常用补码表示法 优点:0表示唯一,可以用加法表示减法(模运算系统) 整数的运算 模拟ALU支持功能:...

February 25, 2022 · 1 min · Andyliu

ConvLab-2 Toolkit

Download toolkit git clone https://github.com/mozilla/TTS.git Install and config env conda create -n convlab2 python=3.6.2 cd ConvLab-2 install cpu version of pytorch (run on personal computer)conda install pytorch==1.5.1 torchvision==0.6.1 cpuonly -c pytorch otherwise, auto installation cannot find package version. pip install -e .

February 8, 2022 · 1 min · Andyliu

Config Raspi after Reinstallation

Download system and write disk 64-bit Raspi images 64-bit Full Raspi images Enable SSH create empty file named ssh under the disk named boot Connecting wifi for the 1st time create wpa_supplicant.conf under disk named boot, write followings: country=CN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="<wifi name>" psk="<wifi passwd>" key_mgmt=WPA-PSK } then, plug the SD card to pi and start the pi. You should be able to connect to Pi using SSH....

January 29, 2022 · 1 min · Andyliu

Offline TTS

TTS by Mozilla Using open source code https://github.com/mozilla/TTS.git Direct Installation TTS supports python >= 3.6, <3.9. If you are only interested in synthesizing speech with the released TTS models, installing from PyPI is the easiest option. pip install TTS If you plan to code or train models, clone TTS and install it locally. git clone https://github.com/mozilla/TTS pip install -e . Custom installation However, the version is lower in github than in Pypl, losing many models and features....

January 29, 2022 · 1 min · Andyliu