chcp查看编码方式,936:’gbk’

改为utf-8,输入:chcp 65001
❌ 错误做法:
let obj = {}
obj == {} // false
✔ 正确做法:
const isObjEmpty = (obj) => !Reflect.ownKeys(obj).length && obj.constructor === Object;
注意:
Reflect.ownKeys方法,所以需要判断类型Object.keys()?Object.keys只能返回对象中可枚举的属性,Reflect.ownKeys返回所有属性var obj = {
a: 1,
b: 2
}
Object.defineProperty(obj, 'method', {
value: function () {
alert("Non enumerable property")
},
enumerable: false
})
console.log(Object.keys(obj))
// ["a", "b"]
console.log(Reflect.ownKeys(obj))
// ["a", "b", "method"]
浏览器将HTML解析为DOM的同时还创建了另一个树形结构,渲染树(render tree)。渲染树代表了每个元素的视觉样式和位置,同时决定浏览器绘制元素的顺序。
z-index属性的值可以是任意整数(正负都行)。表示的是笛卡儿
坐标系里的深度方向。拥有较高
z-index的元素出现在拥有较低z-index的元素前面。拥有负数z-index的元素出现在静态元素后面。
z-index的行为很好理解,但是使用它时要注意两个小陷阱。
z-index只在定位元素上生效,不能用它控制静态元素。z-index可以创建层叠上下文。一个层叠上下文包含一个元素或者由浏览器一起绘制的一组元素。其中一个元素会作为层叠上下文的根,比如给一个定位元素加上z-index的时候,它就变成了一个新的层叠上下文的根。所有后代元素就是这个层叠上下文的一部分。
所有层叠上下文内的元素会按照以下顺序,从后到前叠放:
z-index为负的定位元素(及其子元素)z-index为auto的定位元素(及其子元素)z-index为正的定位元素(及其子元素)下面这个例子可以用来理解层叠上下文,nested在第一个盒子的层叠上下文中,就算设置了很高的z-index,也会被第二个盒子遮挡。因为第一个盒子形成的层叠上下文在第二个盒子后面。
<body>
<div class="box one positioned">
one
<div class="absolute">nested</div>
</div>
<div class="box two positioned">two
</div>
</body>
body {
margin: 40px;
}
.box {
display: inline-block;
width: 200px;
line-height: 200px;
text-align: center;
border: 2px solid black;
background-color: #ea5;
margin-left: -60px;
vertical-align: top;
}
.one { margin-left: 0; }
.two { margin-top: 30px; }
.positioned { (以下5行)每个定位的盒子都创建了一个层叠上下文,z-index为1
position: relative;
background-color: #5ae;
z-index: 1;
}
.absolute {
position: absolute;
top: 1em;
right: 1em;
height: 2em;
background-color: #fff;
border: 2px dashed #888;
z-index: 100; ←---- z-index只控制元素在它所处层叠上下文内的层叠顺序
line-height: initial;
padding: 1em;
}
扩展到实际应用中的场景是,在已经打开的弹窗中再打开一个弹窗,就算第一个弹窗中的某个元素设置了很高的z-index,也还是会被第二个(后绘制)的弹窗挡住。

