CAUTION The answer about changing the UNIX password for “postgres” through “$ sudo passwd postgres” is not preferred, and can even be DANGEROUS!
This is why: By default, the UNIX account “postgres” is locked, which means it cannot be logged in using a password. If you use “sudo passwd postgres”, the account is immediately unlocked. Worse, if you set the password to something weak, like “postgres”, then you are exposed to a great security danger. For example, there are a number of bots out there trying the username/password combo “postgres/postgres” to log into your UNIX system.
What you should do is follow Chris James‘s answer:
1 2 3 4 5
sudo -u postgres psql postgres
# \password postgres
Enter new password:
To explain it a little bit. There are usually two default ways to login to PostgreSQL server:
By running the “psql” command as a UNIX user (so-called IDENT/PEER authentication), e.g.: sudo -u postgres psql. Note that sudo -u does NOT unlock the UNIX user.
by TCP/IP connection using PostgreSQL’s own managed username/password (so-called TCP authentication) (i.e., NOT the UNIX password).
So you never want to set the password for UNIX account “postgres”. Leave it locked as it is by default.
Of course things can change if you configure it differently from the default setting. For example, one could sync the PostgreSQL password with UNIX password and only allow local logins. That would be beyond the scope of this question.
昨晚听了朱利安大王的世界历史课的第一讲。 脑子里是一团乱麻还没有理出头绪。 直到今天和团队的大佬聊起 AI 作画。
我们知道,在 AI 擅长的领域,人类早已一败涂地。而现在艺术领域遭到 AI 的大举进攻。 近一两年时间看到了很多很掉 san 值的 AI 作画,可以说看到 AI 画的这么烂,有点失望也有点安心。 可就在前不久,一个叫 Disco Diffusion 的 AI 作画引擎大火。看到这个 AI 的作品,心情从失望+安心这种奇怪的混合,变成激动+担忧。
这个定义不一定准确,因为 Rum 现在还是非常初级的阶段,想象空间非常大,提前下定义只会限制想象。这也是我选择 Rum 来学习 Go的原因吧。 前面三篇我们做好了一个可以持续运行并给 Rum 发送内容的 bot。我们自己的电脑不一定会长期在线和联网。于是我们可以在服务器上去运行 Rum,同时再运行我们写好的 bot。
type Cron struct { Method string`json:"method"` Schedule string`json:"schedule"` } type Group struct { Name string`json:"name"` ID string`json:"ID"` TestGroup bool`json:"testGroup"` Cron Cron `json:"cron"` TimeZone string`json:"timeZone"` } type Configs struct { URL string`json:"url"` Groups []Group `json:"groups"` }
for i := 0; i < fBs; i++ { bar += fullB } gB := perc*ttlBs - math.Floor(perc*ttlBs) //to decide which gab block to chose. log.Info("the gap block indicator is:", gB)
if gB < 0.0001 && perc < 0.9999 { bar += emptyB } elseif gB >= 0.0001 && gB < 0.35 { bar += quarterB } elseif gB >= 0.35 && gB < 0.6 { bar += halfB } elseif gB >= 0.6 && gB < 0.85 { bar += threeQuartersB } elseif perc >= 0.9999 { log.Info("quit earlier to prevent an extra empty block ", perc*ttlBs) return } else { bar += fullB }
eBs := int(ttlBs) - fBs - 1 for i := 0; i < eBs; i++ { bar += emptyB }
content := "" content += "2022 进度条 / Year Progress 2022\n" content += bar
now := time.Now().UTC() displayPerC := fmt.Sprintf("%.1f", perc*100) + "%" bar = content + displayPerC + "\nUTC时间: " + now.Format("2006, Jan 02, 15:04:05") + "\n"
return }
变量 bar 是函数要返回的值,也是要发送给 Rum 的全部内容。经过前面的计算,生成进度条之后,干脆在这个函数里把标题和时间戳也加上,成了最后的内容。 这个函数的一个参数是 perc,也即percentage,百分比,顺理成章的,我们需要根据时间来计算百分比了。