Tips

  1. 使用反向代理时,git相关命令会出问题
  2. 实验前,创建新分支pa号,在其中做修改,完成以后合并pa到master中,并转回master分支

模板

# PA
## notification
-
## difficulties
1.
## summary

PA0

notification

  • 全程使用git
  • git commit --allow-empty可以使git空(无更改的)提交
阅读全文 »

笔记

命令

hexo new "postName" # 新建文章
hexo new page "pageName" # 新建页面
hexo generate # 生成静态页面至public目录
hexo server # 开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy # 部署到GitHub
hexo help # 查看帮助
hexo version # 查看Hexo的版本

按文章更新时间排序

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 10
order_by: -updated # 默认是-date

背景设置

把你挑选的背景图片命名为:background.jpg,放在blog\themes\next\source\images里,在blog\themes\next\source\css_custom文件的custom.styl首部添加

body {
background:url(/images/background.jpg);
background-attachment: fixed;
}

符号链接

# Windows,有些文件需要文件名相同才能打开
# -d 目录符号链接
mklink /d C:\file\path\Target C:\file\path\Source

安装主题

  1. npm安装在modules下
cd hexo-site
npm install hexo-theme-next
  1. git clone安装
cd hexo-site
git clone https://github.com/next-theme/hexo-theme-next themes/next
# Upgrade
cd themes/next
git pull origin master
# Configuration
cp themes/next/_config.yml _config.next.yml

Hexo

我的配置

# 设置英文字体
global:
family: Source Serif Pro

# layout\_partials\head\head.njk 设置中文字体
{{ next_font() }}
{{ next_vendors('fontawesome') }}
<link href="https://fonts.googleapis.com/css?family=Noto+Serif+SC&display=swap" rel="stylesheet">
# source\css\_variables\base.styl 添加中文字体
$font-family-chinese = "Noto Serif SC"

codes:
family: IBM Plex Mono

codeblock:
theme:
light: stackoverflow-light

Quick Start

npm install hexo-cli -g
hexo init blogFolderName
cd blog
npm install
hexo server

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Create a new post

$ hexo new "My New Post"

More info: Writing

Run server

$ hexo server

More info: Server

Generate static files

$ hexo generate

More info: Generating

Deploy to remote sites

$ hexo deploy

More info: Deployment

项目心得

24.10.9

将AliOss换成本地存储。可是一直插入不成功,使用Swagger调试,甚至数据库什么都接受不到!非常诡异的BUG
原来,是导入了错误的RequestBody,导致前端提交的表单怎么都接受不到!

// 导入了错误的包
import io.swagger.v3.oas.annotations.parameters.RequestBody;

import org.springframework.web.bind.annotation.RequestBody;

Nginx

反向代理

server {
listen 80;
server_name localhost;
# 反向代理,处理管理端发送的请求
location /api/ {
# localhost/api/abc转发到下面admin/abc
proxy_pass http://localhost:8080/admin/;
#proxy_pass http://webservers/admin/;
}
}

好处:

  • 不会暴露服务器,服务器可以安全放在内网,由nginx转发、缓存。

负载均衡

upstream webservers{
# 服务器组,按权重分配
server 127.0.0.1:8080 weight=90 ;
server 127.0.0.1:8088 weight=10 ;
# ip_hash 根据ip分配
# least_conn 分配到最少链接的服务器
# url_hash 根据url分配
# fair 分配到响应时间最短的服务器
}

server {
listen 80;
server_name localhost;

# 反向代理,处理管理端发送的请求
location /api/ {
# 负载均衡
proxy_pass http://webservers/admin/;
}
}

Swagger

Knife4j:Java MVC框架集成Swagger

API接口文档生成、测试

Chapter3 操作系统结构

复杂度管理方法 M.A.L.H

Modularity: 模块化,分而治之
Abstraction: 抽象,接口与实现分离,遵循宽进严出原则。例如虚拟内存、文件系统

对于大型系统,只有模块化和抽象,可能导致划分模块太多,交互关系复杂,因此还需要引入分层和层次结构控制复杂度。

