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     退出
阅读全文 »

Task Scheduler

WIN+R, taskschd.msc
在这里可以设置定时任务、登录任务。
有些软件的开机自启动就设置在这里。比起组策略有更多的可选项(延迟启动,网络和电源要求等)

Group Policy Editor

WIN+R, gpedit.msc
在这里可以设置一些开关机时执行的任务

Computer Configuration -> Windows settings -> Scripts -> Shutdown -> Properties -> Add

静默运行脚本

Task Scheduler没有办法隐藏窗口
在Task Scheduler运行该vbs脚本,目标脚本路径作为参数即可实现静默运行。

' minRun.vbs
' Run minRun.vbs Task Scheduler在可选参数提供实际脚本地址
' 检查是否提供了批处理文件路径参数
If WScript.Arguments.Count = 0 Then
WScript.Echo "Error: No batch file path provided."
WScript.Quit 1
End If

' 获取批处理文件路径参数
Dim batchFilePath
batchFilePath = WScript.Arguments(0)

' 检查批处理文件是否存在
If Not FileExists(batchFilePath) Then
WScript.Echo "Error: Batch file not found at " & batchFilePath
WScript.Quit 1
End If

' 创建 WScript.Shell 对象
Set oShell = CreateObject("Wscript.Shell")

' 执行批处理文件
' 使用 0 表示不等待批处理文件执行完成
' 使用 True 表示以同步方式运行(等待批处理执行完成)
oShell.Run batchFilePath, 0, True

' 清理
Set oShell = Nothing

' 检查文件是否存在的辅助函数
Function FileExists(filePath)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(filePath)
End Function

1.0 编辑

% 表示注释
; 表示不显示结果,只执行语句
clear 清除内存变量
clc 清除全部
pretty 用分式表示公式
simplify 化简命令
exp(x) 指数, e^x
log2(x) 以2为底数的对数
阅读全文 »

全键盘操作指南

终端操作

  • code <Folder> 打开工作区;相当于 CTRL+K, CTRL+O
  • code -diff file1 file2 对比两个文件(颜色标注)
  • code <File> 打开文件
  • CTRL + ←/→ 逐词跳转
  • CTRL+K 清理终端
  • CTRL+P: >Tasks 新建任务,用 CTRL+P: >run 运行;相当于 make

Panel操作

CTRL+P 打开Panel

  • @ 符号:寻找symbol,如函数名、变量名;相当于CRTL+SHIFT+.
  • # <String> 符号:全局搜索字符串
  • >join line 选中多行合并为一行

编辑区操作

  • CTRL+G <Line_Number> 跳到指定行
  • CTRL + ←/→ 逐词跳转;相当于vim的 w
  • ALT + ↑/↓ 移动某行代码
  • ALT + SHIGT+ ↑/↓ 复制某行代码
  • CTRL+P: >Snippets 创建代码模板
  • SHIFT+ALT+F12 找到某个命名的全部引用(而不是简单的搜索)
  • SHIFT+ALT+F 格式化代码,相当于 >Format Document

设置 settings.json

显示.gitignore屏蔽文件

关闭 Search: Use Ignore Files,或

"search.useIgnoreFiles": false

自定义终端

"terminal.integrated.defaultProfile.windows": "MSYS2-UCRT64",
"terminal.integrated.profiles.windows": {
"MSYS2-UCRT64": {
"path": "D:\\your\\path\\MSYS2\\msys2_shell.cmd",
"args": [
"-defterm",
"-no-start",
"-here",
"-ucrt64"]
}
},

保护文件

防护中心 - 高级防护 - 自定义防护 - 锁定文件读取、创建、修改、删除权限

说明:%%是注释%%

程序设计

  1. 首先写<view class="class_name"></view>来结构化设计;每个class对应一个css样式
<view class="container">
<image class="avatar" src="../images/avatar/avatar-1.jpg"></image>
<text class="motto">Welcome, Orange Can</text>
<view class="journey-container">
<text class="journey">Start your journey of miniprogram</text>
</view>
</view>
  1. css中放样式信息,写法如下;全局样式可以放app.css
