Skip to content

Instantly share code, notes, and snippets.

View sandyxu's full-sized avatar
Working from office

Sandy Xu sandyxu

Working from office
  • Shanghai, China
View GitHub Profile
@sandyxu
sandyxu / safe_continue_redirect.rb
Last active December 21, 2015 11:59
防止浏览器存在url跳转漏洞被利用钓鱼
# 来自wooyun的白帽子安全 http://www.wooyun.org/bugs/subtype-65/page/1
# 通过params[:continue] 的安全url进行跳转
def safe_continue_redirect(continue = params[:continue])
if continue
redirect_to safe_continue_url(continue)
else
redirect_to(root_path)
end
end
@sandyxu
sandyxu / why-new-issue-github
Created August 20, 2013 01:37
Why star from 'New Issue' on GitHub
在GitHub里 Issue是我们的任务管理,代码跟踪,意见反馈的根源。通过对 Issue, 添加 Milestones进行进度管理;
及时调整Issue的状态,便于了解进度;添加Label,有助于区分Issue的性质。每次代码的提交最好都有对应的Issue,
便于浏览任务对应的代码,直接对每行代码评论,反馈。尤其是对程序员永远的沟通能力和思维定式,减少了沟通中的上下文。
这样一套下了,会减少很多沟通成本。
建议每个提交代码的人先在GihHub 添加或找到一个 Issue,充分利用这套系统带给我们的便利。
提交代码,从 New Issue 开始!!!
@sandyxu
sandyxu / omniauth.rb
Last active December 21, 2015 04:08
OmniAuth should set config.on_failure
# 在OmniAuth时触发异常被web server捕获直接返回500页面,如果想捕获并处理要做如下设置
# config/initializers/omniauth.rb
OmniAuth.config.on_failure = AuthenticationsController.action(:failure)
# log 输出
OmniAuth.config.logger = Rails.logger

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt