分类目录归档:Summary

看脑图学python

学一门编程语言,个人建议先要把这门语言的最基本的内容搞清楚,然后在这个基础上再逐一深入学习,那如何快速了解这些内容呢,当让用脑图是最方便的了,也是便于理解,通过脑图的学习,能让人快速掌握一门语言,以下是我在浏览国外一个网站的时候看到的,觉得不错,分享给小伙伴,希望对大家学习有些帮助,脑图是画的python3,但对学习python2同意具有借鉴意义,因为思想是一样的,别的不多说了,上图:

python-3-in-one-pic

安装paramiko报错解决

最近通过pip安装一台机器的ansible,真是费劲了周折,总结如下,安装时报

‘ascii’ codec can’t decode byte 0xe2 in position 75: ordinal not in range(128)错误,我没特别管,安装上是装上了,但ansible运行不正常,我在python命令行下,导入paramiko模块,会报这个错误,

ImportError: No module named cryptography.hazmat.backends

明显表示没安装成功cryptography这个模块,然后通过pip install来安装,发现快结束时又报

‘ascii’ codec can’t decode byte 0xe2 in position 75: ordinal not in range(128)

解决如下:

export LC_ALL=C
pip install –upgrade setuptools
以上能解决上一个报错,但再运行,
pip install  cryptography
会出现这个错误,distutils.errors.DistutilsError: Setup script exited with error: command ‘gcc’ failed with exit status 1
解决:
yum install gcc libffi-devel python-devel openssl-devel
然后,就没有问题了。
pip install  cryptography

 

具体export LC_ALL=C含义如下:

LC_ALL is the environment variable that overrides all the other localisation settings (except $LANGUAGE under some circumstances).

Different aspects of localisations (like the thousand separator or decimal point character, character set, sorting order, month, day names, language or application messages like error messages, currency symbol) can be set using a few environment variables.

You’ll typically set $LANG to your preference with a value that identifies your region (like fr_CH.UTF-8if you’re in French speaking Switzerland, using UTF-8). The individual LC_xxx variables override a certain aspect. LC_ALL overrides them all. The locale command, when called without argument gives a summary of the current settings.

For instance, on a GNU system, I get:

I can override an individual setting with for instance:

Or:

Or override everything with LC_ALL.

In a script, if you want to force a specific setting, as you don’t know what settings the user has forced (possibly LC_ALL as well), your best, safest and generally only option is to force LC_ALL.

The C locale is a special locale that is meant to be the simplest locale. You could also say that while the other locales are for humans, the C locale is for computers. In the C locale, characters are single bytes, the charset is ASCII (well, is not required to, but in practice will be in the systems most of us will ever get to use), the sorting order is based on the byte values, the language is usually US English (though for application messages (as opposed to things like month or day names or messages by system libraries), it’s at the discretion of the application author) and things like currency symbols are not defined.

On some systems, there’s a difference with the POSIX locale where for instance the sort order for non-ASCII characters is not defined.

You generally run a command with LC_ALL=C to avoid the user’s settings to interfere with your script. For instance, if you want [a-z] to match the 26 ASCII characters from a to z, you have to set LC_ALL=C.

On GNU systems, LC_ALL=C and LC_ALL=POSIX (or LC_MESSAGES=C|POSIX) override $LANGUAGE, while LC_ALL=anything-else wouldn’t.

