MD5生成

string_view
std::string喜欢在堆上分配内存,显然这对性能提升是灾难的表现。所以可以使用string_view来解决这个问题
Spring中
POJO (Plain Old Java Object)最简单的对象,只包含私有属性和getter/setter方法
DTO (Data Transfer Object)传输用的物件,包装的PO
PO (persistent object)数据库table对应的java物件
DAO (data access object)逻辑物件,提取SQL并包装为PO
VO (View Object)视图对象,通常是POJO的子类,包含额外的属性和方法

idea数据库连接
idea中连接数据库要指定到具体数据库,要不然idea无法识别要依据哪个数据库做智能提示

ThreadLocal
Java中ThreadLocal可以用于在方法间传递变量
友元函数
这个功能是提供类以外的函数访问类的私有成员。友元函数可以访问类的私有和保护成员,而不需要通过公共接口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <iostream> using namespace std;
class Box { private: double width;
public: Box(double w) : width(w) {}
friend void printWidth(const Box& b); };
void printWidth(const Box& b) { cout << "Width: " << b.width << endl; }
int main() { Box box(10.5); printWidth(box); return 0; }
|
右值引用
右值引用(rvalue reference) 是一种允许你绑定到 临时对象(右值) 的引用类型,它是现代 C++ 中实现 移动语义(move semantics) 和 完美转发(perfect forwarding) 的关键技术。
语法:T&&
线程间传递数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include <iostream> #include <thread> #include <future> #include <chrono>
void compute(std::promise<int> prom) { std::this_thread::sleep_for(std::chrono::seconds(2)); int result = 42; prom.set_value(result); }
int main() { std::promise<int> prom; std::future<int> fut = prom.get_future();
std::thread t(compute, std::move(prom));
std::cout << "Waiting for result...\n"; int value = fut.get(); std::cout << "Result: " << value << "\n";
t.join(); return 0; }
|
python中类继承语法
1 2 3 4 5 6 7 8 9 10
| class Animal: def sound(self): print("动物的声音")
class Dog(Animal): def sound(self): print("汪汪")
a = Dog() a.sound() //汪汪
|
生成器(Generator)
yield关键字,相当于变种return.
生成器是简化写迭代器的工具,不需要定义 __iter__()
和 __next__()
方法。
1 2 3 4 5
| def count_up_to(n): count = 1 while count <= n: yield count count += 1
|
装饰器(Decorator)
@decorator
关键字
1 2 3 4 5 6 7 8 9 10 11
| def decorator(func): def wrapper(): print("装饰器执行") func() return wrapper
@decorator def my_function(): print("函数执行")
my_function()
|
协程(Coroutine)
Python 中的协程本质是特殊的生成器,它们可以暂停执行并保存状态,然后再恢复继续执行。
asyncio.sleep() 和普通的 time.sleep()辨别
普通的 time.sleep(seconds)阻塞调用:调用时,整个线程都会暂停,啥也做不了。
异步的 asyncio.sleep(seconds)非阻塞调用:await asyncio.sleep(1) 表示协程挂起,事件循环去执行别的任务。
pyhon单例
一个简单的单例
1 2 3 4 5 6 7 8 9 10 11
| class Singleton: _instance = None
def __new__(cls): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance
s1 = Singleton() s2 = Singleton() print(s1 is s2)
|
python类调用本质是调用 new 和 init
这句s1 = Singleton()
Python 实际执行了这两步:
调用 Singleton.__new__(Singleton) 创建实例
调用 Singleton.__init__(s1) 初始化实例(如果定义了 __init__)
这里这句就相当于s1 = Singleton.__new__(Singleton)
java切面,反射
通过注解Annotation实现函数的选中,汇集成一个切面Aspect,在切面通过反射实现一些公共属性的自动填充


文件上传
文件上传前端三要素