ITeye博客

2013 年文章归档

共 57 篇文章

brew service restart

brew services restart memcached

2013-07-06 22:56 · Ruby On Rails

git如何合并 多个commit

需要先搞明白rebase 然后,进这个界面 pick b76d157 b pick a931ac7 c # Rebase df23917..a931ac7 onto df23917 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = li…

2013-07-02 20:42 · Ruby On Rails · git

rvm create gemset

rvm ruby-1.9.3-p429 do rvm gemset create union

2013-07-01 09:00 · Ruby On Rails · git

关于devise结合github通过omniauth登录

最近写了个github帐户登录Demo: https://github.com/yankforce/devise_omniauth_github 演示项目地址: http://devise-github.herokuapp.com BASIC版本,只是github omniauth,可以参考这个 https://github.com/bay6/omniauth-github-example demo: http://github-ominiauth.herokuapp.com 主要遇到问题: No route matches “/users/sign_out” devise rails 3 …

2013-06-24 04:47 · Ruby On Rails

在ubuntu中.profile 和.bashrc的加载区别

总之,profile不只是bash,在启动加载 bashrc是bash在,起bash session加载 .bashrc is for Bash only, while .profile is used by other shells as well. Another important difference is that .profile is used at the time when you log in, be it on a terminal, or into your desktop. So settings in there will apply always when yo…

2013-06-01 21:38 · Linux

ubuntu 13.04 ruby 安装依赖

sudo aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev libqt4-dev libpq-dev build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev …

2013-06-01 20:59

console for sinatra

git://github.com/sickill/racksh.git 也是用来做同样的事。 只是可以模拟http请求 # make GET request $rack.get uri, params, env # make POST request $rack.post uri, params, env # make PUT request $rack.put uri, params, env # make DELETE request $rack.delete uri, params, env 写sinatra的时候想找类似 rails console 就用 $ irb -r ./my_…

2013-05-24 21:19 · Sinatra

git revert merge commit

0ce2ca0b35f59af267241cf4d40d16a3e13ba6f3 df1acf5f54426d30f12c6b4558c3dd922297aae3 e19b912404ffd3c153ccac3072dbf22396896d2a #要revert的commit是merge git revert -m 2 0ce2ca0b35f59af267241cf4d40d16a3e13ba6f3 如何在commit里,search代码 git log -p | grep <pattern> git grep <regexp> $(git rev-list --all) #Search a…

2013-05-07 08:10 · git

cdata 和 xml xmlParseEntityRef: no name 错误

Problem: An XML parser returns the error “xmlParseEntityRef: no name” Cause: There is a stray ‘&’ (ampersand character) somewhere in the XML text eg. some text & some more text Solution: Solution 1: Remove the ampersand. Solution 2: Encode the ampersand (that is replace the ‘&’ character with ‘&’ )…

2013-05-04 00:24 · Ruby On Rails

一目了然 rails html xml encode decode

1.9.2p320 :001 > require 'htmlentities' 1.9.2p320 :002 > c = HTMLEntities.new #=> #<HTMLEntities:0x007fef0a5b0468 @flavor="xhtml1"> 1.9.2p320 :003 > c.decode "&gt;" #=> ">" 1.9.2p320 :004 > require 'cgi' # => false 1.9.2p320 :005 > CGI.unescapeHTML "&quot;" # => "\"" 1.9.2p320 :006 > helper.send :r…

2013-05-03 23:37 · Ruby On Rails

使用scope 链接多个where条件

scope :by_category, (lambda do |category_id| where(category_id: category_id) unless category_id.nil? end) scope :by_district, (lambda do |district_id| where(district_id: district_id) unless district_id.nil? end) #if district 是nil就会返回全部 Client.by_category(category).by_district(district) class User s…

2013-05-02 09:17 · Ruby On Rails

在rspec里使用 route path

Rspec.configure do |config| config.include Rails.application.routes.url_helpers ... end

2013-05-01 20:09 · Ruby On Rails

postgresql install and configure for ubuntu

ABSTRACT PostgreSQL is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation DBMS systems. This blog entry documents the installation process of the PostgreSQL database on Ubuntu Linux. sudo apt-get ins…

2013-04-25 08:13 · Postgresql

Destroying a Postgres DB on Heroku

heroku pg:reset DATABASE

2013-04-24 10:58 · RubyOnRails

关于Jquery的plugin使用

// jQuery, the fn property is just an alias to the prototype property. //The jQuery identifier (or $) is just a constructor function, and all instances created with it, inherit from the constructor's prototype. //A simple constructor function: function Test() { this.a = 'a'; } Test.prototype.b = 'b…

2013-04-14 10:30 · jquery

select_tag default value & options

#If you are using select_tag without any other helper, then you can do it in html: select_tag "whatever", "<option>VISA</option><option selected=\"selected\">MasterCard</option>" #Or with options_for_select: select_tag "whatever", options_for_select([ "visa", "mastercard" ], "MasterCard") #Or with …

2013-04-10 21:40 · Ruby On Rails

Jquery array remove

Array.prototype.remove = function(el){ return this.splice(this.indexOf(el),1); } var arr = [1,2,3,4,5]; arr.remove(4); console.log(arr);//[1,2,3,5] var array = [1,2,3,4,5]; array.splice(2,1); console.log(array);//[1,2,4,5] y.splice( $.inArray(removeItem, y), 1 ); $(window).load(function () { // run…

2013-04-10 21:38 · javascript Jquery ext prototype · Ruby On Rails

jquery read table

$('#mytable tr').each(function() { var customerId = $(this).find("td").eq(2).html(); }); var items=[], options=[]; //Iterate all td's in second column $('#tableId>tbody>tr>td:nth-child(2)').each( function(){ //add item to array items.push( $(this).text() ); }); //restrict array to unique items var …

2013-04-10 20:54

ruby readline的两种写法

f = File.read('public/file.csv').read lines = f.each_line.map{|x|x} lines = File.readlines('public/file.csv')

2013-04-09 10:21 · Ruby On Rails · Postgresql

关于encoding utf-8

一 gem解决方案 https://github.com/m-ryan/magic_encoding 二,rake task 解决方案 desc "Manage the encoding header of Ruby files" task :check_encoding_headers => :environment do files = Array.new ["*.rb", "*.rake"].each do |extension| files.concat(Dir[ file.join(dir.getwd.split(/\\/), "**", extension) ]) end fil…

2013-04-04 20:55 · Ruby On Rails