A few cases where you typically need to set LC_ALL=C:

  • sort -u or sort ... | uniq.... In many locales other than C, on some systems (notably GNU ones), some characters have the same sorting order. sort -u doesn’t report unique lines, but one of each group of lines that have equal sorting order. So if you do want unique lines, you need a locale where characters are byte and all characters have different sorting order (which theC locale guarantees).
  • the same applies to the = operator of POSIX compliant expr or == operator of POSIX compliant awks (mawk and gawk are not POSIX in that regard), that don’t check whether two strings are identical but whether they sort the same.
  • Character ranges like in grep. If you mean to match a letter in the user’s language, use grep '[[:alpha:]]' and don’t modify LC_ALL. But if you want to match the a-zA-Z ASCII characters, you need either LC_ALL=C grep '[[:alpha:]]' or LC_ALL=C grep '[a-zA-Z]'. [a-z] matches the characters that sort after a and before z (though with many APIs it’s more complicated than that). In other locales, you generally don’t know what those are. For instance some locales ignore case for sorting so [a-z] in some APIs like bash patterns, could include [B-Z] or [A-Y]. In many UTF-8 locales (including en_US.UTF-8 on most systems), [a-z] will include the latin letters from a to y with diacritics but not those of z (since z sorts before them) which I can’t imagine would be what you want (why would you want to include é and not ź?).
  • floating point arithmetic in ksh93. ksh93 honours the decimal_point setting in LC_NUMERIC. If you write a script that contains a=$((1.2/7)), it will stop working when run by a user whose locale has comma as the decimal separator:

    Then you need things like:

    As a side note: the , decimal separator conflicts with the , arithmetic operator which can cause even more confusion.
  • When you need characters to be bytes. Nowadays, most locales are UTF-8 based which means characters can take up from 1 to 6 bytes. When dealing with data that is meant to be bytes, with text utilities, you’ll want to set LC_ALL=C. It will also improve performance significantly because parsing UTF-8 data has a cost.
  • a corollary of the previous point: when processing text where you don’t know what character set the input is written in, but can assume it’s compatible with ASCII (as virtually all charsets are). For instance grep '<.*>' to look for lines containing a <, > pair will no work if you’re in a UTF-8 locale and the input is encoded in a single-byte 8-bit character set like iso8859-15. That’s because . only matches characters and non-ASCII characters in iso8859-15 are likely not to form a valid character in UTF-8. On the other hand, LC_ALL=C grep '<.*>' will work because any byte value forms a valid character in the C locale.
  • Any time where you process input data or output data that is not intended from/for a human. If you’re talking to a user, you may want to use their convention and language, but for instance, if you generate some numbers to feed some other application that expects English style decimal points, or English month names, you’ll want to set LC_ALL=C:

    That also applies to things like case insensitive comparison (like in grep -i) and case conversion (awk‘s toupper(), dd conv=ucase…). For instance:

    is not guaranteed to match on I in the user’s locale. In some Turkish locales for instance, it doesn’t as upper-case i is İ (note the dot) there and lower-case I is ı (note the missing dot).

 

公有云会淘汰那些运维职业?

在现在,公有云的发展,绝对不容我们每个运维人忽视,它带给我们运维人翻身便利的同时,也对我们运维的某些岗位带来了冲击,以下以我个人理解随着公有云的发展那些岗位会被影响:

第一,IDC基础运维岗位,就是负责在公司安装机器、上架插线的岗位,会被逐渐替换掉,因为IAAS,即基础实施即服务,公有云现在基本都在做的这块,人家都把这块做出服务卖了,如果价格便宜,所以公司是在没必要自己做这些毫无价值的内容了。

第二,网络工程师岗位,网络工程师一直以来市场需求就不高,那随着公有云的成熟,就更不要网络工程师的存在了,因为公有云都帮你实现好了,而且超出你的期望满足你的需求,所以这些岗位会慢慢缩减,但不会消失,一些高手还可以去BAT发展,但要趁早了。

第三,服务器硬件评测工程师,就是在物理机时代,公司为了更好的选择好机器不出问题,保证业务的稳定,所以在公司设立对各个厂家服务器评测的工程师,因为使用云了,基本的硬件内容就不需要去考虑了,性能也不用考虑了,公有云可以随时动态调整云主机配置,这部分岗位会大大缩减,但不会消失,因为BAT还是需要的。

以上只是个人的一些理解,不代表权威, 同时做运维的兄弟进行交流。

学习的道与术

很快又到周末了,今天我们来谈一个学习的问题,来说说学习中的道与术,随着每个人的年龄的增长,我们总会发现身边的一些小伙伴进步飞速,才几年不见,发现要么当上了O,要么当上了技术大牛,自己也突突过了几年为啥还是小屌丝一枚呢,可能就要思考了,“你妹,科学家不是说人跟人的的大脑差别很小么,为什么现实差距这么大呢?”,这就引出了我们今天要说的话题,关于学习你必须要懂的道理,我觉得懂的越早的人越容易成功,当然这里我还是讲以普通人的智商来谈,那些大神级的歪果仁不在我讨论的范围之内,其实这地球上出几个牛逼人也正常,要不这世界还怎么发展,还iphone6,估计连电话都不知道是什么,那回头来说我们的问题:

那什么是道,先来回答以下二个问题:

你要成为什么样的人?

你的职业目标是什么?做技术?做管理?还是创业?抑或是其它