/* 示范写法 */
.class_name{
attribute: rpx;
location_attribute: center;
}
/* 一般网页可以这样布局 */
.container{ /* 最外层的<view> */
display: flex; /* 布局方式 */
flex-direction: column; /* 列,从上到下;reverse是从下到上;可选row */
align-items: center; /* 居中 */
}
阅读全文 »

基本知识

特殊字符

*:匹配前面的字符0+次
+:匹配前面的字符1+次
?:匹配前面的字符0/1次
[a-z_]:匹配中括号内字符1次,示例是匹配小写字母或下划线

定位符

^:表示开头处
$:表示结尾处
\b:匹配单词间的空格处

特殊序列

\d:匹配数字
\w:匹配字母、数字、下划线
\s:匹配不可见字符
\D:匹配非数字
\W:匹配非字母、数字、下划线
\S:匹配非空白字符

举例

  • “hel?o”:可以匹配heo, helo(0次或1次)
  • “hel+o”:可以匹配helo, hello(1次以上)
  • “hel*o”:可以匹配heo, helo, hello(0次以上)
  • r"+\-*/":匹配加减乘除符号,r表示不转义

技术博主

  • 多看开发者大会!
  1. ThePrimeTime
  2. CodeAesthetic
  3. Molly Rocket

What’s so special about 2147483648?

by Sandra Henry-Stocker, Unix Dweeb, from NetWorkWorld 945870
tags: Data Center, Linux, Open Source
难度:EASY

First of all, it’s a power of 2. That’s undoubtedly not the most obvious thing unless you’re some kind of mathematical genius. And, to be exact, it’s 2^31. That’s significant — as you’ll see in a minute.

In binary, 2147483647 is 01111111111111111111111111111111 and it’s the biggest positive number that will fit in 32 bits when using the “two’s complement” notation (补码) — the way of representing numbers that allows for negative values. If we could use that leftmost (high order) bit, the largest possible number would be twice as large since every extra bit doubles the range of numbers that a binary number can represent.

And 2147483648 just happens to be the number you’d get if you multiplied 256 * 256 * 256 * 256 and then divided the result by 2. Not excited yet? Give me a moment.

阅读全文 »

标准写法

  • 编译hello.c
hello:hello.c
gcc hello.c -o hello # 注意开头的tab, 而不是空格

.PHONY: clean
# 用于指示"clean是一个伪目标", 伪目标相应的命令序列总是会被执行.

clean:
rm hello # 注意开头的tab, 而不是空格

生成目标文件名:依赖文件列表
用于生成目标文件的命令序列 # 注意开头的tab, 而不是空格
  • 更有效率的写法
CC=gcc
CFLAGS=-I.

hellomake: hellomake.o hellofunc.o
$(CC) -o hellomake hellomake.o hellofunc.o
  • 全部编译
SOURCE = $(wildcard *.c)  
TARGETS = $(patsubst %.c, %, $(SOURCE))

CC = gcc
CFLAGS = -Wall -g

all: $(TARGETS)

%: %.c
$(CC) $< $(CFLAGS) -o $@

.PHONY:clean all

clean:
rm -f $(TARGETS)

Makefile文件的格式

[廖雪峰](http://ruanyifeng.com/blog/2015/02/make.html)

Makefile文件由一系列规则(rules)构成。每条规则的形式如下。

<target>: <prerequisites> 
[tab] <commands>

上面第一行冒号前面的部分,叫做"目标"(target),冒号后面的部分叫做"前置条件"(prerequisites);第二行必须由一个tab键起首,后面跟着"命令"(commands)。

  • 键入make -nB, 它会让make程序以"只输出命令但不执行"的方式强制构建目标。

文件名匹配

%.o: %.c # 所有.o/.c结尾的文件

变量

txt = Hello World
test:
@echo $(txt) # 变量放在$()中,@表示不打印直接执行
0%