后面讲 high 起来了 fuck 不断。
也没有获得什么实质性的职位阶层,没有发表什么论文,没有得到多高的薪资。 却从来没有想过,你获得职位阶层/发表论文/高薪资目的是什么? 都是为了幸福,如果研究技术能幸福,为啥不呢
fxruby 好像没法用 ocra 打包了
ping++ 不好吗
这和前后端分离没什么区别,如果只是前端不想看到后端代码,直接在用 git submodule 引入就行了,而且这样可能会有前后端的路由冲突吧
点一下那个 %MEM,从大到小排序看看,bundle 应该就是 worker 占用的吧
后台多个服务能在一台服务器上跑吗?
https://brunosutic.com/blog/async-ruby 新出的这个 Async
可以用 Crystal 的 Fiber + Channel
foreman 和 Supervisor 在用途上有什么区别?
应该可以关掉这种提示,这种元编程生成的方法可能不太容易推断出来 https://www.jetbrains.com/help/ruby/code-inspection.html
剧情好像马特•达蒙的那部电影《赌王之王》,也是赌到一无所有,然后女朋友分手
可以用键盘打字吗
因为是“城一代”,不能像我这样从农村里来,还能回农村里去
用路由器科学上网可以更方便,避免手机电脑电视盒子都要配置一次的问题,也能让那些不使用系统代理配置的应用通过代理访问。
https://github.com/mperham/sidekiq/wiki/Signals
TSTP tells Sidekiq to "quiet" as it will be shutting down at some point in the near future. It will stop fetching new jobs but continue working on current jobs. Use TSTP + TERM to guarantee shutdown within a time period. Best practice is to send TSTP at the start of a deploy and TERM at the end of a deploy.
如果有任务运行的比较久的话,-t
也要设置的够长
上全局 VPN,不是 SS 的全局模式
现在内存这么便宜,8G/200 块,如果是用的 Macbook,那还有什么说的,直接换 16 寸那款 64G 版本
如果用 RESTful 的风格和你说的这种是不是冲突
{
"code": "...",
"message": "...",
"details": {}
}
看过什么内容会不会有记录
非对称加密,每次加密结果都会不一样
尝试补全 go 的加密方法
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"bytes"
"encoding/base64"
"fmt"
)
func SplitSubN(s string, n int) []string {
sub := ""
subs := []string{}
runes := bytes.Runes([]byte(s))
l := len(runes)
for i, r := range runes {
sub = sub + string(r)
if (i + 1) % n == 0 {
subs = append(subs, sub)
sub = ""
} else if (i + 1) == l {
subs = append(subs, sub)
}
}
return subs
}
func main() {
data := "hello"
const publickey = `
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw8cUnDShPMYFDZkL65Y0nUyyN
0Nqxgz6vsFEJj3I3A1nsaQBmGC1urtO9pGJkFzaXkQo7s2y+S53qdsWNufKk8U2l
SpiGjm4WWCucJTnYpC+nMwAAd/nmQudCtH4czJOkK4m29Tv6fUmvOtcSpQzW7zL0
47I6qkkAadGb8CAg9wIDAQAB
-----END PUBLIC KEY-----`
block, _ := pem.Decode([]byte(publickey))
pubInterface, _ := x509.ParsePKIXPublicKey(block.Bytes)
pub := pubInterface.(*rsa.PublicKey)
partLen := pub.N.BitLen()/8 - 11
fmt.Println(partLen)
chunks := SplitSubN(data, partLen)
buffer := bytes.NewBufferString("")
for _, chunk := range chunks {
bytes, err := rsa.EncryptPKCS1v15(rand.Reader, pub, []byte(chunk))
if err != nil {
fmt.Println("", err)
}
buffer.Write(bytes)
}
fmt.Println(base64.RawURLEncoding.EncodeToString(buffer.Bytes()))
}
#=> "runNVN4ZjB_Z-aA7-7ovGP4bVPNJdKpvXpR47Wn9mdvTYqhUp1z-vN_Q_mGylXH_y423cZyipKnZDEP0dTZFGMfsNhL81NOBNG981pQZ87t9_F2mnyqsoXOR6pUL7j4VQUExMsx3caeMOc_0KkQbjGGnbSvwQ9ewtH7UQBcYiUE"
然后用 ruby 解密
private_pem = <<-EOS
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAPDxxScNKE8xgUNm
QvrljSdTLI3Q2rGDPq+wUQmPcjcDWexpAGYYLW6u072kYmQXNpeRCjuzbL5Lnep2
xY258qTxTaVKmIaObhZYK5wlOdikL6czAAB3+eZC50K0fhzMk6Qribb1O/p9Sa86
1xKlDNbvMvTjsjqqSQBp0ZvwICD3AgMBAAECgYBjForF7JtPNkS6uyuAkzbhnUsN
Z38I0bjN9+zbyapnBXHNz8DiO78zbaKWsyvjjchdvMBAnSFzgRWIfx/vkTE/59GF
gfn7VLbvKMYULzbkZbh8NcwNjJLfLtNXmqt973uSiNah9JTeCHQd062VI5D64QHv
GgKMDAJ6Z2W4jSn8gQJBAPuXT0597Z3ciY6G0EHAhHrJNieDNJboUFodQlHqpTrs
SLmGTJVswj3Su2vi7ZEPyErHjL2vdrs1hDXKFVik+rkCQQD1KrKA7xUdYRwGnIry
CMH+uaECSmKhnZgFVg9zCSpDEaTOjenGGVuu6sXWmJKj7PZ1pFHsPrzOCSp/3Pk6
hmEvAkBL22NeFzn9zvDquFsyeAl5vBFH+JdyqLkRcqD8cfM/wN5skcGljBVE7rTz
4ogepNOPOHuG9dCmwYwLa9Lj11qBAkAafynZq31BtpwbztFphS7KQ++12qo8Q1cJ
xJpY2XW61+5S8J2Cbn0tM2x8W/MFSnf8kOzVtpYbQnxYY16AR8O7AkEAkHLKWspk
QFWRUlliBVpJg+GHe9VI7ND3wWIbV4H1kmyt08959LBpg7cZLu06PXUShwtADaE9
42Ta3K/fSme4Tw==
-----END PRIVATE KEY-----
EOS
s = 'KAPye436VwAqMZ6amu9UeODAh-3dhU6KNbcVXmBU-HK_geeHjyktLzOREMvWPnLcJ7mdddPwwHPEBZfaVliCFl0o9IDIUe7JfEHvmfG7limTUyii08O2b1cBu8pAnev3BxUfDJRqqh84-66Qiiur-syQQkAdnzH-wuG3DJ_UPgo'
rsa = OpenSSL::PKey::RSA.new(private_pem)
rsa.private_decrypt(Base64.urlsafe_decode64(s))
成功解密出 hello
然后用 ruby 加密
public_pem = <<-EOS
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw8cUnDShPMYFDZkL65Y0nUyyN
0Nqxgz6vsFEJj3I3A1nsaQBmGC1urtO9pGJkFzaXkQo7s2y+S53qdsWNufKk8U2l
SpiGjm4WWCucJTnYpC+nMwAAd/nmQudCtH4czJOkK4m29Tv6fUmvOtcSpQzW7zL0
47I6qkkAadGb8CAg9wIDAQAB
-----END PUBLIC KEY-----
EOS
data = 'hello'
rsa = OpenSSL::PKey::RSA.new(public_pem)
Base64.urlsafe_encode64 rsa.public_encrypt(data)
用上面 ruby 的解密方法也能解密
https://golang.org/pkg/crypto/rsa/#EncryptPKCS1v15
https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/PKey/RSA.html#method-i-public_encrypt
https://commondatastorage.googleapis.com/chromium-boringssl-docs/rsa.h.html#RSA_PKCS1_PADDING
https://stackoverflow.com/questions/47981709/ruby-rsa-public-key-encryption-to-golang
结论:你写的是对的
mongodb,pg 应该都有基于地理位置的查询功能
代码自测程度
是指哪些方法被修改了吗?
https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L368
如果 header 名是 symbol 格式会调用
key = key.to_s.split(/_/).map(&:capitalize).join('-')
可以改成
heades: { 'appId' => 'xlkb' }
我有个思路是定一个最小的时间间隔,比如每分钟的记录为一个 sortset,然后按需统计
redis = Redis.current
redis.zincrby("keyword:#{Time.now.strftime('%Y%m%d%H%M')}", 1, 'Ruby')
# 前一个小时的统计
hour = Time.now - 1.hour
start_time = hour.beginning_of_hour
end_time = hour.end_of_hour
keys = start_time.to_i.step(end_time.to_i, 60).collect { |t| "keyword:#{Time.at(t).strftime('%Y%m%d%H%M')}" }
redis.zunionstore("keyword:#{start_time.strftime('%Y%m%d%H')}", keys, aggregate: 'sum')
# 前一天的统计
day = Time.now - 1.day
start_time = day.beginning_of_day
end_time = day.end_of_day
keys = start_time.to_i.step(end_time.to_i, 60 * 60).collect { |t| "keyword:#{Time.at(t).strftime('%Y%m%d%H')}" }
redis.zunionstore("keyword:#{start_time.strftime('%Y%m%d')}", keys, aggregate: 'sum')
# 近一周top10关键词
start_time = (Time.now - 1.week).beginning_of_minute
end_time = Time.now.end_of_minute
keys = start_time.to_i.step(end_time.to_i, 60).collect { |t| "keyword:#{Time.at(t).strftime('%Y%m%d%H%M')}" }
redis.zunionstore("keyword:#{start_time.strftime('%Y%m%d%H%M')}-#{end_time.strftime('%Y%m%d%H%M')}", keys, aggregate: 'sum')
redis.zrevrange("keyword:#{start_time.strftime('%Y%m%d%H%M')}-#{end_time.strftime('%Y%m%d%H%M')}", 0, 9, with_scores: true)