Layering: 分层,每个层级是一套完整机制。通常一个模块只能与本层和上下层交互,不能跨层。例如OSI、TCP/IP
Hierarchy: 层次结构,大的子系统由多个小的子系统组织成。即同级模块的分层

宽进严出原则:容忍各种输入(包括恶意输入),严格控制模块的对外输出

微内核

宏内核架构:单点bug使整个系统崩溃。
微内核:解耦单个功能/模块(如文件系统、设备驱动)作为独立服务隔离运行,使内核成为一个最小功能集。

微内核架构服务隔离,单点出问题系统不会崩溃

内核态部分,称为μkernel\mu kernel

微内核优势:

  1. 弹性硬件拓展能力
  2. 硬件异构实现
  3. 功能安全
  4. 信息安全
  5. 时延确定

现代操作系统特征:1)虚拟内存;2)用户态、内核态隔离。

阅读全文 »

Gradescope Autograder

Spring 2018

44个Assn,偏向数据结构
邀请码:MNXYKX
学校:UC Berkeley
直接输入,不要选择2U-UC Berkeley,否则将提示COURSE ENTRY CODE IS INVALID

Spring 2021

19个Assn,偏向软件工程
邀请码:MB7ZPY

文章收录

The Law of the Broken Futon 浮沙筑高台法则

“Since I’m fine now, can’t I add that missing piece later, when it’s actually needed?” Sometimes, yes. But it’s much harder.
Adding the missing piece later means waiting until the damage is already underway, and hellishly difficult to undo.

A Response to “Why Most Unit Testing is Waste”

(Unit Tests) They are based on programmers’ fantasies about how the function should work. But programmers break down requirements into smaller components all the time – this is how you program. Sometimes there are misunderstandings, but that is the exception, not the rule, in my opinion.

2.1 Mystery of Java Restore

When instantiate an Object, obj = new Object(), obj stores the address of the Object, not the specific data struction.

(That is why all type of variables create memory boxes of 64 bits. It is just the memory of the address.)

Therefore, When we use obj2 = obj, Java simply copy the addr of obj and assign it to obj2 (They are pointing to the same Object), that is why when we change obj2.weight it effects obj.weight too.

阅读全文 »

Windows

# 模板
netsh dns add encryption server=<IP Address> dohtemplate=<DOH Template> autoupgrade=yes udpfallback=no

# 腾讯
netsh dns add encryption server=1.12.12.12 dohtemplate=https://doh.pub/dns-query autoupgrade=yes udpfallback=no

netsh dns add encryption server=120.53.53.53 dohtemplate=https://doh.360.cn/dns-query autoupgrade=yes udpfallback=no

查看DoH模板:

$ netsh dns show encryption

223.5.5.5 加密设置
----------------------------------------------------------------------
DNS-over-HTTPS 模板 : https://dns.alidns.com/dns-query
自动升级 : yes
UDP 回退 : no

PA1-1 24.5.30

又开始了ICS之旅,这次又给自己下了一个难度,找到了汪亮老师讲解的ICS 5!

target

第一课的目标是修正一个register错误声明

insteresting

  • 中途网易源Bad Gateway 502了,更换清华源,学会了:%s/163/tuna/g非常爽!
  • 又学了几个终端快捷键
  • 想到了用 ccache 加速我的PA

problems

  1. unionstruct 的区别?
    unioin 在同一个内存空间中存储不同的数据类型。
    struct 则是同时存储不同的数据类型。
  2. 为什么要用 union?阅读i386手册
    2.3.1 General Registers
    As Figure 2-5 shows, the low-order word of each of these eight registers has a separate name and can be treated as a unit. This feature is useful for handling 16-bit data items and for compatibility with the 8086 and 80286 processors. The word registers are named AX, BX, CX, DX, BP, SP, SI, and DI.
    对于CPU来说,可以把AH AX AL看成单独的单元,拆分成小块。所以它们是共用关系。

PA1-2 ALU 24.6.5

target

实现ALU中的各类运算,包括设置标志位

knowledge

Appendix C

