you are better than you think

备忘

last update:

vps安全配置(一)

背景故事

本周一(2016.05.23)上午刘同学的服务器上的数据被清空,对方勒索3个比特比,目前比特比价格在2900+,3个比特币近9000大洋。 网络上没有绝对安全,能做的就是尽量提高黑客暴力猜解的成本。这里总结下关于ssh安全方面的设置。

一 配置说明

  •  修改ssh默认端口

修改端口后,对方依旧可以靠扫描端口来尝试,不过服务器一般还会有http之类的端口,这里只是增加了扫描的成本。

  • 禁止root远程登录

root用户是每个系统都存在的用户,如果不禁止root远程登录,土贼在暴力猜解时,只需要猜解密码而不需要猜解登录的用户名。

pg.v4 update小结

go-pg是golang实现的postgresql client,项目页:https://github.com/go-pg/pg。

按项目页说明使用Update有3中用法 :

// Update all columns except primary keys.
err := db.Update(&book)
// UPDATE "books" SET title = 'my title', text = 'my text' WHERE id = 1

// Update only column "title".
res, err := db.Model(&book).Set("title = ?title").Where("id = ?id").Update()
// UPDATE "books" SET title = 'my title' WHERE id = 1

// Update only column "title".
res, err := db.Model(&book).Column("title").Update()
// UPDATE "books" SET title = 'my title' WHERE id = 1

sum()函数文档中说sum的作用是Return the sum of the values for the requested axis ,即返回指定栏或列的值的和。

函数有4个有名参数, axis=None, skipna=None, level=None, numeric_only=None, **kwargs 。 不指定任何参数时即给axis赋值。

当sum(1)时是求行的和,当sum(0)时是求列的和。理解这个用法时参考了这个链接:http://blog.mathandpencil.com/column-and-row-sums/  

If you want to do a row sum in pandas, given the dataframe df:

python df.sum(axis=1)

and a column sum:

python df.sum(axis=0)