《Learn Python The Hard Way》- 越难的路其实越容易

learn python the hard way

简评:这是的阅读完成的第二本python书籍,对于有一些编程经验的人来说这本书籍太过啰嗦了,不适合快速入门,和第一本(a byte of python)有太多重复的地方。但有个好处是练习特别多,一共52个。即使大多练习都比较简单,但通过自己一行一行的敲打,也会逐渐习惯这门语言。坦白的讲最后的几个Exercise我看的都比较粗糙,但确实是全书的亮点。作者从具体的一个游戏出发,教会你一步一步实现对问题的归纳整理,变成相应的类,再将类进一步分清层次,哪些可以变成基类,哪些可以继承。特别是对于游戏场景和地图的分析,可能就是大部分游戏的基本骨架(我没有编写大规模游戏的经验),最后作者通过代码实现基本的框架,然后重复这一个过程,一步一步细化整个程序。另外要说的一点是,作者对于很多初学者很难理解的知识点,都有很好的类比。比如:类和对象的概念,作者类比了一个例子,假设你有一个桶,桶里面装有三条Salmon,因为你爱给动物们起名字,于是你叫他们 Frank, Joe, and Mary现在请思考一个问题:What is the difference between Mary and a Salmon?这样一步一步带你去思考,而不是直接给你答案。久负盛名之下,必定有其经典的地方。

 

另外说一些:

这本书是ZED SHAW的一个系列教程,包括pdf、视频和答疑(官网地址)。

客观的讲,这本书的整体感觉还是不错的。对于0基础的学习者要开始学习的话,最好先从附录开始,如果简单的命令行都还不会的话。

比较深刻的有下面这一段话:

The world needs more weird people who know how things work and who love to figure it all out. When they treat you like this, just remember that this is your journey, not theirs. Being different is not a crime, and people who tell you it is are just jealous that you’ve picked up a skill they never in their wildest dreams could acquire.
You can code. They cannot. That is pretty damn cool.
翻译如下:
这个世界需要更多的疯狂的人,需要那些了解事物是如何运作的并喜欢探究其内部的原理的人。在这一段旅程中,如果有人漠视、嫉妒甚至仇恨你,你只需要记住的是:这只是你的一段经历,不是他们的。变得不同不是一种罪恶,如果有人这么给你说,那只能说明他嫉妒你了,因为你能掌握他们永远无法理解的一种能力。
你会code ,他们不能,这他妈本身就是一件超酷的事儿。
开篇作者还讲到了编程的三大关键能力:reading and writing, attention to detail, and spotting differences. (多读多写、关注细节、发现不同)在论述这三点的时候,作者都比较犀利:
At fi rst, you will not understand anything. It’ll be weird, just like with learning any human language. You will struggle with words and not know what symbols are what, and it’ll all be very confusing. Then
one day—BANG—your brain will snap and you will suddenly “get it.” If you keep doing the exercises and keep trying to understand them, you will get it. You might not be a master coder, but you will at least understand how programming works.
回想起自己的学习经历,的确是深有感受,我也许无法成为伟大的程序员,但了解事物本身的运行规律就是一件很赏心悦目的事情。

这本书最后的8个练习我看的比较粗糙,其他的代码自己基本上都实际敲过。有一点很好的地方,对于非常关键的知识点,作者都有很好的类比:比如对于类和对象的区别作者有下面这一段论述:

An important concept that you have to understand is the difference between a object. The problem is, a class and anclthere is no real “difference” between as object and an . They are actually the same thing at different points in time. I will demonstrate by a Zen koan:

What is the difference between a Fish and a Salmon?
Did that question sort of confuse you? Really sit down and think about it for a minute. I mean, a Fish and a Salmon are different but, wait, they are the same thing, right? A Salmon is a kind of Fish, so I mean it’s not different. But at the same time, because a Salmon is a particular type of Fish,it’s actually different from all other Fish. That’s what makes it a Salmon and not a Halibut. So a Salmon and a Fish are the same but different. Weird.This question is confusing because most people do not think about real things this way, but they intuitively understand them. You do not need to think about the difference between a Fish and a Salmon because you know how they are related. You know a Salmon is a kind of Fish and that there are other kinds of Fish without having to understand that.
Let’s take it one step further: say you have a bucket full of three Salmon and, because you are a nice person, you have decided to name them Frank, Joe, and Mary. Now, think about this question:
What is the difference between Mary and a Salmon?
Again, this is a weird question, but it’s a bit easier than the Fish versus Salmon question. You know that Mary is a Salmon, and so she’s not really different. She’s just a specifi c “instance” of a Salmon. Joe and Frank are also instances of Salmon. What do I mean when I say “instance”? I mean they were created from some other Salmon and now represent a real thing that has Salmon- like attributes.
Now for the mind- bending idea: Fish is a class, and Salmon is a class, and Mary is an object. Think about that for a second. Alright let’s break it down real slow and see if you get it. A Fish is a class, meaning it’s not a real thing, but rather a word we attach to instances of things with similar attributes. Got fi ns? Got gills? Lives in water? Alright it’s probably a Fish. Someone with a PhD then comes along and says, “No, my young friend, this Fish is actually Salmo salar, affectionately known as a Salmon.” This professor has just clarifi ed the Fish further and made a new class called “Salmon” that has more specifi c attributes. Longer nose, reddish flesh, big, lives in the ocean or fresh water, tasty? OK, probably a Salmon.