Name Function
CF Carry Flag ── Set on high-order bit carry or borrow; cleared otherwise.
PF Parity Flag ── Set if low-order eight bits of result contain an even number of 1 bits; cleared otherwise.
ZF Zero Flag ── Set if result is zero; cleared otherwise.
SF Sign Flag ── Set equal to high-order bit of result (0 is positive, 1 if negative).
OF
Overflow Flag ── Set if result is too large a positive number or too small a negative number (excluding sign-bit) to fit in destination operand; cleared otherwise.
阅读全文 »

Git配置

远程仓库 - 廖雪峰的官方网站 (liaoxuefeng.com)

  1. 创建ssh key,在c盘用户目录.git文件夹中
    ssh-keygen -t rsa -C "youremail@example.com"
    ssh-keygen -l -f ~/.ssh/id_rsa 可以查看秘钥的配置信息,包括邮箱
  2. 在GitHub账号设置页面,添加ssh key,复制.ssh/id_rsa.pub的信息,点击创建即可
  3. 测试是否成功:ssh -T git@github.com
    注意:如果测试不成功,可能是反向代理的问题

Github 远程仓库

  1. 在github上新建一个仓库
  2. git remote add origin git@github.com:github账号名称/仓库名称.git 关联仓库,origin是远程库的名字
  3. git push -u origin master把本地库内容(master分支)推送到远程库(oringin),-u 参数表示会把本地master分支和远程master分支关联起来,方便后面简化命令
  • git remote set-url origin <URL>更改仓库地址

github trending 热门软件

  • 项目含金量 stars 1k+
  • fork 拷贝项目到自己的仓库
  • pull request 合并分支

NJU

  • 学习编程语言如C、Rust
  • 精选精读论文
  • STFW:比百度更高效的办法

0.0 规范

我要编写一个名为“学习笔记”的 Web 应用程序,让用户能够记录感兴趣的主题,并在学习每个主题的过程中添加日志条目。“学习笔记”的主页对这个网站进行描述,并邀请用户注册或登录。用户登录后,可以创建新主题、添加新条目以及阅读既有的条目。

目录 ll_project 包含 4 个文件, 其中最重要的是 settings.pyurls.pywsgi.py。文件 settings.py 指定 Django 如何与系统交互以及如何管理项目。
在开发项目的过程中,我们将修改其中的一些设置,并添加一些设置。
文件 urls.py 告诉 Django,应创建哪些网页来响应浏览器请求。
文件 wsgi.py 帮助 Django 提供它创建的文件,名称是 web server gateway interface(Web 服务器网关接口)的首字母缩写。

1.0 创建环境

1.1 创建虚拟环境

在独立的项目文件夹下运行

python -m venv ll_env

python -m ensurepip --default-pip # 重装pip

将会创造一个ll_env文件夹
可以使用下面的命令激活虚拟环境。激活虚拟环境后,安装的模组将只在虚拟环境中生效,而不干扰到电脑上Python的模组

source ll_env/bin/activate # Linux系统
source ll_env/Scripts/activate # Windows系统

(ll_env)
work_directory$ # 命令提示符前会显示(ll_env)

使用deactive取消激活虚拟环境

1.2 安装配置Django

pip install --upgrade pip # 更新pip
pip install django # 安装Django
django-admin startproject ll_project . # 初始化Django
python manage.py migrate # 生成数据库
python manage.py runserver # 生成预览,可以在本地8000端口看到网页
Django手册: https://docs.djangoproject.com/en/4.1/ref/models/fields/
阅读全文 »

NJU gdb六步走

  1. 启动gdb,加载可执行文件
  2. 设置断点 break main 入口处设置断点
  3. 启动程序 run (参数)
  4. 查看程序当然状态
    • info register (EIP): 显示所有寄存器(或只有EIP寄存器)的内容
    • 栈:保存过程执行时的数据信息
  5. 继续下一条指令
    • stepsi(机器指令)
  6. 退出 quit

1.0 Cprograming

原网址: https://www.cprogramming.com/gdb.html

gcc main.c -g -Wall -Werror -o main    启动编译
gdb main    开始debug
list 列出代码
break 行    设置断点
	info break    断点信息
run   运行程序
next或step  进行单步编译(next跳过函数)
print <value>    打印变量的值
continue    跳到下一个断点位置
quit     退出
阅读全文 »
0%