我为什么不热衷于升级软件了

在我正式开始学习计算机知识,也就是大学之前的几年里,我想大概是从我家刚有电脑的初中开始吧,我都是一个热衷于把电脑里的软件更新到最新版的人。然而从那以后的八年里,我越来越懒于更新软件了,手机也好,电脑也好,平板也好,软件商店上常常五六十个App更新我都能做到视而不见了。

刷题的况味

写下这个标题的时候我才发现我竟然一直都不是很确定“况味”这个词到底是个什么意思,忘记了中学时候在什么地方看到过这个词,估计是在哪一堂语文课或者哪一次语文阅读的时候遇到的吧。去查了一下才知道跟“滋味”是差不多的,这么说来放在标题也还是挺贴切的。

似乎读不下去书了

我最近发现自己的读书能力下降的非常厉害,不仅是读书的效率还是读书的意愿都不像以前那么好了。

我的WFH配置

不知不觉在家工作已经快要两个月了,其间经历了一次跳槽来Google,在新公司家里也呆了一个月了。因为两周前Pichai说可能要一直WFH的年底,于是不得不为长期作战做准备了,添置了一些新的硬件。现在我对于WFH的环境还是比较满意的了。

在网页中使用Service Worker发送通知

最近写了一个上班时摸鱼用的舰C远征计时工具。React的部分很快就搞定了,但是因为远征结束的时候要发送一个浏览器通知,我以前没有写过这种东西,所以走了很多弯路花了不少时间,最终还是把功能实现了。

这是我第一次使用Service Worker,也没有花很多时间去研究,所以肯定会有很多疏漏。

给博客加了GitHub Action自动部署

虽然很久没有写博客了,但是题还是在做的,最近也跳了槽来了Google。前几天有人给我的BGM report仓库开PR,由于不想手动try,所以就加了个简单的GitHub Action来自动测。今天给博客也加上了Action,以后就不用手动run Hexo命令来生成然后再push了。

Action Workflow:https://github.com/Shell32-Natsu/Shell32-Natsu.github.io/blob/src/.github/workflows/deploy.yml

今天还写了个远征计时的小玩意儿,用React的小App,也用了Action自动部署到GitHub Pages。

LeetCode 1156. Swap For Longest Repeated Character Substring

Given a string text, we are allowed to swap two of the characters in the string. Find the length of the longest substring with repeated characters.

Example 1:

1
2
3
Input: text = "ababa"
Output: 3
Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3.

Example 2:

1
2
3
Input: text = "aaabaaa"
Output: 6
Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6.

Example 3:

1
2
Input: text = "aaabbaaa"
Output: 4

Example 4:

1
2
3
Input: text = "aaaaa"
Output: 5
Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5.

Example 5:

1
2
Input: text = "abcdef"
Output: 1

Constraints:

  • 1 <= text.length <= 20000
  • text consist of lowercase English characters only

LeetCode 1155. Number of Dice Rolls With Target Sum

You have d dice, and each die has f faces numbered 1, 2, ..., f.

Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target.

Example 1:

1
2
3
4
Input: d = 1, f = 6, target = 3
Output: 1
Explanation:
You throw one die with 6 faces. There is only one way to get a sum of 3.

Example 2:

1
2
3
4
5
Input: d = 2, f = 6, target = 7
Output: 6
Explanation:
You throw two dice, each with 6 faces. There are 6 ways to get a sum of 7:
1+6, 2+5, 3+4, 4+3, 5+2, 6+1.

Example 3:

1
2
3
4
Input: d = 2, f = 5, target = 10
Output: 1
Explanation:
You throw two dice, each with 5 faces. There is only one way to get a sum of 10: 5+5.

Example 4:

1
2
3
4
Input: d = 1, f = 2, target = 3
Output: 0
Explanation:
You throw one die with 2 faces. There is no way to get a sum of 3.

Example 5:

1
2
3
4
Input: d = 30, f = 30, target = 500
Output: 222616187
Explanation:
The answer must be returned modulo 10^9 + 7.

Constraints:

  • 1 <= d, f <= 30
  • 1 <= target <= 1000

Invoke Jenkins Jobs from BitBucket Server by Webhook

I just added unit tests and am planning to add functional test scripts to one of my project. What comes to your mind when you work on a project every day, already have had test scripts and there is a Jenkins server available? Right, automate it!

My compay uses BitBucket server. However, although there are several BitBucket server plugins available, all of them are not free (and they are even not cheap!). So far, I just want to invoke a Jenkins job when some events happen. Should we pay thousands of dollars for such a easy (relatively) use case? So I decide to find some free alternatives.

LeetCode 1035. Uncrossed Lines

We write the integers of A and B (in the order they are given) on two separate horizontal lines.

Now, we may draw a straight line connecting two numbers A[i] and B[j] as long as A[i] == B[j], and the line we draw does not intersect any other connecting (non-horizontal) line.

Return the maximum number of connecting lines we can draw in this way.

Example 1:

1
2
3
4
Input: A = [1,4,2], B = [1,2,4]
Output: 2
Explanation: We can draw 2 uncrossed lines as in the diagram.
We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will intersect the line from A[2]=2 to B[1]=2.

Example 2:

1
2
Input: A = [2,5,1,2,5], B = [10,5,2,1,5,2]
Output: 3

Example 3:

1
2
Input: A = [1,3,7,1,7,5], B = [1,9,2,5,1]
Output: 2

Note:

  1. 1 <= A.length <= 500
  2. 1 <= B.length <= 500
  3. 1 <= A[i], B[i] <= 2000