从具体的问题到实现的类,分析步骤如下:

1. Write or draw about the problem.
2. Extract key concepts from #1 and research them.
3. Create a class hierarchy and object map for the concepts.
4. Code the classes and a test to run them.
5. Repeat and refine

相信初学者会比较好理解这两个概念。

下载地址:http://pan.baidu.com/s/1pKRxrK3

中文版、英文版和视频教程(包括:pdf epub mobi格式)

《必然》-12个关键词帮你理清互联网未来发展方向

必然

简评:将互联网发展的方向浓缩成12个关键字,其中很大的一部分都没什么新意,要么都是已经实现,要么就是马上要实现的。我想真正震撼人心的预测,是透过极其微小甚至不可能的线索,看清其发展壮大的本质。就如当年的维基,现在的维基百科一样。特别是共享那一章,开源社区的确有一定的优势,但不是很赞同作者的回报模式,毕竟为了坚持理想而靠别人的捐助生活,不是每个人都能接受的。书中还讨论了人工智能,智能穿戴设备等,都比较有意思,一定要保重身体活到足够长,好玩儿的东西太多了。

我的Python学习之路

阅读书籍类:

①《a byte of python》

a byte of python

简评:《A byte of Python》是我读完的第一本Python书籍,篇幅很小,每个知识点都有对应的源码和解释。写作的风格很不错,一个核心的思想就是Explicit is better than Implicit,特别是第12章以一个简单的备份程序的4个版本介绍了程序开发的一个重要观念Software is grown, not built……太经典了。(篇幅太小,不做多于的笔记了)

阅读完成时间:2016年6月6日    笔记:无

②《Learn python the hard way》

learn python the hard way

阅读完毕时间:2016年6月17日  笔记链接

简评:这是的阅读完成的第二本python书籍,对于有一些编程经验的人来说这本书籍太过啰嗦了,不适合快速入门,和第一本(a byte of python)有太多重复的地方。但有个好处是练习特别多,一共52个。即使大多练习都比较简单,但通过自己一行一行的敲打,也会逐渐习惯这门语言。坦白的讲最后的几个Exercise我看的都比较粗糙,但确实是全书的亮点。作者从具体的一个游戏出发,教会你一步一步实现对问题的归纳整理,变成相应的类,再将类进一步分清层次,哪些可以变成基类,哪些可以继承。特别是对于游戏场景和地图的分析,可能就是大部分游戏的基本骨架(我没有编写大规模游戏的经验),最后作者通过代码实现基本的框架,然后重复这一个过程,一步一步细化整个程序。另外要说的一点是,作者对于很多初学者很难理解的知识点,都有很好的类比。比如:类和对象的概念,作者类比了一个例子,假设你有一个桶,桶里面装有三条Salmon,因为你爱给动物们起名字,于是你叫他们 Frank, Joe, and Mary现在请思考一个问题:What is the difference between Mary and a Salmon?这样一步一步带你去思考,而不是直接给你答案。久负盛名之下,必定有其经典的地方。

 

《白鹿原》-小说是一个民族的秘史

白鹿原

简评:书的开篇以老族长白嘉轩回忆起他的一生,最为骄傲的还是他娶过七个老婆逐渐铺开,主要讲述了白孝文,鹿兆鹏,黑娃,白灵,兆海这后一代人在民国,抗战,国共内战期间不同的生活。基本上还原了在大变动时代最真实的生活,坦白的说闹农协的那部分人确实是乌合之众,所以朱先生会在开始编写县志的时候会写成共匪,而国共之争也不过是天下为共和天下为公之争,只是个争斗的由头。也就不会感叹白灵逃过了敌人的追捕,却最后死在了根据地的枯井中。而吸大烟败家玩意儿白孝文最后成了滋水县第一位县长。作者在开篇引用了一句话:小说是一个民族的秘史。也许正史无法看到的内容都被用这样的方式记录了下来,但无奈这又是一部到1949年也就终结了的小说,毕竟像《亮剑》一类的书可能实在是太少了。

一个靠绳索捆绑的士兵所支撑的政权无疑是世界上最残暴的政权,也是最虚弱无能的政权……

我观‘三民主义’和‘共产主义’大同小异,一家主张‘天下为公’,一家昌扬‘天下为共’,既然两家都以救国扶民为宗旨,合起来不就是‘天下为公共’吗?为啥合不到一块反倒弄得自相戕杀?公字和共字之争不过是想独立字典,卖荞面和卖饸饹的争斗也无非是为独占集市!既如此,我就不大注重‘结局’了

