Skip to content

Instantly share code, notes, and snippets.

View lanrion's full-sized avatar
🎯
Focusing

lanrion lanrion

🎯
Focusing
  • guǎng zhōu
View GitHub Profile
@lanrion
lanrion / gist:9320326
Last active August 29, 2015 13:56
fork 了某个开源项目,发了PR后,需要更新master的代码的做法
fork 了某个开源项目,发了PR后,需要更新master的代码的做法:
git remote add --track master upstream git://github.com/upstreamname/projectname.git
git fetch upstream
git merge upstream/master
注意:upstream 是定义名称。
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
@lanrion
lanrion / gist:9801783
Last active August 29, 2015 13:57
ubuntu 快捷命令收集

Alt+F2 : 快速打开搜索栏。

Alt+Tab : 不同应用之间的切换,选中某一个,再Alt+~ 即可放大当前栏目。

下载了Sublime Text 之后,我们需要建立一个快捷命令

sudo mv Sublime\ Text\ 2 /opt/
sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime

参考 http://my.oschina.net/yexingkong/blog/140726

@lanrion
lanrion / gist:9866781
Created March 30, 2014 03:03
安装java ubuntu
@lanrion
lanrion / gist:9866811
Created March 30, 2014 03:04
修改mysql root 用户密码
mysql>use mysql
mysql>update user set password=password("new_pass") where user="root";
mysql>flush privileges;
@lanrion
lanrion / gist:9867179
Created March 30, 2014 03:45
手把手教你在ubuntu上安装apache和mysql和php
@lanrion
lanrion / gist:9967961
Last active August 29, 2015 13:58
multi_xml适配器模式的实现

摘自 multi_xml 适配器模式的实现,加载某个gem正常,则相应的使用某个解释器来解释XML

# Get the current parser class.
def parser
  return @parser if defined?(@parser)
  self.parser = self.default_parser
  @parser
end
@lanrion
lanrion / gist:10015146
Last active August 29, 2015 13:58
git submodules

1, 有些项目里包含另外一个子git项目(Submodule),那么按照常用的 git clone是不可能顺带把子git项目一起接下来的,所以可以考虑:

git clone --recursive git@xxxx.git
git clone --recursive git@github.com:cloudfoundry/cf-release.git

详细使用文章:

http://ju.outofmemory.cn/entry/44286

@lanrion
lanrion / gist:10241916
Created April 9, 2014 08:34
linux scp命令使用

scp是有Security的文件copy,基于ssh登录。操作起来比较方便,比如要把当前一个文件copy到远程另外一台主机上,可以如下命令。

scp  / home / daisy / full . tar . gz root@ 172.19 . 2.75 : / home / root

然后会提示你输入另外那台172.19.2.75主机的root用户的登录密码,接着就开始copy了。

如果想反过来操作,把文件从远程主机copy到当前系统,也很简单。

alias 和 alias_method 区别 ruby

1

class User

  def full_name