forked from poole/hyde
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.json
1 lines (1 loc) · 56.8 KB
/
content.json
1
{"meta":{"title":"WINFAN","subtitle":null,"description":null,"author":"winfan","url":"http://winfan.xyz"},"pages":[{"title":"Categories","date":"2016-10-10T02:53:42.000Z","updated":"2016-10-10T02:53:42.000Z","comments":true,"path":"categories/index.html","permalink":"http://winfan.xyz/categories/index.html","excerpt":"","text":""},{"title":"Tags","date":"2016-10-10T02:53:59.000Z","updated":"2016-10-10T02:53:59.000Z","comments":true,"path":"tags/index.html","permalink":"http://winfan.xyz/tags/index.html","excerpt":"","text":""}],"posts":[{"title":"隐私政策","slug":"private","date":"2018-03-10T12:46:25.000Z","updated":"2018-03-13T05:28:02.030Z","comments":true,"path":"2018/03/10/private/","link":"","permalink":"http://winfan.xyz/2018/03/10/private/","excerpt":"","text":"##隐私政策本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 您在同意本应用服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。 适用范围(a) 在您注册本应用帐号时,您根据本应用要求提供的个人注册信息;(b) 在您使用本应用网络服务,或访问本应用平台网页时,本应用自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据;(c) 本应用通过合法途径从商业伙伴处取得的用户个人数据。您了解并同意,以下信息不适用本隐私权政策:(a) 您在使用本应用平台提供的搜索服务时输入的关键字信息;(b) 本应用收集到的您在本应用发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情;(c) 违反法律规定或违反本应用规则行为及本应用已对您采取的措施。 信息使用(a)本应用不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本应用(含本应用关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。(b) 本应用亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何本应用平台用户如从事上述活动,一经发现,本应用有权立即终止与该用户的服务协议。(c) 为服务用户的目的,本应用可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与本应用合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)。 信息披露在如下情况下,本应用将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息:(a) 经您事先同意,向第三方披露;(b)为提供您所要求的产品和服务,而必须和第三方分享您的个人信息;(c) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露;(d) 如您出现违反中国有关法律、法规或者本应用服务协议或相关规则的情况,需要向第三方披露;(e) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷;(f) 在本应用平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,本应用有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。(g) 其它本应用根据法律、法规或者网站政策认为合适的披露。 信息存储和交换本应用收集的有关您的信息和资料将保存在本应用及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或本应用收集信息和资料所在地的境外并在境外被访问、存储和展示。 Cookie的使用(a) 在您未拒绝接受cookies的情况下,本应用会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的本应用平台服务或功能。本应用使用cookies可为您提供更加周到的个性化服务,包括推广服务。(b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的本应用网络服务或功能。(c) 通过本应用所设cookies所取得的有关信息,将适用本政策。 信息安全(a) 本应用帐号均有安全保护功能,请妥善保管您的用户名及密码信息。本应用将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。(b) 在使用本应用网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对7.本隐私政策的更改(a)如果决定更改隐私政策,我们会在本政策中、本公司网站中以及我们认为适当的位置发布这些更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会透露这些信息。(b)本公司保留随时修改本政策的权利,因此请经常查看。如对本政策作出重大更改,本公司会通过网站通知的形式告知。方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是本应用用户名及密码发生泄露,请您立即联络本应用客服,以便本应用采取相应措施。","categories":[{"name":"google","slug":"google","permalink":"http://winfan.xyz/categories/google/"}],"tags":[{"name":"app","slug":"app","permalink":"http://winfan.xyz/tags/app/"},{"name":"google","slug":"google","permalink":"http://winfan.xyz/tags/google/"}],"keywords":[{"name":"google","slug":"google","permalink":"http://winfan.xyz/categories/google/"}]},{"title":"Book One Thing","slug":"book_note_one_thing","date":"2017-10-23T12:46:25.000Z","updated":"2017-10-23T08:47:56.000Z","comments":true,"path":"2017/10/23/book_note_one_thing/","link":"","permalink":"http://winfan.xyz/2017/10/23/book_note_one_thing/","excerpt":"","text":"平等是一个谎言。平等才是最大的不平等。","categories":[{"name":"book","slug":"book","permalink":"http://winfan.xyz/categories/book/"}],"tags":[{"name":"book","slug":"book","permalink":"http://winfan.xyz/tags/book/"}],"keywords":[{"name":"book","slug":"book","permalink":"http://winfan.xyz/categories/book/"}]},{"title":"PySpider","slug":"PySpider","date":"2017-10-23T12:46:25.000Z","updated":"2017-10-23T08:41:56.000Z","comments":true,"path":"2017/10/23/PySpider/","link":"","permalink":"http://winfan.xyz/2017/10/23/PySpider/","excerpt":"","text":"PySpider官网:http://www.pyspider.cn/book/pyspider/pyspider-Quickstart-2.html Web页面说明:http://www.pyspider.cn/jiaocheng/pyspider-webui-12.html 选择元素PyQuery 使用 https://xuanwo.org/2015/10/23/pyquery-intro/ PyQuery Api:http://pyquery.readthedocs.io/en/latest/api.html 123m = '<p><span><em>Whoah!</em></span></p><p><em> there</em></p>'d = PyQuery(m)d('p').eq(1) #取第一个元素 urldecode script can use PhantomJS & selenium","categories":[{"name":"crawl","slug":"crawl","permalink":"http://winfan.xyz/categories/crawl/"}],"tags":[{"name":"python","slug":"python","permalink":"http://winfan.xyz/tags/python/"},{"name":"crawl","slug":"crawl","permalink":"http://winfan.xyz/tags/crawl/"},{"name":"pyspider","slug":"pyspider","permalink":"http://winfan.xyz/tags/pyspider/"}],"keywords":[{"name":"crawl","slug":"crawl","permalink":"http://winfan.xyz/categories/crawl/"}]},{"title":"RN Bitrise一键集成打包android/ios测试包","slug":"rn-bitrise","date":"2016-11-10T12:46:25.000Z","updated":"2016-11-10T10:45:31.000Z","comments":true,"path":"2016/11/10/rn-bitrise/","link":"","permalink":"http://winfan.xyz/2016/11/10/rn-bitrise/","excerpt":"","text":"RN Bitrise一键集成打包android/ios测试包 https://www.bitrise.io Android1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162---format_version: 1.1.0default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.gittrigger_map:- push_branch: master workflow: primary- pull_request_source_branch: master workflow: primaryworkflows: primary: steps: - [email protected]: title: Activate App SSH key inputs: - ssh_key_save_path: "$HOME/.ssh/steplib_ssh_step_id_rsa" - git-clone: {} - [email protected]: title: npm install inputs: - content: |- #!/bin/bash npm install - [email protected]: {} - [email protected]: inputs: - platform: android - entry_file: "./index.android.js" - out: android/app/src/main/assets/index.android.bundle - dev: 'false' - [email protected]: title: gradlew inputs: - content: "#!/bin/bash\\n\\ncd android \\n./gradlew assembleRelease" opts: is_expand: true - [email protected]: inputs: - apk_path: "/bitrise/src/android/app/build/outputs/apk/app-release-unsigned.apk" - keystore_url: "$KEY_PATH" - keystore_password: "$KEY_PASS" - keystore_alias: tellmewhy.keystore - private_key_password: "$KEY_PASS" - [email protected]: title: cp apk inputs: - content: |- #!/bin/bash cp $BITRISE_SIGNED_APK_PATH $BITRISE_DEPLOY_DIR/signed-app-release.apk - [email protected]: is_always_run: false envs: - opts: is_expand: true KEY_PATH: xxx - opts: is_expand: true KEY_PASS: xxx - opts: is_expand: true KEY_ALIAS: xxx 因为android 默认了release 用的是assets/index.android.bundle,所以用react-native bundle 生成到正确的位置即可,sign-apk配置上签名文件和密码,alias即可。省略了npm test 测试。做比较少修改即可一次编译成功。 IOSios 需要p12和描述文件,苹果帐号 123npm installreact-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/bundle/main.jsbundle --dev false --assets-dest ios/bundle/assetsfastlane ios beta bundle 这里打包了main.jsbundle/assets 在xcode中要用folder reference(引用后是蓝色文件+) ,要先创建bundle目录 fastlane 外国工具 直接上https://github.com/fastlane/fastlane/tree/master/gym 看它和gym 的Readme,最好本机先安装fastlane init 测试下,gym 好6,这里我们只需要用它的fastlane ios beta 即可。还可以测试截图,以后再补充。 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162# fastfilefastlane_version "1.107.0"default_platform :iosplatform :ios do before_all do # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." ENV["BITRISE_DEPLOY_DIR"] = "./build/" end desc "Runs all the tests" lane :test do scan end desc "Submit a new Beta Build to Apple TestFlight" desc "This will also make sure the profile is up to date" lane :beta do # match(type: "appstore") # more information: https://codesigning.guide gym(use_legacy_build_api: true,scheme:"goodidea",output_directory:"./build/")# Build your app - more options available #pilot sh("cp ../build/goodidea.ipa $BITRISE_DEPLOY_DIR") #sh "your_script.sh" # You can also use other beta testing services here (run `fastlane actions`) end desc "Deploy a new version to the App Store" lane :release do # match(type: "appstore") # snapshot gym # Build your app - more options available deliver(force: true) # frameit end # You can define as many lanes as you want after_all do |lane| # This block is called, only if the executed lane was successful # slack( # message: "Successfully deployed new App Update." # ) end error do |lane, exception| # slack( # message: exception.message, # success: false # ) endend# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md# fastlane reports which actions are used# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer 执行cp 时总找不到文件,原来它去了fastlane这个目录,sh “pwd && ../build/goodidea.ipa $BITRISE_DEPLOY_DIR” 最后,fastlane 只读取目录下的fastlane配置,ios 在再下一级目录,在working directory 设置 ./ios 即可。 ios10有个bug 一定要设置好sign,这个我build了5,6次终于green了,坑。 有问题留言我上传些图,没有就这样了..","categories":[{"name":"ReactNative","slug":"ReactNative","permalink":"http://winfan.xyz/categories/ReactNative/"}],"tags":[{"name":"react native","slug":"react-native","permalink":"http://winfan.xyz/tags/react-native/"},{"name":"auto","slug":"auto","permalink":"http://winfan.xyz/tags/auto/"}],"keywords":[{"name":"ReactNative","slug":"ReactNative","permalink":"http://winfan.xyz/categories/ReactNative/"}]},{"title":"30Day's react native way","slug":"30days_rn_way","date":"2016-10-19T12:46:25.000Z","updated":"2016-10-28T08:54:29.000Z","comments":true,"path":"2016/10/19/30days_rn_way/","link":"","permalink":"http://winfan.xyz/2016/10/19/30days_rn_way/","excerpt":"","text":"30Day’s react native wayA study note based on @Wei Fang‘s awesome project. github地址 Day1 Timer 布局 文字 fontWeight 状态一控制 组件分开写最后组合 小的标志图可用position 计时逻辑 Day2 Weather 布局 scrolview vector-icon swiper 一次map了各城市数据 内嵌scrollview Day3 Twitter 动画 变形及透明 动画constructor时设初值 组件style时设为属性,动作或者ComponentDidMount 时启动动画。动画有几种,我喜欢的牛读翻页效果是Flip https://github.com/kevinstumpf/react-native-flip-view 下拉刷新 scrollview–>refreshControl tab tab为了兼容android用了react-native-tab-navigator,简洁可定制,如果要可以左右切换效果可以用react-native-scrollable-tab-view。因为这里需要下拉刷新,如果直接用scrollable的tab会下拉不了。而且初始化时load完所有页面数据过大,还是简洁的用第一个较可定制。 现在层的实现都是通过用position:’absolute’,后一层叠在前一层上,试了zIndex再看下效果。 Day6 Spotify 介面实在动人 react-native-video + react-native-swiper swiper 为了全屏可触用了position:’absolute’,它本身可以设置height/width,页面的点在靠下方位置。 spotify FontAwesome Day9 TwitterUi 先实现静态布局 找出几个关键的位置点 icon的变化:以自我位置为中心点,向上负数缩小,向下正数/上移过程有因素值使icon位置同时上向下移,速度稍慢于整体图片上下移 bannerImg :bannerTop 一直为0,直到上移到-62.5,然后再上移一步,_bannerTop就要相应高度下移一步 透明度的计算:math.pow() 现在的高度/最终高度 手势:需要设置panResponder 将触摸权限交给scrollView 才有可能实现类似的上移一部分后scrollView 或者ListView 继续上移,这里不展开 (tag:todo) stick header 效果 Day10 TumblrAnimation 位移动画 设置state和执行Animate顺序有讲究,先让看到再执行动画,后面则相反,延迟一点让动画执行完再不显示 Touchable控件的子件默认是占满整个父件空间,可以参考NeverMind 现在支持zIndex写可以更方便 先用Sketch实现了布局再去写快好多– Day13 Twitter Input Ui TextInput CameraRoll.getPhotos Day 14 SwiperCard 注意细节,在拖动时可以看到下一张图 现在的tinder改变了,直接运行实例无法重现gift图效果,实现了布局 tag:todo 实现react-native-tinder-swipe-cards 这个代码不长,效果酷炫,是尝试animate的绝佳材料… Day16 Unlock with gesture 父子控件之间数据传递 实际写会遇到自己忽略的问题 Day17 不兼容android暂时跳过(tag:todo)Day18 看似复杂的坎,越过才会发现是那回事。 这个例子用到的还是最初的原理,View 随着state 的变化而更新。两个View变化之间的补间动画由LayoutAnimation帮我们去完成。 过程:触摸时获取到方块 index给它加效果阴影,每次移动更新位置,移动到其它块位置时将它在数组的位置更新LayouAnimation动画更新。触摸结束后让被触摸到的块回到它新index应该去的地方。 难点:判断触摸到的index,最后移动到哪里去了。 判断边界条件,不在范围内的index处理。 细节许多可以借鉴 Day20 Single Reminder 先想好布局分层,多层易乱 LayoutAnimation 选中完成的动作是由无到有底色,只是更换背景没有这种效果,要从无到有。 阴影的使用 Day21 MultiReminder 单页面到多页面的转变,适用于很多类似的情况,也是对状态的改变所render的页面随之变化,效果出众,代码简洁。 LayoutAnimation Day22 GoogleNow 看似简单的页面有大智慧呀 动画可以用Animated量不用LayoutAnimation(我猜的) 第一坑:动画效果是Touch->AnimateView->View->Icon/Touch->AnimateView->Icon,AnimateView放大占满屏幕,View(Icon)缩小相反倍数。 第二坑:输入框外面总包了层View,一为了阴影效果,一个是为了输入的文字在框四周有padding. Animated’s easing: Easing.elastic(1) Day23 D3 WebView直接显示本地html flexDirection改变后alignItem/justifyContent会相应切换,postion absolute是相对父组件的位置。(这两个前面例子也会遇到) img cover效果不错。 Day24 FacebookTab react-native-scrollable-tab-view 应用,点击时动画慢关闭dev tab’s opacity (two icon),the last icon will ease out when selected tabUnderline move when the srcoll value change (use Interpolate) change scrollable-tab-view example facebooktab,change color –> change opacity layout Day26 DrawableLayout 左侧菜单拖动效果 菜单在底下,主页面在上,用触摸控制主页面left。 这个是实现思路,实际应用可参考:react-native-drawer-layout Day27 IMessage Gradien 用了Linergradian…我免得加库,直接用opacity测试下,开始opacity变化好慢,不知为什么后来又正常了– 更新页面,1用state 2直接setNativeProps 3 动画? 更新随着位置的变化,除了panResonder/api返回offset,这个也可以UIManager.measure(https://github.com/facebook/react-native/issues/953) findNodeHandle直接从’react-native’ 导入了 Day 28 the last one(happy:)","categories":[{"name":"ReactNative","slug":"ReactNative","permalink":"http://winfan.xyz/categories/ReactNative/"}],"tags":[{"name":"react native","slug":"react-native","permalink":"http://winfan.xyz/tags/react-native/"},{"name":"tutorial","slug":"tutorial","permalink":"http://winfan.xyz/tags/tutorial/"}],"keywords":[{"name":"ReactNative","slug":"ReactNative","permalink":"http://winfan.xyz/categories/ReactNative/"}]},{"title":"Appstore证书","slug":"appstore_certificate","date":"2016-10-13T12:46:25.000Z","updated":"2016-10-14T09:54:23.000Z","comments":true,"path":"2016/10/13/appstore_certificate/","link":"","permalink":"http://winfan.xyz/2016/10/13/appstore_certificate/","excerpt":"","text":"Appstore certificates开发者需要 证书p12 描述文件 证书在本机生成csr然后生成即可。(dev/dis) 描述文件是本地测试机和bundleId绑定的文件。要增加测试机直接导入文件,bundleId也可以直接创建,然后直接生成对应的描述文件。 others bundleId 可以生成一份*号的方便测试(不包括充值那些功能) 证书一年期,如果过期了要重新生成证书及描述文件 需要发布的机器必须装上第一台机器导出的p12证书 not confirm? 删掉bundleId,包含它的profile会失效,删掉证书对线上或在用证书影响(待证)","categories":[],"tags":[{"name":"appstore","slug":"appstore","permalink":"http://winfan.xyz/tags/appstore/"},{"name":"publish","slug":"publish","permalink":"http://winfan.xyz/tags/publish/"},{"name":"xcode","slug":"xcode","permalink":"http://winfan.xyz/tags/xcode/"}],"keywords":[]},{"title":"nginx 初体验(Todo)","slug":"2016-09-17-nginx-look","date":"2016-09-17T12:46:25.000Z","updated":"2016-10-14T08:15:35.000Z","comments":true,"path":"2016/09/17/2016-09-17-nginx-look/","link":"","permalink":"http://winfan.xyz/2016/09/17/2016-09-17-nginx-look/","excerpt":"","text":"nginx 初Reference centos + docker 负载","categories":[{"name":"Server","slug":"Server","permalink":"http://winfan.xyz/categories/Server/"}],"tags":[{"name":"server","slug":"server","permalink":"http://winfan.xyz/tags/server/"},{"name":"tools","slug":"tools","permalink":"http://winfan.xyz/tags/tools/"},{"name":"todo","slug":"todo","permalink":"http://winfan.xyz/tags/todo/"},{"name":"env_setting","slug":"env-setting","permalink":"http://winfan.xyz/tags/env-setting/"},{"name":"nginx","slug":"nginx","permalink":"http://winfan.xyz/tags/nginx/"}],"keywords":[{"name":"Server","slug":"Server","permalink":"http://winfan.xyz/categories/Server/"}]},{"title":"Docker Node开发环境","slug":"docker-env","date":"2016-09-12T12:46:25.000Z","updated":"2016-10-14T03:27:47.000Z","comments":true,"path":"2016/09/12/docker-env/","link":"","permalink":"http://winfan.xyz/2016/09/12/docker-env/","excerpt":"","text":"Docker开发环境高质量Node.js微服务的编写和部署 被上面的文章带坑了 在时速云测试自动构建及自动上传时注册构建填的master ,创建容器时也是master分支即可 昨天构建成功最后一步buffering to disk出错估计是时速云问题,隔天就好了。 github地址 UsageDockerfile node 现在用的是6.5,直接替换为4.5.0..这些就可以 1234567891011121314151617FROM sameersbn/ubuntu:14.04.20160827MAINTAINER [email protected] \\ cd /opt && \\ wget http://nodejs.org/dist/v6.5.0/node-v6.5.0-linux-x64.tar.gz && \\ tar -xzf node-v6.5.0-linux-x64.tar.gz && \\ mv node-v6.5.0-linux-x64 node && \\ cd /usr/local/bin && \\ ln -s /opt/node/bin/* . && \\ DEBIAN_FRONTEND=noninteractive npm install -g nodemon --no-optional && \\ sudo ln -s /opt/node/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \\ rm -f /opt/node-v6.5.0-linux-x64.tar.gzWORKDIR /srcCMD ["/bin/bash"] Start12345docker build -t winfan/node-dev .docker run -i -t --rm \\ -p 3000:3000 \\ -v `pwd`:/src \\ winfan/node-dev 12#add nodemon for devnpm install -g nodemon 启动应用1nodemon app.js 一旦把镜像构建好了,我们就可以使用下面的语句运行一个容器了: 让我们来看一看docker运行命令中发生了什么. -i 会在交互模式下启动容器(对比 -d 是在分离模式下). 这就意味一旦交互会话结束,容器就会退出.-t 会分配一个pseudo-tty.–rm 会在退出时移除容器及其文件系统.-p 3000:3000 会将主机上的端口 3000 转发到容器上的端口3000.-v pwd:/src这句将会将当前的工作目录挂载到主机上(例如,我们的项目文件)容器中的 /src 里面. 我们将当前目录作为一个卷挂在,而不是使用Dockerfile中的ADD命令,那样我们在文本编辑器中做的任何修改都可以立即在容器中看到了.winfan/node-dev 是要运行的docker镜像的名称和版本 – 这跟我们用来构建docker镜像时使用的名称和版本是相同的. 由于Dockerfile指定了CMD [“/bin/bash”], 容器一启动,我们就会登录到一个bash shell环境中. Base Image [x] Ubuntu (fork sameersbn/ubuntu add node and nodemon) [ ] node-argo 官方发布 [ ] apline publish Reference 基于 Docker 开发 NodeJS 应用 高质量Node.js微服务的编写和部署","categories":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}],"tags":[{"name":"env_setting","slug":"env-setting","permalink":"http://winfan.xyz/tags/env-setting/"},{"name":"docker","slug":"docker","permalink":"http://winfan.xyz/tags/docker/"},{"name":"node","slug":"node","permalink":"http://winfan.xyz/tags/node/"}],"keywords":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}]},{"title":"docker 搭建ss","slug":"2016-09-08-docker-ss","date":"2016-09-08T12:46:25.000Z","updated":"2016-10-13T11:01:04.000Z","comments":true,"path":"2016/09/08/2016-09-08-docker-ss/","link":"","permalink":"http://winfan.xyz/2016/09/08/2016-09-08-docker-ss/","excerpt":"","text":"docker 搭建ss1234docker pull oddrationale/docker-shadowsocks#add $SSPASSWORD to ~/.bash_profiledocker run -d -p 11984:11984 oddrationale/docker-shadowsocks -s 0.0.0.0 -p 11984 -k $SSPASSWORD -m aes-256-cfb#ios 可以下载wingy,亲测有效 就是这么自然..","categories":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}],"tags":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/tags/Docker/"},{"name":"shadowsocks","slug":"shadowsocks","permalink":"http://winfan.xyz/tags/shadowsocks/"},{"name":"overseas","slug":"overseas","permalink":"http://winfan.xyz/tags/overseas/"}],"keywords":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}]},{"title":"docker中gitlab部署记录","slug":"2016-09-07-gitlab","date":"2016-09-07T12:46:25.000Z","updated":"2016-10-14T08:47:26.000Z","comments":true,"path":"2016/09/07/2016-09-07-gitlab/","link":"","permalink":"http://winfan.xyz/2016/09/07/2016-09-07-gitlab/","excerpt":"","text":"docker中gitlab部署记录https://github.com/sameersbn/docker-gitlab 引言通过Dockefile建立一个Gitlab容器的镜像。使用版本gitlab:8.11.4 硬件要求CPU 1核能满足个100用户,但响应速度可能会受到影响。 2核最多支持100个用户。 4核最多支持1,000个用户。 8核最多支持10,000个用户。 内存 如果使用512Mb内存,那么Gitlab会运行得非常缓慢,并且需要250Mb的虚拟内存。 768Mb是最低内存大小,我们並不推荐。 (521Mb虚拟机运行会报耗时过长错误) 1GB内存能支持100个用户(仓库需要占用250Mb,否则Git需要使用交换空间) 2GB是推荐的大小,能支持1,000个用户。 4GB能支持10,000个用户。 存储所需要的存储空间,很大程度上取决于Gitlab中有多少仓库需要存储。尽管如此,你应该准备2倍于实际所占大小的空间。因为Gitlab satellites会建立每个仓库的额外副本。 如果未来想灵活的增加存储空间,请考虑使用LVM,当需要的时候,可以添加更多的硬盘。 除了支持本地存储以外,还支持挂载卷:网络文件(NFS)协议。卷可以位于一个文件服务器、网络存储(NAS)、存储区域网络(SAN)、亚马逊云服务(AWS),弹性存储(EBS)。 如果你有足够的内存和较新的CPU,那么Gitlab的速度取决于硬盘的寻道速度。使用高速硬盘(7200转/分钟)或固态硬盘(SSD)将提高Gitlab的响应速度。 安装centos7wget -qO- https://get.docker.com/ | sh systemctl start docker chkconfig docker on centos6.5wget -qO- https://get.docker.com/ | sh service docker start chkconfig docker on /systemctl enable docker docker 1.8及以上推荐用docker-compose12345cd /tmpwget https://raw.githubusercontent.com/sameersbn/docker-gitlab/master/docker-compose.yml curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-composedocker-compose up docker 1.7以下手动运行12345678910111213141516171819202122232425#这里的DB信息如果更改 第三行运行gitlab 时也要相应增加对应的环境变量docker run --name gitlab-postgresql -d \\ --env 'DB_NAME=gitlabhq_production' \\ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \\ --env 'DB_EXTENSION=pg_trgm' \\ --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \\ sameersbn/postgresql:9.5-1 docker run --name gitlab-redis -d \\ --volume /srv/docker/gitlab/redis:/var/lib/redis \\ sameersbn/redis:latest ###配置上基本上按照github上的,必须设置的是DB,SECRET,OPT那三个key,这里还增加了host,smtp_user,smtp_pass的设置,默认用的gmail,设置gmail时需要先在gamil那里开启允许应用连接,改变了本地存储目录为/datadocker run --name gitlab -d \\ --link gitlab-postgresql:postgresql --link gitlab-redis:redisio \\ --publish 10022:22 --publish 10080:80 \\ --env 'GITLAB_HOST=106.75.192.252' \\ --env '[email protected]' \\ --env 'SMTP_PASS=mygailpasswd' \\ --env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \\ --env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \\ --env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \\ --env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \\ --volume /srv/docker/gitlab/gitlab:/home/git/data \\ sameersbn/gitlab:8.11.4 问题解决端口冲突需要在宿主机开放端口,本例中的是10080及10022,宿主机8080端口也不可以被占用,否则也会报超时处理错误,virtualBox模拟的机器也只要检查自己的端口,不要检查virtualBox的宿主机… 12345678#开放端口/sbin/iptables -I INPUT -p tcp --dport 10022 -j ACCEPT/sbin/iptables -I INPUT -p tcp --dport 10080 -j ACCEPT#然后保存:/etc/init.d/iptables save#查看打开的端口:/etc/init.d/iptables status 邮件邮件设置gmail要开通了imap及接受未知位置应用登录](http://www.google.com/accounts/DisplayUnlockCaptcha),运行gitlab时要设置smtp_user及smtp_passwd即可。其它问题到可以用root用户在设置那里看一下production_log,gitlab那里看一下issue。 Docker速度过慢香港主机快到不可想像,一开始用公司网络不能活,简直浪费时间,国内机器可以用加速器 ,1.8以下手动把那地址加上去也可以用,总算可以pull到。 备份及回滚测试docker化备份比较简单,只需要将/srv/docker/gitlab 这个目录的内容复制到新机器或者新目录,保持原样配置volume更改为新地址即可原样运行成功。gitlab上也有每天备份方便回滚。 Reference 在Docker中部署GitLab https://index.docker.io/u/sameersbn/gitlab/ https://docs.docker.com/compose/install/","categories":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}],"tags":[{"name":"git","slug":"git","permalink":"http://winfan.xyz/tags/git/"},{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/tags/Docker/"},{"name":"gitlab","slug":"gitlab","permalink":"http://winfan.xyz/tags/gitlab/"},{"name":"team","slug":"team","permalink":"http://winfan.xyz/tags/team/"}],"keywords":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}]},{"title":"Docker安装","slug":"2016-09-07-docker","date":"2016-09-07T12:46:25.000Z","updated":"2016-10-14T09:56:53.000Z","comments":true,"path":"2016/09/07/2016-09-07-docker/","link":"","permalink":"http://winfan.xyz/2016/09/07/2016-09-07-docker/","excerpt":"","text":"Docker安装环境centos 7.2 64位 / docker 1.8 安装1234567891011121314151617181920212223#!/bin/bashyum -y updatecurl -sSL https://get.docker.com/ | sh yum install -y docker-selinux#启动systemctl start docker.service#测试安装是否成功docker run hello-world#开机自启动systemctl enable docker.service#开放端口示例firewall-cmd --state#看开机自运行程序systemctl list-unit-files | grep firewall#...虚拟机关掉...systemctl disable firewalld#ipip ad | less#查看现运行占内存进程ps aux | grep docker Docker速度过慢香港主机快到不可想像,一开始用公司网络不能活,简直浪费时间,国内机器可以用加速器 ,1.8以下手动把那地址加上去也可以用,总算可以pull到。 常用命令docker 用镜像image运行起来的容器叫container,要删掉image需要先删掉container,要删掉container当然要先停了container,一般都是docker stop container && docker rm container 1234567891011121314docker ps -adocker search hellodocker stop/restart/start/pause/unpausedocker -hdocker commit containerdocker push #需要docker.io 即docker hub帐号#常见删掉image需要docker stop container && docker rm container && docker rmi image#批量删除none的image镜像,docker ps -a | grep "Exited" | awk '{print $1}' | xargs docker stop docker ps -a | grep "Exited" | awk '{print $1}' | xargs docker rm docker images | grep none | awk '{print $3}' |xargs docker rmi Docker 神器docker-compose安装12curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose 使用12#常用命令与docker兼容docker-compose -h 未涉及 swarm/多线程/.. Reference CentOS 7上安装Docker 1.8 - DockOne.io CentOS7中关闭firewall,并使用iptables管理防火墙centos widuu/chinese_docker docker常用命令 [翻译]Docker Compose工具快速入门 docker强制批量删除none的image镜像 Docker入门教程","categories":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}],"tags":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/tags/Docker/"},{"name":"env_setting","slug":"env-setting","permalink":"http://winfan.xyz/tags/env-setting/"}],"keywords":[{"name":"Docker","slug":"Docker","permalink":"http://winfan.xyz/categories/Docker/"}]},{"title":"准爸爸必修课","slug":"2016-06-01-book-baby","date":"2016-06-01T12:46:25.000Z","updated":"2016-10-14T08:45:44.000Z","comments":true,"path":"2016/06/01/2016-06-01-book-baby/","link":"","permalink":"http://winfan.xyz/2016/06/01/2016-06-01-book-baby/","excerpt":"","text":"分娩分三产程:从正规宫缩临产到宫口开全的过程 第一产程: 时间较长不同人不一样,忍痛,尽量找空隙休息,储存体力 正规宫缩 阵痛间隔和持续时间一定,如间隔5-6分钟,持续半分钟,痛程序逐渐加剧,间隔时间逐渐缩短,持续时间逐渐变长。 会越来越痛 第二产程: 忍痛同时付出努力 最多2-3小时 产妇找到自己最舒服的姿势 感觉一阵宫缩来袭时,配合强烈的宫缩用力屏气,力气用在肛门口,就是便秘解大便的感觉。 屏气,一定不能把气吐出来,而且一口气屏得越久越好。一阵宫红缩持续将近一分钟,没有人生孩子的时候能一口气屏那么久,所以中间要换气。要知道,宫缩是很珍贵的,不配合宫缩的用力就是浪费力气,所以,这就要求宫缩来的时候要不惜力气,中间换气的时候要短,马上深吸气继续向下用力,充分利用宫缩的这半分钟。等到一阵宫缩过去了,身体就要彻底放松,好好调整一下呼吸,等待下一波。所以,第二产程用力的时候,应该是间隔有节奏地向下屏气,如果感觉有大便解出来了,就说明力气差不多用对地方了。是的,就是那种大便解出来的感觉。 产力的三部分组成: 1 子宫的收缩力 (最重要的,即宫缩) 2 腹肌给的压力 (更多是被动力) 3 盆底肌给的旋转力 (只要有便秘时解大便的力气,生孩子也就够了)产力不能靠锻炼,但是可以积蓄,即第一产程的尽量休息。 剖腹产(具体情况定,听医生意见) 如何更好地陪产 (陪伴) 进行充分沟通,做好分娩期心理调整,播歌,打气。 陪产解决两个问题:一个是前面说的疼痛,另一个是对于未知的恐惧。对未知,对于未来失去掌控的恐惧感,需要心理上的安慰与支持。目的就是尽可能地缓解疼痛以及克服恐惧。 不要做的:1 要陪伴鼓励理性信任医生 一起度过产后特殊时期","categories":[{"name":"Other","slug":"Other","permalink":"http://winfan.xyz/categories/Other/"}],"tags":[{"name":"booknote","slug":"booknote","permalink":"http://winfan.xyz/tags/booknote/"},{"name":"baby","slug":"baby","permalink":"http://winfan.xyz/tags/baby/"},{"name":"life","slug":"life","permalink":"http://winfan.xyz/tags/life/"},{"name":"other","slug":"other","permalink":"http://winfan.xyz/tags/other/"}],"keywords":[{"name":"Other","slug":"Other","permalink":"http://winfan.xyz/categories/Other/"}]},{"title":"qemu","slug":"2016-05-24-qemu","date":"2016-05-24T12:46:25.000Z","updated":"2016-10-14T08:15:00.000Z","comments":true,"path":"2016/05/24/2016-05-24-qemu/","link":"","permalink":"http://winfan.xyz/2016/05/24/2016-05-24-qemu/","excerpt":"","text":"some times we want to write about how we success ,but here just describe how pain I had suffered. Reference: Jeremy http://m.77169.net/HTML/226392.html 安装依赖,下载qemu12345sudo apt-get install -y libglib2.0-dev uml-utilities bridge-utils dh-autoreconf vim gitwget http://wiki.qemu-project.org/download/qemu-2.6.0.tar.bz2 wget https://downloads.openwrt.org/snapshots/trunk/malta/generic/openwrt-malta-le-vmlinux-initramfs.elf 1 添加网桥创建后 sudo /sbin/ifup tap0 && sudo /sbin/ifup br0 启动 2 创建ubuntu与qemu虚拟之间的共享盘 3 binwalk 解压固件12345//binwalkgit clone https://github.com/devttys0/binwalksudo python setup.py installsudo apt-get install python-lzmabinwalk -e NW774.bin 解压完有以下内容,将squashfs-root 复制到上一步的共享盘中即/tmp/share,squashfs-root 里面有bin这些文件,新复制内容到里面需要重新启动qemu 4 通过telnet 连接qemu虚拟器telnet localhost 6666 5 chroot 到从NW774.bin解压的文件 可惜最后我有ubuntu 32位 1604/ubuntu 64位 1404/ qemu 2.6 都会出现如上图错误,实验失败–执行过的shell 如下方便重现 1234567891011121314151617181920212223242526272829303132333435 #!/bin/bashwget http://wiki.qemu-project.org/download/qemu-2.6.0.tar.bz2wget https://downloads.openwrt.org/snapshots/trunk/malta/generic/openwrt-malta-le-vmlinux-initramfs.elfapt-cache search glib2sudo apt-get install -y libglib2.0-dev uml-utilities bridge-utils dh-autoreconf vim git squashfs-tools p7zip-full./configure --target-list=mipsel-softmmu --prefix=/usr/localexport LANG=en_US:zh_CN.UTF-8export LC_ALL=Csudo make && make installcd ~dd if=/dev/zero of=Desktop/share.img bs=1M count=350mkfs.ext4 Desktop/share.imgmkdir /tmp/sharesudo mount -o loop Desktop/share.img /tmp/share//binwalkgit clone https://github.com/devttys0/binwalksudo python setup.py installsudo apt-get install python-lzmabinwalk -e ...binsudo qemu-system-mipsel -kernel openwrt-malta-le-vmlinux-initramfs.elf -M malta -net nic,vlan=0,macaddr=00:33:33:33:33:33 -net tap,vlan=0,ifname=tap0,script=no -serial tcp::6666,server -nographic -drive file=Desktop/share.imgtelnet localhost 6666 ##Enter ##dmesg | grep "350 MiB"mount -t ext4 /dev/sda /overlaychroot /overlay/squashfs-root/ mac 截图shift + command +4 截并保存在桌面shift + ctrl + command +4 截并不保存成文件 mac 共享给ubuntu输入帐号密码 ceye.iohttp://ceye.io/introduce x382au.ceye.io 以这个域名结尾的都可以统计到次数,ip,user-agent.域名或者request 12#curl http://httprequest.test.x382au.ceye.io/hello/\\?p\\=httptest#nslookup http://httprequest.test.x382au.ceye.io","categories":[{"name":"Hack","slug":"Hack","permalink":"http://winfan.xyz/categories/Hack/"}],"tags":[{"name":"zpt","slug":"zpt","permalink":"http://winfan.xyz/tags/zpt/"},{"name":"hack","slug":"hack","permalink":"http://winfan.xyz/tags/hack/"},{"name":"qemu","slug":"qemu","permalink":"http://winfan.xyz/tags/qemu/"},{"name":"tool","slug":"tool","permalink":"http://winfan.xyz/tags/tool/"}],"keywords":[{"name":"Hack","slug":"Hack","permalink":"http://winfan.xyz/categories/Hack/"}]},{"title":"ZPT日常作战","slug":"2016-05-20-zptnote","date":"2016-05-20T12:46:25.000Z","updated":"2016-10-14T08:46:29.000Z","comments":true,"path":"2016/05/20/2016-05-20-zptnote/","link":"","permalink":"http://winfan.xyz/2016/05/20/2016-05-20-zptnote/","excerpt":"","text":"#ZPT日常作战 初战优秀记录 ZoomEye+Seebug二进制恶魔果实的神奇力量初探与思考 小心你背后的眼睛 poc其实没那么难写 还有几篇忘记收藏了,找回来再补 HistoryCouchDB (restful api ..的越来越多,写你的方便,安全由我们守护)docker port:2375 remote api1.3.3c proFTPd磊科路由jeremie at seebug ImageMagic(big bang)Write Up: Remote Command Execute in Wordpress 4.5.1","categories":[{"name":"Hack","slug":"Hack","permalink":"http://winfan.xyz/categories/Hack/"}],"tags":[{"name":"zpt","slug":"zpt","permalink":"http://winfan.xyz/tags/zpt/"},{"name":"hack","slug":"hack","permalink":"http://winfan.xyz/tags/hack/"},{"name":"note","slug":"note","permalink":"http://winfan.xyz/tags/note/"},{"name":"todo","slug":"todo","permalink":"http://winfan.xyz/tags/todo/"}],"keywords":[{"name":"Hack","slug":"Hack","permalink":"http://winfan.xyz/categories/Hack/"}]},{"title":"Githug","slug":"2016-01-12-git-githug","date":"2016-01-12T12:46:25.000Z","updated":"2016-10-14T09:13:43.000Z","comments":true,"path":"2016/01/12/2016-01-12-git-githug/","link":"","permalink":"http://winfan.xyz/2016/01/12/2016-01-12-git-githug/","excerpt":"","text":"reset,rebasereset 恢复到某一状态,保留修改待提交或者全部舍弃前面的修改rebase 以某个版本为基础重新在它的基础上重新提交修改内容/以某个版本为基础交互修改log,sqush,reorder reset,chekcoutreset 以仓库内容覆盖checkout 以Staging area 内容覆盖 HEAD HEAD^ HEAD^1git push origin mastergit push origin test_branch 其它实践再补充 Level 1: init$ git init Level 2: config$ git config --global user.name "winfan" $ git config --global user.email "[email protected]" Level 3: add$ git add README Level 4: commit$ git commit -m "add R.. commit" Level 5: clone$ git clone https://github.com/Gazler/cloneme Level 6: clone_to_folder$ git clone https://github.com/Gazler/cloneme my_cloned_repo Level 7: ignore$ vim .gitignore # Add line "*.swp" Level 8: include$ vim .gitignore # Add line "*.a !lib.a" Level 9: status$ git status Level 10: number_of_files_committed$ git status Level 11: rmgit rm deleteme.rb Level 12: rm_cached //start remove from staging area$ git rm --cached deleteme.rb Level 13: stash //git stash -h$ git stash Level 14: rename$ git mv oldfile.txt newfile.txt Level 15: restructuremkdir src $ git mv *.html src Level 16: log$ git log Level 17: tag$ git tag new_tag Level 18: push_tags //TODO$ git push --tags origin master Level 19: commit_amend // add,change the latest commit message$ git add forgotten_file.rb $ git commit --amend Level 20: commit_in_future //my answer is change the computer time…$ git commit -m "future" --date="Sun Jan 3 13:40:06 2017 +0800" Level 21: reset //reset checkout12345git reset 恢复到某个版本状态,--soft用仓库的内容覆盖staging area 和working directory,如果staging area和working directory有你自己的内容,你有新的修改没提交或者提交了没commit,就保留你的。--hard就不用想这么多,直接全部内容仓库的。git checkout 则是使用 staging area 的中的版本覆盖 working directory。$ git reset HEAD $ git add to_commit_first.rb Level 22: reset_soft //start –soft 参数将上一次的修改放入 staging area –mixed 参数将上一次的修改放入 working directory –hard 参数直接将上一次的修改抛弃 $ git reset --soft HEAD^ Level 23: checkout_file$ git checkout config.rb Level 24: remote$ git remote -v Level 25: remote_url$ git remote -v Level 26: pull //start$ git pull origin master Level 27: remote_add$ git remote add origin https://github.com/githug/githug Level 28: push //TODO start$ git rebase origin/master master $ git push origin master Level 29: diff$ git diff HEAD Level 30: blame$ git blame config.rb Level 35: branch_at //TODO start$git branch test_branch HEAD^1 Level 36: delete_branch$ git branch -d delete_me Level 37: push_branch //$ git push origin test_branch Level 38: merge$ git merge feature master Level 39: fetch //== git fetch && git merge$ git fetch origin Level 40: rebase在使用此命令的时候,需要非常注意的是,不要 rebase 哪些已经推送到公共库的更新,因为此操作是重新应用修改,所以公共库的更新可能已经被其他协作者所同步,如果再次 rebase 这些修改,将可能zh $ git rebase master feature Level 41: repack$ git repack -a -d Level 42: cherry-pick$ git checkout master $ git cherry-pick new-feature~2 Level 43: grep$ git grep TODO Level 44: rename_commit$ git rebase -i logindex Level 45: squash$ git rebase -i log_index Level 46: merge_squash$ git merge --squash long-feature-branch $ git add . $ git commit -m "Merge branch long-feature-branch" Level 47: reorder$ git rebase -i log_index Level 48: bisect12345$ git bisect start$ git bisect bad$ git bisect good [first commit]$ git bisect run ruby prog.rb 5 # 二分查找直至找出 bad 提交 $ git bisect start master f608824888b83 Level 49: stage_lines$ git add -p feature.rb # 编辑提交指定行 or $ git add -e feature.rb Level 50: find_old_branch$ git reflog $ git checkout solve_world_hunger Level 51: revert$ git revert HEAD^1 Level 52: restore$ git reflog $ git rebase --log_index or git checkout? Level 53: conflict$ git merge mybranch resolve conflicts and finish the merge $ git add . $ git commit -m "Fix merge" Level 54: submodule$ git submodule add https://github.com/jackmaney/githug-include-me githug-include-merge Level 55: contribute:) Githug is designed to give you a practical way of learning git. It has a series of levels, each req ref:http://www.jianshu.com/p/482b32716bbehttp://blog.csdn.net/trochiluses/article/details/8996431","categories":[{"name":"Tools","slug":"Tools","permalink":"http://winfan.xyz/categories/Tools/"}],"tags":[{"name":"tools","slug":"tools","permalink":"http://winfan.xyz/tags/tools/"},{"name":"git","slug":"git","permalink":"http://winfan.xyz/tags/git/"},{"name":"fun","slug":"fun","permalink":"http://winfan.xyz/tags/fun/"}],"keywords":[{"name":"Tools","slug":"Tools","permalink":"http://winfan.xyz/categories/Tools/"}]},{"title":"Python Unitest","slug":"2015-11-03-unitest","date":"2015-11-03T12:46:25.000Z","updated":"2016-10-14T08:24:37.000Z","comments":true,"path":"2015/11/03/2015-11-03-unitest/","link":"","permalink":"http://winfan.xyz/2015/11/03/2015-11-03-unitest/","excerpt":"","text":"https://docs.python.org/2/library/unittest.html http://blog.csdn.net/hackerain/article/details/24095117 unitest– not finish yet,more practise TestCase,TestLoader source test case unittest.TestCase test suite unitest.TestSuite() test runner unitest.TextTestRunner() runner 可以执行suite/case case要实现runtest或者实例时传入方法名称. setUp init tearDown clean (每执行一个case执行一次,tearDown同理) 以’test_’开头 12suite = unittest.TestLoader().loadTestsFromTestCase(TestStringMethods)unittest.TextTestRunner(verbosity=2).run(suite) 例子12345678910111213141516171819202122232425262728293031#!/usr/bin/env pythonimport unittestclass TestStringMethods(unittest.TestCase): def setUp(self): '''ini test word = FOO''' print 'test init' self.word = 'FOO' def tearDown(self): '''clear test word = FOO''' print 'test clear' self.word = None def test_upper(self): self.assertEqual('foo'.upper(),self.word) def test_isupper(self): self.assertTrue('FOO'.isupper()) self.assertFalse('Foo'.isupper()) def test_split(self): s='hello world' self.assertEqual(s.split(),['hello','world']) with self.assertRaises(TypeError): s.split(2)if __name__ == '__main__': #unittest.main() #suite = unittest.TestLoader().loadTestsFromTestCase(TestStringMethods) testCase = TestStringMethods('test_split') unittest.TextTestRunner(verbosity=3).run(testCase) 123456789101112➜ helloworld git:(master) ✗ python -m unittest discover test inittest clear.test inittest clear.test inittest clear.----------------------------------------------------------------------Ran 3 tests in 0.000sOK 执行方式1 如代码里的写ruuner 执行case or suite,再运行test脚本 2 command line 1234python -m unittest test_module1 test_module2python -m unittest test_module.TestClasspython -m unittest test_module.TestClass.test_method python -m unittest -h 3 discover(new command line,有这个根据不想写执行代码–) 123python -m unittest discover -h python -m unittest discover -s project_directory -p \"*_test.py\"python -m unittest discover project_directory \"*_test.py\" 4 skipping test and expected failures","categories":[],"tags":[{"name":"python","slug":"python","permalink":"http://winfan.xyz/tags/python/"},{"name":"unitest","slug":"unitest","permalink":"http://winfan.xyz/tags/unitest/"}],"keywords":[]},{"title":"Supervisor","slug":"2015-11-02-supervisor","date":"2015-11-02T12:46:25.000Z","updated":"2016-10-14T08:29:52.000Z","comments":true,"path":"2015/11/02/2015-11-02-supervisor/","link":"","permalink":"http://winfan.xyz/2015/11/02/2015-11-02-supervisor/","excerpt":"","text":"http://supervisord.org/running.html The simple way to use suepervisorInstall1pip install supervisor create default config1echo_supervisord_conf > supervisord.conf supervisord(start)1supervisord -n -c supervisor.conf supervisorctl (controller)1supervisorctl status/stop all/shutdown add program123456[program:foo]command=/bin/cat ; the program (relative uses PATH, can take args)[program:goagent]command=/usr/local/bin/python proxy.py ; the program (relative uses PATH, can take args)directory=/Users/winfan/opt/goagent/local ; directory to cwd to before exec (def no cwd) 1supervisorctl reload","categories":[{"name":"Tools","slug":"Tools","permalink":"http://winfan.xyz/categories/Tools/"}],"tags":[{"name":"unix","slug":"unix","permalink":"http://winfan.xyz/tags/unix/"},{"name":"server","slug":"server","permalink":"http://winfan.xyz/tags/server/"},{"name":"tools","slug":"tools","permalink":"http://winfan.xyz/tags/tools/"},{"name":"supervisor","slug":"supervisor","permalink":"http://winfan.xyz/tags/supervisor/"}],"keywords":[{"name":"Tools","slug":"Tools","permalink":"http://winfan.xyz/categories/Tools/"}]},{"title":"Python核心编程","slug":"2015-10-22-python-core-mulThread18","date":"2015-10-22T12:46:25.000Z","updated":"2016-10-14T08:44:24.000Z","comments":true,"path":"2015/10/22/2015-10-22-python-core-mulThread18/","link":"","permalink":"http://winfan.xyz/2015/10/22/2015-10-22-python-core-mulThread18/","excerpt":"","text":"##《Python核心编程2》 第14章 执行环境 可调用对象 –> 加()可执行 函数(内建BIF build_in_function,用户定义udf,lambda) 方法 (BIM,UDM) 类 (调用创建了实例) 类的实例 实现了call的类的实例 代码对象 代码块/udf.func_code/方法(函数对象(代码对象)) callable,compile(eval求值,single单一,exec语句组) eval/exec (执行代码对象) 123456>>> exec \"\"\"... x = 0... print 'x is currently:',x... \"\"\"x is currently: 0>>> f = open('xcount.py') input 等同于 eval(raw_input(prompt=’’)) 返回python对象,raw_input返回string 12345678>>> aString = raw_input('Enter a list')Enter a list[123,'xyz',46.7]>>> aString\"[123,'xyz',46.7]\">>> aList = input('Enter a list:')Enter a list:[123,'xyz',46.7]>>> aList[123, 'xyz', 46.7] 函数属性 1234567891011121314151617181920212223242526272829#!/usr/bin/env pythondef foo(): return Truedef bar(): 'bar() dose not do much' return Truefoo.__doc__ = 'foo() does not do much'foo.tester='''if foo(): print 'PASSED'else: print 'FAILED''''for eachAttr in dir(): obj = eval(eachAttr) if isinstance(obj,type(foo)): if hasattr(obj,'__doc__'): print '\\nFunction \"%s\" has a doc string:\\n\\t%s' % (eachAttr,obj.__doc__) if hasattr(obj,'tester'): print 'Function \"%s\" has a tester... executing' % eachAttr exec obj.tester else: print 'Function \"%s\" has no tester... skiping' % eachAttr else: print '\"%s\" is not a function ' % eachAttr 执行其它Python程序 import /execfile() 123f = open(filename,'r')exec ff.close() 执行其它非Python程序—>subprogress subprogress.call([‘ls’,’-al’]) Popen 123456789101112>>> from subprocess import PIPE,Popen>>> f = Popen(['ls','-al'],stdout=PIPE).stdout>>> for each in f:... print each... total 96drwxr-xr-x@ 19 winfan staff 646 Oct 12 11:15 .drwxr-xr-x 7 winfan staff 238 Aug 28 10:28 ..-rw-r--r-- 1 winfan staff 380 Aug 19 10:06 .project 123456#stdin stdout have PIPE will return an object,else None# p= Popen(['python','test1.py'],stdin=PIPE,stdout=PIPE)#p.write('test')#p.communicate()[0] cause in&out/it's PIPE so only communicate can flush to stout#如果是ls -al 这种命令,则直接运行完毕并关闭pip 已无法再操作in,out#Both subprocess and os.popen* only allow input and output one time, and the output to be read only when the process terminates. 根据unix 规范 要编写从stdin 获取输入再输出到stdout 直接借助sys.stdin就可以 12345#test1.py#!/usr/bin/env pythonimport sysline = sys.stdin.readlines()print 'test',line 12 practise git:(master) ✗ ls | python test1.pytest ['11_11.py\\n', '11_12.py\\n'] 结束执行 主动 sys.exit(status=0) 需要退出前清理设置 sys.exitfunc() 第15章 正则表达式 compile 多则预编译 group 匹配到的 groups 子组 group(1)也是子组 123456789>>> f = re.match('(a)(b)','ab')>>> f.group()'ab'>>> f.group(1)'a'>>> f.group(2)'b'>>> f.groups()('a', 'b')ab' match,search,findallmatch & search 返回找到的第一个match 要从头开始匹配 中间的还要捕获search 可中间含有两者都返回一个匹配对象 findall 和search功能一样,返回列表一般应该是想用search ,需要全部就findall split 正则分割 raw strings 原始字符串 r’’ 第18章 多线程编程 进程和线程:一个进程可以有多个线程 thread + lock threading join 自处理锁(守护进程,setDaemon为false) threading 创建一个Thread的实例,可以传给它一个函数,可调用的类对象,或者派生出一个子类,实现它的run方法。书中建议第三种。 Queue 共享线程间数据 put get 可以block 12345678910111213141516171819202122#!/usr/bin/env python#myThread.pyimport threadingfrom time import ctimeclass MyThread(threading.Thread): def __init__(self,func,args,name=''): threading.Thread.__init__(self) self.name = name self.func = func self.args = args self.res = '' def getResult(self): return self.res def run(self): print 'starting ',self.name,'at:',ctime() self.res = self.func(*self.args) print 'finished ',self.name,'at:',ctime() 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#!/usr/bin/env python#mtsleep.pyimport threadingfrom time import sleep,ctimefrom myThread import MyThreadloops=[4,2]class ThreadFunc(object): def __init__(self,func,args,name=''): self.name = name self.func = func self.args = args def __call__(self): self.func(*self.args)def loop(nloop,nsec): print 'start loop',nloop,'at:',ctime() sleep(nsec) print 'loop',nloop,'done at:',ctime()def fib(x): sleep(0.005) if x < 2: return 1 return (fib(x-2) + fib(x-1))def fac(x): sleep(0.1) if x<2:return 1 return (x* fac(x-1))def sum(x): sleep(0.1) if x<2:return 1 return (x+sum(x-1))def main(): funcs = [fib,fac,sum] nfuncs = range(len(funcs)) n=12 print '*** SINGLE THREAD',ctime() for i in nfuncs: print 'starting',funcs[i].__name__, 'at:',ctime() print funcs[i](n) print funcs[i].__name__,'finished at:',ctime() print '\\n*** MULTIPLE THREADS' threads = [] for i in nfuncs: t = MyThread(funcs[i],(n,),funcs[i].__name__) threads.append(t) for i in nfuncs: threads[i].start() for i in nfuncs: threads[i].join() #print threads[i].getResult() for i in nfuncs: print threads[i].getResult() print 'all Done!'if __name__ == '__main__': main()","categories":[],"tags":[{"name":"booknote","slug":"booknote","permalink":"http://winfan.xyz/tags/booknote/"},{"name":"python","slug":"python","permalink":"http://winfan.xyz/tags/python/"}],"keywords":[]},{"title":"Hello World","slug":"hello-world","date":"2013-07-13T12:46:25.000Z","updated":"2016-10-10T02:58:55.000Z","comments":true,"path":"2013/07/13/hello-world/","link":"","permalink":"http://winfan.xyz/2013/07/13/hello-world/","excerpt":"","text":"Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. Quick StartCreate a new post1$ hexo new \"My New Post\" More info: Writing Run server1$ hexo server More info: Server Generate static files1$ hexo generate More info: Generating Deploy to remote sites1$ hexo deploy More info: Deployment","categories":[],"tags":[{"name":"hello","slug":"hello","permalink":"http://winfan.xyz/tags/hello/"},{"name":"what","slug":"what","permalink":"http://winfan.xyz/tags/what/"}],"keywords":[]}]}