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

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

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.

阅读全文 »
0%