学习API的设计是系统设计的重要部分。
学习一下twitter的开发文档、facebook的开发文档
https://developers.facebook.com/
https://apigee.com/console 方便你调试一大堆的API, See:
DevOps
学习API的设计是系统设计的重要部分。
学习一下twitter的开发文档、facebook的开发文档
https://developers.facebook.com/
https://apigee.com/console 方便你调试一大堆的API, See:
App Engine is a Platform-as-a-Service. It means that you simply deploy your code, and the platform does everything else for you. For example, if you app becomes very successful, App Engine will automatically create more instances to handle the increased volume.
Compute Engine is an Infrastructure-as-a-Service. You have to create and configure your own instances. It gives you more flexibility and generally costs much less than App Engine. The drawback is that you have to manage your deployment yourself.
Read more about Compute Engine
You can mix both App Engine and Compute Engine, if necessary. They both work well with the other parts of the Google Cloud Platform.
To put it simply: compute engine gives you a server which you have full control/responsibility for. You have direct access to the operating system, and you install all the software that you want, which is usually a web server, database, etc…
In app engine you don’t manage the operating system of any of the underlying software. You only upload code (Java, PHP, Python, or Go) and voila – it just runs…
App engine saves tons of headache, especially for inexperienced people but it has 2 significant drawbacks: 1. more expensive (but it does have a free quota which compute engine doesn’t) 2. you have less control, thus certain things are just not possible, or only possible in one specific way (for example saving and writing files).
Basic difference is that Google App Engine (GAE) is a Platform as a Service (PaaS) whereas Google Compute Engine (GCE) is an Infrastructure as a Service (IaaS).
To run your application in GAE you just need to write your code and deploy it into GAE, no other headache. Since GAE is fully sclable, it will automatically acquire more instances in case the traffic goes higher and decrease the instances when traffic decreases. You will be charged for the resources you really use, I mean, the Instance-Hours, Transferred Data, Storage etc. But the restriction is, you can create your application in only Python, PHP, Java and Go
On the other hand, GCE provides you full infrastructure in the form of Virtual Machine. You can write or install any program in GAE virtual machine. Actually GAE is the way to use Google Data Centers virtually. In GAE you have to manually configure your infrastructure to handle scalability by usingLoad Balancer.
google-cloud: https://cloud.google.com
docs: https://cloud.google.com/docs/
gcloud工具: https://cloud.google.com/sdk/gcloud/
What is the difference between Google App Engine and Google Compute Engine? http://stackoverflow.com/questions/22697049/what-is-the-difference-between-google-app-engine-and-google-compute-engine
GCE- faq: https://cloud.google.com/compute/docs/faq
开发者控制台帮助文档: https://developers.google.com/console/help/new (先看看这个会为后续使用节省不少时间)
GoogleCloudSDKInstaller.exe 后,似乎还是没有gcloud命令,需要手动执行 Google\Cloud SDK\google-cloud-sdk\install.bat
学习进度:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
@echo off rem Copyright 2013 Google Inc. All Rights Reserved. SETLOCAL rem <cloud-sdk-cmd-preamble> rem rem CLOUDSDK_ROOT_DIR (a) installation root dir rem CLOUDSDK_PYTHON (u) python interpreter path rem CLOUDSDK_PYTHON_ARGS (u) python interpreter arguments rem CLOUDSDK_PYTHON_SITEPACKAGES (u) use python site packages rem rem (a) always defined by the preamble rem (u) user definition overrides preamble SET CLOUDSDK_ROOT_DIR=c:\progra~1\google\Clouds~1\google-cloud-sdk SET PATH=%CLOUDSDK_ROOT_DIR%\bin\sdk;%PATH% IF "%CLOUDSDK_PYTHON%"=="" ( SET CLOUDSDK_PYTHON=python.exe ) IF "%CLOUDSDK_PYTHON_SITEPACKAGES%" == "" ( IF "%VIRTUAL_ENV%" == "" ( SET CLOUDSDK_PYTHON_SITEPACKAGES= ) ELSE ( SET CLOUDSDK_PYTHON_SITEPACKAGES=1 ) ) IF "%CLOUDSDK_PYTHON_SITEPACKAGES%" == "" ( IF "%CLOUDSDK_PYTHON_ARGS%" == "" ( SET CLOUDSDK_PYTHON_ARGS=-S ) ELSE ( SET CLOUDSDK_PYTHON_ARGS=%CLOUDSDK_PYTHON_ARGS:-S=% -S ) ) ELSE IF "%CLOUDSDK_PYTHON_ARGS%" == "" ( SET CLOUDSDK_PYTHON_ARGS= ) ELSE ( SET CLOUDSDK_PYTHON_ARGS=%CLOUDSDK_PYTHON_ARGS:-S=% ) rem </cloud-sdk-cmd-preamble> %COMSPEC% /C "%CLOUDSDK_PYTHON% %CLOUDSDK_ROOT_DIR%\bin\appcfg.py %*" ENDLOCAL %COMSPEC% /C exit %ERRORLEVEL% |
在使用google的hg和Google-cloud-sdk时都会遇到需要设置http代理的问题;
方式1: export http_proxy=10.xx.xx.xx:8888 // 无效
方式2: export http_proxy=http://10.xx.xx.xx:8888 // 无效
方式3: export https_proxy=http://10.xx.xx.xx:8888 // 无效
为什么?
通过下面对使用的python的httplib2的代码分析发现:
其他:
对于Go写的程序来讲,对于https请求来讲,优先参考 https_proxy,然后参考http_proxy; 参考: net/http/transport.go
所以,如果有类似错误如下:
Get https://code.google.com/p/snappy-go/source/checkout?repo=: x509: certificate has expired or is not yet valid
请检查是否需要设置 http_proxy
在玩docker的时候,由于docker是不欢迎 http_proxy https_proxy 这些环境变量的,于是添加 no_proxy 环境变量绕过,如下:
1 |
export no_proxy=$no_proxy,/var/run/docker.sock |
看起来似乎没啥问题,但是问题还是出现了,由于no_proxy 原本是 空的,于是现在的no_proxy 就成了:
1 |
,/var/run/docker.sock |
似乎也没啥问题呀,但是cloud sdk的httplib2 不小心把 空 匹配了所有域名了,代码如下: (坑爹不?)
万里长城坚不可摧,GFW坚也得摧
ssh + polipo 配置http代理
首先,你得有一个国外的sshd服务
1 2 3 4 |
socksParentProxy=localhost:9050 daemonise=true proxyAddress=:: proxyPort=8080 |
tinyproxy也是支持上游的socks代理设置的,但是,没有配成(可能是我用的tinyproxy版本不够新): https://banu.com/tinyproxy/
更多参考: http://library.zenlogic.com/ss/2014/05/10/shadowsocks-polipo-squid/
有些时候为了避免参数的copy,会尽可能将参数定义为指针类型;如果参数是一个接口,那么是不是要定义为接口的指针呢?如果不定一为指针是不是会导致“值传递”呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
package main import "fmt" type Messager interface { String() string } type SimpleMessage struct { } // 可以看出,无论对象还是对象指针都实现了String方法 func (this SimpleMessage) String() string { return "对于接口参数在运行时,传递的是 值 还是 地址,取决于运行时传递的是 值 还是 地址,定义的时候不要写成接口的指针" } func printMessager(m Messager, obj bool) { if obj { fmt.Printf("%p\n", &m) // 如果传入的是对象 } else { fmt.Printf("%p\n", m) // 如果传入的是指针 } fmt.Println(m.String()) } func main() { fmt.Println("传递对象时,进行了值的copy,可以看到地址不同") obj := SimpleMessage{} fmt.Printf("%p\n", &obj) printMessager(obj, true) // 传对象 fmt.Println("传递指针时,没有做值的copy,可以看到地址相同") msg := &SimpleMessage{} fmt.Printf("%p\n", msg) printMessager(msg, false) // 传指针 } |
http://play.golang.org/p/sw7ejPVV1t
永远不要把接口参数前面添加一个星号
VIM中有一个rtp变量,可以通过set rtp 来查看,这个变量写的可能是多个目录,如果要加载一个filetype=go 的文件,则vim会搜索rtp中指定的路径,在这些路径(权且用xxx标识)下,搜索xxx/syntax/go.vim 来加载语法文件,搜索 xxx/indent/go.vim 来查找缩进方式文件,等等
http://www.cnblogs.com/yjf512/archive/2012/12/27/2835331.html
go tool pprof http://localhost:3999/debug/pprof/profile
如果你使用的是outlook,如果邮箱密码变更了,一般情况下outlook会提示你重新输入密码,但是有时候不会(可能已转为脱机工作模式),这时候,想找到那个修改邮箱密码的地方是很难的,下面是我发现的一种方法,点击下图中的“脱机工作”图标,就会染出重新输入密码的对话框,输入新密码就OK了