ITeye博客

夜鸣猪的Ruby On Rails 空间

夜鸣猪 · 共 628 篇文章

brew unable to unlink old 'README.md' (Permission denied)

rvm install 2.0.0 met problem about brew brew unable to unlink old 'README.md' (Permission denied) solve problem by: sudo chmod 777 /usr/local cd /usr/local git remote add git://github.com/mxcl/homebrew.git git reset --hard git clean -f -d git pull origin master brew update sudo chmod 775 /usr/local

2013-02-27 23:50 · Ruby On Rails · Ruby 1.9 · 评论(0)

Rails Helper

http://guides.rubyonrails.org/form_helpers.html http://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper Use view help at Controller helper :foo # => requires 'foo_helper' and includes FooHelper helper 'resources/foo' # => requires 'resources/foo_helper' and i…

2013-02-26 02:45 · Ruby On Rails · 评论(0)

Rails integrate with Google analytics Api

https://github.com/chrisle/gattica https://github.com/robmckinnon/rugalytics https://www.ruby-toolbox.com/categories/Web_Analytics Google api Doc https://developers.google.com/analytics/devguides/reporting/core/v3/ # Include the gem require 'gattica' # Login ga = Gattica.new({ :email => 'email@gmai…

2013-02-21 22:57 · Ruby On Rails · 评论(0)

How to stub Rspec

@page = double(:page) %w(most_popular_content lead primary_tab_data recent_companies_data show_coroflot? coroflot).map do |method| @page.stub!( method.to_sym ) end @page.stub(:channel_name).and_return('technology') view.stub(:admin?) @channel_name = 'technology' (Dir["#{rails.root}/app/views/shared…

2013-02-17 04:34 · Ruby On Rails · Rspec · 评论(0)

Ack Regular expression

ack uses Perl regular expressions, and those allow lookahead assertions: ^(?!.*bar).*foo.*$ will match a line that contains foo but doesn't contain bar. I'm not familiar with the usage of ack, but something like this should work: ack '^(?!.*bar).*foo.*$' myfile

2013-02-15 00:04 · Ruby On Rails · 评论(0)

test controller at console

#If method is POST method then app.post'controller/action?parameter1=value1&parameter2=value2' #[ here parameters will be as per your applicability ] #else if it is GET method then app.get'controller/action' foo = ActionController::Base::ApplicationController.new foo.some_method app.myresource_path…

2013-02-15 00:03 · Ruby On Rails · 评论(0)

git submodule

# get the submodule initially git submodule add ssh://bla submodule_dir git submodule init #git submodule update # time passes, submodule upstream is updated # and you now want to update # change to the submodule directory cd submodule_dir # checkout desired branch git checkout master # update git …

2013-02-14 23:54 · git · 评论(0)

Package up all your .gem files in vendor/cache

gem 'my_private_gem', :path => "vendor/gems/my_private_gem-VERSION" gem list | awk '{print $1}' | xargs gem unpack --target vendor/gems bundle install --deployment. This will install the gems, in their unpacked state, in vendor/bundle. Package up all your .gem files in vendor/cache $ bundle package…

2013-02-14 23:51 · Ruby On Rails · git · 评论(0)

command line tools for linux

du -sh ls . for i in G M K; do du -ah | grep $i | sort -nr -k 1; done | head -n 11 dir | gvim - #output to vim #the - option tells vim to open stdin dir | gvim - #inside vim :r !<cmd> :r !dir df -k . Show size of current directory in du -sh `ls .` du -h | tail -n 1 du -h | grep -v '/' | awk '{print…

2013-02-14 23:49 · Linux · 评论(0)

Removing untracked files from your git working copy

If you want to also remove directories, run git clean -f -d . If you just want to remove ignored files, run git clean -f -X . If you want to remove ignored as well as non-ignored files, run git clean -f -x .

2013-02-12 06:10 · ruby · git · 评论(0)

git push and git pull the different of the path

reset remote branch git fetch origin git reset --hard origin/master #git fetch uses: refs/heads/<head>:refs/heads/<branch> #git push uses: HEAD:refs/heads/<head> remote config [remote "<name>"] url = <url> pushurl = <pushurl> push = <refspec> fetch = <refspec>

2013-02-02 07:20 · Ruby On Rails · 评论(0)

search Deleted or modifiied code through git

git log -S<string> path/to/file git log -SFoo -- path_containing_change git log -SFoo -- path_containing_change --since=2009.1.1 --until=2010.1.1 To search for commit content (i.e., actual lines of source, as opposed to commit messages and the like), what you need to do is: git grep <regexp> $(git …

2013-02-01 08:01 · 评论(0)

jQuery Ajax calls in Rails 3 getting 401 Unauthorized Request

Problem: Sign in Sign out Sign in (successful 201. However prints WARNING: Can't verify CSRF token authenticity in server logs) Subsequent ajax request fails 401 unauthorised Refresh the website (at this point, CSRF in the page header changes to something else) I can sign in, it works, until I try …

2013-02-01 07:58 · Ruby On Rails · 评论(0)

Searching Haml and SASS with ack

Reference update only thing is about the format and there are set and add. If, like me, you've recently discovered the wonderful speed of the ack search tool, you may be frustrated to find that it ignores some of your source code. Files that you know should be appearing in your search results just …

2013-01-31 07:52 · Ruby On Rails · 评论(0)

ubuntu 12.10 proxy install package apt-get

#/.bashrc export http_proxy=http://username:password@proxy_server:proxy_port/ #/etc/apt/apt.conf.d/30proxy Acquire::http::Proxy "http://username:password@proxy_server:proxy_port/"; sudo apt-get update

2013-01-31 06:47 · Linux · 评论(0)