[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(''))
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(''))
第二波解谜,可以在 https://twitter.com/jetbrains/status/1237694815283879943 找到。
给出了一段字符串:
.spleh A+lrtC/dmC .thgis fo tuo si ti semitemos ,etihw si txet nehw sa drah kooL .tseretni wohs dluohs uoy ecalp a si ,dessecorp si xat hctuD erehw esac ehT .sedih tseuq fo txen eht erehw si ,deificeps era segaugnal cificeps-niamod tcudorp ehT
仔细看一下就会发现是倒序
比较明显是倒序的,先尝试复原:
fun main() {
val string = ".spleh A+lrtC/dmC .thgis fo tuo si ti semitemos ,etihw si txet nehw sa drah kooL .tseretni wohs dluohs uoy ecalp a si ,dessecorp si xat hctuD erehw esac ehT .sedih tseuq fo txen eht erehw si ,deificeps era segaugnal cificeps-niamod tcudorp ehT"
print(string.reversed())
}
会得到:The product domain-specific languages are specified, is where the next of quest hides. The case where Dutch tax is processed, is a place you should show interest. Look hard as when text is white, sometimes it is out of sight. Cmd/Ctrl+A helps.
比较明显:
来到 MPS: The Domain-Specific Language Creator by JetBrains,能发现这里有个:
打开报告,根据提示,全选来尝试看到白色的文字:
复制出来可以得到:This is our 20th year as a company, we have shared numbers in our JetBrains Annual report, sharing the section with 18,650 numbers will progress your quest.
所以前往 JetBrains 2019 Annual Highlights – Celebrating 20 Years!,找了半天没发现哪里有 18650,后面才发现原来是这个加起来刚好是 18650:
进去后慢慢翻,有个图片:
有一段火星文?可以慢慢看,也可以看看图片的 alt 属性:
能勉强看出来是:Did you know JetBrains is always hiring? Check out the kareers(careers) page and see if there is a job for you or a quest challenge to go further at least.
在招聘页面能找到这个 Fearless Quester 在 https://www.jetbrains.com/careers/jobs/fearless-quester-356/,但是忘记截图了,现在已经 404 了,有点尴尬。
一直觉得自己执行力好差啊…还是要想办法做到今日事今日毕才行…
根据提示后续要到 Game Development Tools by JetBrains,用科乐美秘技触发,有一个打砖块游戏,打完砖块就出现了:
好消息,好消息!如果你正在使用较新的 Windows 10,那么截图只要:Windows 徽标键 +Shift+S 即可触发截图和草图应用来抓取矩形截图、任意形状截图、窗口截图或是全屏幕截图;Windows 徽标键 +PrtSc 即可触发截图和草图应用直接抓取全屏幕截图。不用再为了截图打开微信或 QQ 啦。
如果你觉得这个快捷键比较难按,你可以在设置->轻松使用->键盘中修改:
什么?你说我火星了?好像不是我,是我的朋友们…(无中生友ing)
好,来说说这个功能。根据此文章 Why doesn’t the screen clipping tool work anymore? – OneNote 所述,该热键本是 OneNote 用户用于截图的,自 Windows 10 创意者更新(也就是1703)后,由截图与草图应用接管。相关文章还包括:What’s New in Windows 10’s Creators Update 和 How to take and annotate screenshots on Windows 10。
还要注意的是,根据 Snip & Sketch…. : Windows10 – Reddit。截取屏幕后,你通常直接从剪贴板中取得图片,但是在:%LOCALAPPDATA%\Packages\Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy\TempState\ScreenClip 路径下仍然保存有图片的副本(也就是 C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy\TempState\ScreenClip)。可能有隐私泄露风险,请务必注意。
大多数情况下,普通用户使用 Docker 都需要使用 sudo 进行提权,否则可能要切换到 root 用户才可直接使用。其实只需要将当前用户加入 docker 用户组即可。
The docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.
Post-installation steps for Linux | Docker Documentation
正常情况下应该已经存在docker用户组了,如果没有则需要:
sudo groupadd docker
来添加一个名为docker的用户组。
然后就可以将当前用户加入docker用户组:
sudo usermod -aG docker $USER
或者:
sudo gpasswd -a $USER docker
注销后重新登录即可生效。按文档,对于有图形界面的Linux,应该注销再登录即可,否则应该完全重启。如果不方便注销,可以尝试:
newgrp docker
此时应该可以不需要sudo来使用Docker了。
发现版本19.03起有一个实验性特性,以非root用户运行Docker守护进程:
dockerd-rootless.sh --experimental
Post-installation steps for Linux | Docker Documentation
How can I use docker without sudo? – Ask Ubuntu
Docker security | Docker Documentation
推荐同学用 Google Chrome 作为日常的浏览器,但是他表示很难下载成功。为了省事,我决定直接弄个离线安装包给他。
直接搜索 chrome offline installer,找到了官方文档:下載及安裝 Google Chrome – 電腦 – Google Chrome說明。文中说明了在离线状态下安装 Chrome,需要在联网的主机上下载备用Chrome安装程序,就是我想要的离线安装包了。
只要打开上述链接再点击下载 Chrome 就可以得到离线安装包了。
仔细看了一下那个链接,其实本质上只是在 Chrome 的官方网址 https://www.google.com/chrome/ 后面加上 ?standalone=1 而已。即:https://www.google.com/chrome/?standalone=1。
时间限制: 1 Sec 内存限制: 128 MB
集合是由一个或多个确定的元素所构成的整体。集合的运算有并、交、相对补等。
集合A和集合B的交集:由属于A且属于B的相同元素组成的集合。
集合A和集合B的并集:由所有属于集合A或属于集合B的元素所组成的集合。
集合B关于集合A的相对补集,记做A-B:由属于A而不属于B的元素组成的集合。
假设集合A={10,20,30},集合B={1,10,50,8}。则A与B的并是{10,20,30,1,50,8},A与B的交是{10},B关于A的相对补集是{20,30}。
定义整数集合类CSet,属性包括:集合中的元素个数n,整型指针data存储集合中的元素。
方法有:重载输出,按样例格式输出集合中的元素。
重载+运算符,求集合A和集合B的并集,并返回结果集合。
重载-运算符,求集合B关于集合A的相对补集,并返回结果集合。
重载*运算符,求集合A和集合B的交集,并返回结果集合。
主函数输入集合A、B的数据,计算集合的并、交、相对补。
可根据题目,为CSet类添加需要的成员函数。
测试次数
每组测试数据两行,格式如下:
第一行:集合A的元素个数和元素
第二行:集合B的元素个数和元素
每组测试数据输出如下:
第一行:集合A
第二行:集合B
第三行:A和B的并
第四行:A和B的交
第五行:B关于A的相对补集 与 A关于B的相对补集的并,即(A-B)+(B-A)
每组测试数据间以空行分隔。
2
3 10 20 30
4 10 1 2 3
5 100 2 3 4 -10
6 -34 12 2 4 90 100
A:10 20 30
B:10 1 2 3
A+B:10 20 30 1 2 3
A*B:10
(A-B)+(B-A):20 30 1 2 3
A:100 2 3 4 -10
B:-34 12 2 4 90 100
A+B:100 2 3 4 -10 -34 12 90
A*B:100 2 4
(A-B)+(B-A):3 -10 -34 12 90
这个其实没啥好说的…思路清晰就可以了。并集运算可以先生成一个临时数组,加入集合A的元素,然后再加入集合B中不和已加入元素重复的元素。相对补集可以先生成、添加,然后再删除重复的。
主要问题可能在于有同学试图返回一个指向了即将失效的临时变量的指针。
You are returning a temporary object, but because you return it by value, the copy is created. If you return pointer or reference to temporary object, that would be a mistake.
If you change the return type to
C++ returning temporary objects confusion – Stack Overflowconst char *and returnss.str().c_str()you would return pointer to some buffer of temporarystd::stringreturned byss.str()and that would be bad.
#include <iostream>
#include <vector>
#include <algorithm>
class Set {
public:
explicit Set(std::vector<int> data) : data(std::move(data)) {}
Set operator+(const Set &rhs) const {
std::vector<int> tmp;
tmp.assign(this->data.begin(), this->data.end());
for (auto i : rhs.data) {
if (std::find(tmp.begin(), tmp.end(), i) == tmp.end()) {
tmp.push_back(i);
}
}
return Set(tmp);
}
Set operator-(const Set &rhs) const {
std::vector<int> tmp;
tmp.assign(this->data.begin(), this->data.end());
for (auto i : rhs.data) {
auto it = std::find(tmp.begin(), tmp.end(), i);
if (it != tmp.end()) {
tmp.erase(it);
}
}
return Set(tmp);
}
Set operator*(const Set &rhs) const {
std::vector<int> tmp;
for (auto i1 : this->data) {
for (auto i2 : rhs.data) {
if (i1 == i2) {
tmp.push_back(i1);
}
}
}
return Set(tmp);
}
friend std::ostream &operator<<(std::ostream &os, const Set &rhs) {
std::cout << rhs.data.front();
for (int i = 1; i < rhs.data.size(); ++i) {
os << ' ' << rhs.data[i];
}
return os;
}
private:
std::vector<int> data;
};
int main() {
int T;
std::cin >> T;
while (T--) {
int sizeA, sizeB;
std::cin >> sizeA;
std::vector<int> vectorA(sizeA);
for (auto &i : vectorA) {
std::cin >> i;
}
std::cin >> sizeB;
std::vector<int> vectorB(sizeB);
for (auto &i : vectorB) {
std::cin >> i;
}
Set setA(vectorA), setB(vectorB);
std::cout << "A:" << setA << std::endl
<< "B:" << setB << std::endl
<< "A+B:" << setA + setB << std::endl
<< "A*B:" << setA * setB << std::endl
<< "(A-B)+(B-A):" << (setA - setB) + (setB - setA) << std::endl;
std::cout << std::endl;
}
return 0;
}