refer to: http://nginx.com/resources/admin-guide/caching/  这个例子是可以拿来就用的: # 注意这里是顶层。 http { # 这里定义了缓存的格式 log_format my_format '$remote_addr - $remote_user [$time_local] ' '"$reques...
Nginx基础(nginxbeginnersguide)
master-workers process nginx包含一个master process, 多个 worker process.  master process 用来读取配置文件, 控制 worker 的。 worker就是用来处理 request的。 nginx 由于使用了 event-based model, 所以处理request速度很快。 日志 一般都放在 /var/l...
干货 优化rails查询
如果没有经过优化,  position = company.positions 会产生: 13:50:15 DEBUG: MarketModule Load (0.1ms) SELECT `market_modules`.* FROM `market_modules` WHERE `market_modules`.`market_id` = 1 13:50:15...
接口的访问基本机制:服务器端的认证(webinterfacebasics:serversideauthentication)
refer to:  http://nginx.org/en/docs/http/ngx_http_secure_link_module.html http://www.rackspace.com/blog/add-the-content-md5-http-header-to-nginx/ 对于接口的认证,在服务器端的两个地方可以做: 1. nginx , 2. backend...
Rails中使用cancan做权限控制
refer to:  https://github.com/ryanb/cancan cancan 是一个非常著名的权限框架.它把复杂的权限控制,变得非常简单. (它使用了dsl.   can :manange,  cannot :read )
Todo写个rails入门教程(railstutorial)
现有的网上教程都不太好啊。。。
Titanium入门3alloy:惯例优于配置(conventionoverconfiguration)
alloy 框架跟Rails特别像:  app Contains the models, views, controllers and assets of the application. All work should be done here. See folder descriptions below. app/alloy.jmk ...
常见的代码质量问题 汇总版
写代码的原则: 简单,易于沟通。 建议看的书: <<代码之美>>, 以及 <> # 不要把有意义的变量名 命名成 foo, bar, 例如下面的,改成叫 guide 或者叫 guide_property 比较合适。 foo = Ti.App.Properties.getString("guide") # 对于coffeescript , 最后一行...
一个例子,ruby解析html页面.(nokogiri,httparty,ruby)
有些网页需要我们获取信息 require 'httparty' require 'nokogiri' url ='https://github.com/rdoc/rdoc/issues/190' response = HTTParty.get url puts response.body doc = Nokogiri::HTML response.body doc.css('.js-i...
Ruby的eval,class_eval,instance_eval
refer to:  https://4loc.wordpress.com/2009/05/29/eval-module_eval-and-instance_eval eval: 上来就运行代码.  例如: eval(" a = 1; puts a+1 ") #=> 2 b = 3 eval(" puts b") # => 3 @forty = 40 ...
期待着javascript的根本性变革(javascriptisstrange)
今早看到一篇文章:  javascript简直就是编程语言界的一朵奇葩 我很同意。  这个 10天写出来的语言,需要改变的地方比较多:  5 - '2' = 3 5 + '2' = 52 3.40 + 2.80 # 6.1999999999999993.4 + 2.8 # 6.199999999999999 编程中,也无法像ruby那样有着优雅...
如何打印ruby的动态代码
refer to:  http://stackoverflow.com/questions/1675053/printing-the-source-code-of-a-ruby-block ruby最强的地方(之一)在于 meta programming. 那么了解到动态的代码的具体内容就很重要 默认ruby不提供  proc.inspect 这样的方法.还好 社区的战...
Eclispe系列(radrails,titanium,adt,aptana..)的快捷键shortcuts
快速打开文件: ctrl + shift + r ( vim : ctrl + t)快速打开之前的文件: ctrl + shift + e , ctrl + e ( vim: ctrl + e )快速切换窗口 : ctrl + f7查找: ctrl + h代码格式化: ctrl + shift + f跳到上一次的位置: alt + left跳到前一次的位置: ...
软件方法论:抛弃boilerplatecode.(没它不行,但是它又跟核心功能无关)
想读一个文件: read "some_file.txt" # 不懂编程, 和 编程了 10年+ 的人。 # 有一定编程基础/经验的人: BufferedReader br = new BufferedReader(new FileReader("file.txt")); try { StringBuilder sb = new Strin...
[教程]web+rails入门2(大师原创)ruby10分钟入门
ruby 的基础: 声明个class:  class Apple @color = '' def color return @color end def color= (new_color) @color = new_color end # 以上代码可以简写为: attr_accessible :color @@name = 'ap...
使用rspec的几个注意事项(tipsusingrspecinrails4)
1. 务必使用  $ rails generate rspec:install, 会生成 一个 spec_helper 和一个 rails_helper, 不要改动他们 2. 务必修改 rails帮你生成好的  rspec文件。  把第一行的 spec_helper 改成 rails_helper # require 'spec_helper' requi...
Rails4中使用cache_action,cache_page
TODO: 尚未测试。。。不知道是否需要配置 nginx .... 如果是那样的话速度估计会很快。 refer to: https://github.com/rails/actionpack-page_caching cache_action一直是接口开发的神器, 但是在rails4 中用法略有不同。 1. in your Gemfile:   gem 'actionp...
Rails中使用devise
refer to:  https://github.com/plataformatec/devise 总论:  下面仅仅是个大概的思路,要多看文档.  2018.4.18 , devise将近2W个关注了. # Gemfile gem 'devise' # 运行下面三个命令 $ bundle exec rails generate devise:insta...
使table可以排序(sorttableinrails)
TODO: 把它做成一个gem   1. 要有这段js: this.make_table_sortable = function(table_css_selector) { var base_index, entity_class, this_table; this_table = $(table_css_selector); base_i...
Ruby中的日期操作(datetimeinruby)
2010年就因为这个耗费了一点时间。现在记下来。 strftime , strptime是关键。 下面的代码打印了两个时间之间的日期: require 'date' from = DateTime.strptime('2015-05-23', '%Y-%m-%d') to = DateTime.strptime('2015-06-03', '%Y-%m-%d') (from..to).ea...