只有思考明白了这些你才算过了道的关,为什么要先把这些想明白,因为现在的知识也好,机会也好,有时候太多,反而很容易让自己走错了路,这尤其在对刚毕业的兄弟更为重要,毕业的时候一定要想清楚自己未来几年要去做什么?在学校,考虑的事情比较少,除了学习就是幻想了,但一毕业了就不一样了,你要考虑的事情就突然变多了,除了幻想,还的考虑什么女票、结婚、房子,车子、事业等,所以在这种情况下,很容易就迷茫了,会很容易短视,比如这个技术最挣钱,去学习,过2年,另一个技术比较流行,找工作很容易,就又去学,结果几年下来,面广了,但都不深入,随着时间的流逝,丧失了成为某一领域专家的机会,如果你要赶上去,就比较难,为什么?又回到刚才之前说的,假设人和人大脑差别很小,如果这个参数是常量,那么时间就是变量了,当然是所在某领域花的时间越长越牛逼了,所以想牛逼,想成就一番事业,你必须要把自己的道想明白。

在这我声明下,我这是举例说明,没有说面广不好,只想让你清楚自己的道是什么?所有的选择还是取决你的道。

说完道,我们来说术的层面,如果你道想明白了,其实术就是解决做什么,怎么做的问题,但这里也需要一些思考:

你要学那些?

如何学?

具体到看什么书?

找那个老师?

要达到什么目标?

业界最佳实践是什么?

如果这些你就能明白并能写下来做成计划,坚持了下来,我想术的层面也就过关了。

所以仅仅明白了道还不行,没有术仍然无法让你达到自己的人生巅峰。

最后,我们来出个选择题,请思考以下哪个选项最符合你目前的状态?

A、道为正,术为正,清楚的知道自己的职业目标,而且进步飞快
B、道为正,术为负,清楚知道自己的职业目标,但感觉进步很慢
C、道为负,术为正,天天学的东西好多好累,感觉自己要被淘汰了
D、道为负,术为负,很累,很迷茫,不知道自己该怎么做

如何激励一个人?

如果你走上管理岗位,你会发现如何激励别人可能是你的必修课之一,如果你之前是走的纯技术线,每天面对的是机器,研究什么时候最好的技术,那从做管理的那天起,你必须还要研究人,因为只有理解了人,你才能带好一个团队,很多人都很羡慕做管理,觉得管理者每天除了开会还是开会,没什么具体工作,还能让人做什么就做什么,其实我做管理的时间里,最大的感触是管理岗也只是岗位而已,他跟其他岗位没什么分别,开会其实只是它的工作之一,没什么好稀奇的,每个岗位都解决公司的一些问题,管理岗只是解决的问题层面不同而已,越高层决策的面越大,我们回来说我们的主题,为什么说激励如此重要?因为对管理者而言,团队的士气在一定程度上决定了产出,那团队如何才有士气,每个人都要像打了鸡血一样的工作,那就是管理者的水平了,这里要我说的要激励了,如何激励单这个课程就可以讲2天了,我就听过这样的课程,老师2天的时间就单讲激励一个话题就得压缩着讲,否则时间都不够,为什么激励如此复杂,这就要谈到我们人,说到底是因为人性的复杂,因为人太复杂了,人的需求分5个层次,而每个人都可能处在不同的层次,所以你管理的人员越多,理解每个人的需求层次就比较复杂和耗时,靠猜是万万不能的,因为激励不好反而会产生负的效果,今天我不多谈激励的方法有多少,这个大家可以自己去看书,我今天想说的是,不管你用什么方法,最终激励人的核心是让对方觉得自己是个有用的人,觉得自己有价值,这是激励一个人的根本,除此无它法,因为只有让对方觉得自己做的事有价值,觉得自己做工作的过程中对某些事情的结果起了部分决定作用,他才会全力投入其中,所以,你一定要实时的告诉员工他现在做的事情很重要,可能一句“这事就靠你了”,“我相信你能做好”,一些简单的话语都能激起人强大的责任心,另外在安排工作时要告诉员工做了这件事,他能从中学到什么,对自己有什么价值也是不错的激励方法,因为每个人都是积极向上的,但不是每个人都能认识到自己做的工作能对自己产生什么价值,这时候你作为管理者就要说清楚,让员工明白。

当你懂得了激励,你要在工作中让他变为你的习惯,一段时间后你会发现团队中有人士气低落了,你就该反省自己这段时间是否给予了他足够的关注,到这里你也应该明白,激励是个长期的工作,他没有结束的时间,他最终就是你的习惯,你在不自觉中就鼓励了某人,这样你会逐渐变得有影响力,很多人愿意跟随你,这就是我要说的另一个问题,那究竟怎么判断一个管理者是不是一个好的管理者?我觉得唯一的判断标准就是如果他立刻这个岗位,还有多少人愿意跟随他,这是了解他是否具备管理能力的重要参考。