不会飞的章鱼

熟能生巧,勤能补拙,静能生慧;念念不忘,必有回响。

思路

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <ctype.h>
#include <cs50.h>
#include <stdio.h>
#include <string.h>

// Points assigned to each letter of the alphabet
int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};

int compute_score(string word);

int small_letters[] = {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};

int capital_letters[] = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90};

int temp_Points [] = {};

int main(void)
{
// Get input words from both players
string word1 = get_string("Player 1: ");
string word2 = get_string("Player 2: ");

// Score both words
int score1 = compute_score(word1);
int score2 = compute_score(word2);

// TODO: Print the winner
if (score1 > score2)
{
printf("Player 1 wins!");
}
else if (score1 == score2)
{
printf("Tie!");
}
else
{
printf("Player 2 wins!");
}
}

int compute_score(string word)
{
// TODO: Compute and return score for string
int score = 0;
for (int i = 0; i < strlen(word); i++)
{
if (isupper(word[i]))
{
for (int f = 0; f < sizeof(capital_letters); f++)
{
if (word[i] == capital_letters[f])
{
temp_Points[i] = POINTS[f];
score += temp_Points[i];
}
}
}
else if (islower(word[i]))
{
for (int f = 0; f < sizeof(small_letters); f++)
{
if (word[i] == small_letters[f])
{
temp_Points[i] = POINTS[f];
score += temp_Points[i];
}
}
}
else
{
i += 1;
}
}

return score;
}

思路

  • 获取startSizeendSize
  • 使用do while做好范围限制
1
2
3
4
5
6
int n;
do
{
n = get_int("Positive Integer: ");
}
while (n < 1);
  • 使用if语句判断startSizeendSize是否相等
  • 如果相等,输出Years为0
  • 如果不相等,根据出生人数➗3,死亡人数➗4,每计算一次Years加1

代码

阅读全文 »

安装MQTT服务器

1
2
3
4
5
6
7
8
9
10
11
# 安装 Mosquitto MQTT 服务器
brew install mosquitto

# 启动 Mosquitto 服务器
brew services start mosquitto
==> Successfully started `mosquitto` (label: homebrew.mxcl.mosquitto)

# 验证 Mosquitto 服务器是否正在运行
brew services list
Name Status User File
mosquitto started * *

安装MQTT客户端

访问github-MQTTX,找到MQTTX-1.9.6-arm64.pkg下载安装即可。

然后就可以看到有个MQTTX的图标,表示MQTT客户端安装成功。

阅读全文 »

level 1

Send an HTTP request using curl

1
2
$ curl http://127.0.0.1:80
pwn.college{sc9zRb7KF1lZSGtDWOxSGGTAeYp.dhjNyMDL3ATN3MzW}

level 2

Send an HTTP request using nc

阅读全文 »

什么是EdgeX

边缘中间件,服务于物理传感和执行“事物”和我们的信息技术(IT)系统之间。

EdgeX架构

设备服务

阅读全文 »

什么是 docker-compose

在 Docker 把容器技术大众化之后,Docker 周边涌现出了数不胜数的扩展、增强产品,其中有一个名字叫“Fig”的小项目格外令人瞩目。
Fig 为 Docker 引入了“容器编排”的概念,使用 YAML 来定义容器的启动参数、先后顺序和依赖关系,让用户不再有 Docker 冗长命令行的烦恼,第一次见识到了“声明式”的威力。
Docker 公司也很快意识到了 Fig 这个小工具的价值,于是就在 2014 年 7 月把它买了下来,集成进 Docker 内部,然后改名成了docker-compose

如何使用 docker-compose

安装

1
2
3
4
5
6
7
8
9
10
# intel x86_64
sudo curl -SL https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64 \
-o /usr/local/bin/docker-compose

# apple m1
sudo curl -SL https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-aarch64 \
-o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
阅读全文 »

熟悉Docker的使用

查看版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ docker version
Client:
Cloud integration: v1.0.35
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:51:16 2023
OS/Arch: darwin/arm64
Context: desktop-linux

Server: Docker Desktop 4.21.1 (114176)
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:50:59 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
  • docker engine版本号 24.0.2
  • 系统是linux
  • 硬件架构是arm64

查看信息

阅读全文 »

背景

采访了一位哈尔滨工业大学毕业的程序员,在上海工作三年,与两位合伙人一起创业做了一个长达十年的项目,有着十几个人的公司,年收入300~400万,相对来说算成功。

采访

你觉得你处在这个年龄层的程序员里面算什么水平?

中等吧,顶多能算中等。

阅读全文 »

首先安装Docker for Mac

Enable Kubernetes

设置里打开Kubernetes,下载会持续一段时间:

验证

1
2
3
4
5
6
7
8
9
10
~  kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready control-plane 46h v1.27.2

~  kubectl get ns
NAME STATUS AGE
default Active 46h
kube-node-lease Active 46h
kube-public Active 46h
kube-system Active 46h
阅读全文 »