走过了土壕到舍饭场那一段死亡之旅,随之而来的不是一碗辉煌的稀粥,而是生命的一个辉煌的开端……好好活着!活着就要记住,人生最痛苦最绝望的那一刻是最难熬的一刻,但不是生命结束的最后一刻;熬过去挣过去就会开始一个重要的转折,开始一个新的辉煌历程;心软一下熬不过去就死了,死了一切就都完了。白孝文现在以这种深刻的人生体验呼唤未来的生活,有一种对生活的无限热情和渴望

respberry pi 3 搭建Lamp安装wordpress设置花生壳域名外网访问

先说一下基本的步骤:

1.设置respberry pi 3为静态ip地址;

2.安装apache2+php5+mysql+php5-mysql;

3.下载wordpress并配置wp-config.php文件;

4.安装wordpress;

5.树莓派上安装花生壳穿透内网,绑定花生壳域名外网访问,完成。


一、设置树莓派3为静态ip地址

这里建议大家连接有线,无线的网络我试过,不是很稳定访问效果不理想,而且容易掉线。这里付上设置的有效方法:

输入命令:sudo nano /etc/dhcpcd.conf

在文件尾处加入如下:

树莓派静态ip设置

不需要解释了,第一行是你需要设置的静态ip地址;第二行是路由器地址;第三行是dns我设置成同路由器一样的地址让路由器自己去获取。

设置完成以后重启树莓派,然后输入ifconfig就可以看到设置成功并且能够访问网络了。

   2.安装apache2+php5+mysql+php5-mysql;

首先安装:apache2 并测试本机的静态ip地址能否访问:当然万能的


sudo apt-get update
sudo apt<span class="token operator">-</span>get install apache2 <span class="token operator">-</span>y

apache2服务器在本机上的默认目录为:/var/www/html/不需要更改

接下来需要做的是安装php


sudo apt<span class="token operator">-</span>get install php5 libapache2<span class="token operator">-</span>mod<span class="token operator">-</span>php5 <span class="token operator">-</span>y

创建测试页面 index.php:


sudo nano index<span class="token punctuation">.</span>php

加入简单的测试代码


<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">echo</span> <span class="token string">"hello world"</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

保存到/var/www/html/目录下,然后运行:http://静态ip/index.php

如果能够成功解析php页码,那么就基本上完成了大部分工作了。

接下来是安装mysql:


sudo apt<span class="token operator">-</span>get install mysql<span class="token operator">-</span>server php5<span class="token operator">-</span>mysql <span class="token operator">-</span>y

这个过程需要你输入mysql的密码,请记住。用户名为root。

安装成功以后登陆数据库:


mysql <span class="token operator">-</span>uroot <span class="token operator">-</span>p

 


mysql&gt; create database wordpress;

创建一个wordpress的数据库,如果显示如下,那么创建成功了,记住后面的;不能少


Query OK, 1 row affected (0.00 sec)
退出请使用Ctrl + D。

3.下载wordpress并配置wp-config.php文件;


cd <span class="token operator">/</span>var<span class="token operator">/</span>www<span class="token operator">/</span>html<span class="token operator">/</span>
sudo chown pi<span class="token punctuation">:</span> <span class="token punctuation">.</span>
sudo rm <span class="token operator">*</span>
sudo wget http<span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>wordpress<span class="token punctuation">.</span>org<span class="token operator">/</span>latest<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz

先是进入html目录清空内容,然后使用wget下载。我们马上解压内容,并删除压缩包:


tar xzf latest<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz
mv wordpress<span class="token operator">/</span><span class="token operator">*</span> <span class="token punctuation">.</span>
rm <span class="token operator">-</span>rf wordpress latest<span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz

如果使用ls你会看到在html下的内容如下:


<span class="token punctuation">.</span>
├── index<span class="token punctuation">.</span>php
├── license<span class="token punctuation">.</span>txt
├── readme<span class="token punctuation">.</span>html
├── wp<span class="token operator">-</span>activate<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>admin
├── wp<span class="token operator">-</span>blog<span class="token operator">-</span>header<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>comments<span class="token operator">-</span>post<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>config<span class="token operator">-</span>sample<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>content
├── wp<span class="token operator">-</span>cron<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>includes
├── wp<span class="token operator">-</span>links<span class="token operator">-</span>opml<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>load<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>login<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>mail<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>settings<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>signup<span class="token punctuation">.</span>php
├── wp<span class="token operator">-</span>trackback<span class="token punctuation">.</span>php
└── xmlrpc<span class="token punctuation">.</span>php

在html目录下使用命令:


sudo cp wp<span class="token operator">-</span>config<span class="token operator">-</span>sample<span class="token punctuation">.</span>php wp-config.php

sudo nano wp-config.php

打开wp-config.php文件作如下修改:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');    

/** MySQL database password */
define('DB_PASSWORD', '你的密码');

输入ctrl+x保存退出

然后在局域网内输入:http://静态ip地址实现安装。

可能你还需要设置一下/var/www/html文件权限以后好方便更新。

sudo chown -R www-data /var/www/html

5.安装wordpress就不解释了,没啥难度。

6.花生壳内网穿透请看下面这个链接,讲的也很仔细了。不懂的可以留言。今天就说到这里了。http://service.oray.com/question/2680.html