ITeye博客

夜鸣猪的Ruby On Rails 空间

夜鸣猪 · 共 628 篇文章

Ruby Jquery 地图,地理信息相关资源

Railscast Geocorder Geocorder 官网 Geokit Jquery solution https://code.google.com/p/jquery-ui-map/

2013-03-22 20:32 · Ruby On Rails · 评论(0)

load migrate file and load

Dir[rails.root.join('db','migrate','*.rb')].each{|file|require file} Dir[file.dirname(__file__) + '/../lib/*.rb'].each do |file| require File.basename(file, File.extname(file)) end rails console >> require "db/migrate/20090408054532_add_foos.rb" >> AddFoos.up script/runner 'require("db/migrate/2009…

2013-03-22 05:52 · Ruby On Rails · 评论(0)

Brew update problem

MBA:~ fortin$ brew update error: Your local changes to the following files would be overwritten by merge: expect.rb libiconv.rb ncurses.rb openldap.rb openssh.rb perl.rb tcl.rb tk.rb Please, commit your changes or stash them before you can merge. Aborting Error: Failed to update tap: homebrew/dupes…

2013-03-22 05:48 · Ruby On Rails · 评论(0)

UItableview cell 背景

Here is the most efficient way I have come across to solve this problem, use the willDisplayCell delegate method (this takes care of the white color for the text label background as well when using cell.textLabel.text and/or cell.detailTextLabel.text): - (void)tableView:(UITableView *)tableView wil…

2013-03-20 11:01 · 评论(1)

iOS UItableviewcell 点按钮修改cell颜色

@interface MyTableViewController : UITableViewController { UIColor *cellColor; } -(IBAction)click:(id)sender; @implementation MyTableViewController -(IBAction)click:(id)sender{ cellColor = [uicolor redcolor]; [self.tableview reloaddata]; } - (UITableViewCell *)tableView:(UITableView *)tableView cel…

2013-03-20 10:58 · 评论(0)

change the author of a commit in git?

删除项目里的大文件 git filter-branch --index-filter \ 'find -name ''*.mp3'' -or -name ''*.ogg'' | xargs -d''\n'' rm -f' #Suppose you want to remove a file (containing confidential information or copyright violation) from all commits: git filter-branch --tree-filter 'rm filename' HEAD git filter-branch --com…

2013-03-19 20:34 · git · 评论(0)

Jquery sort table number

So here is what the column is sorted as: 4,666 141,666 293 341,666 346 461,676 This should be sorted as 293 346 4,666 141,666 341,666 461,676 $(document).ready(function() { $.tablesorter.addParser({ id: 'fancyNumber', is:function(s){return false;}, format: function(s) {return s.replace(/[\,\.]/g,''…

2013-03-19 01:01 · javascript Jquery sort plugin 插件 · Ruby On Rails · 评论(0)

update_all

Article.limit(2).update_all ["updated_at = :time", time: Time.now], ["created_at > :time", time: time.now - 12.days] Article.limit(2).update_all ["updated_at = ?", Time.now] list = File.read(Rails.root.join('doc','free_stories.txt')).split("\r\n").map{|x|x[/[\w|-]+/]} Dir.getwd http://apidock.com/r…

2013-03-13 02:09 · Ruby On Rails · 评论(0)

接着上面的母子表单

Creating a new Rails project $ mkdir family # create rvm gemset $ echo "rvm use --create ruby-1.9.2@family"> family/.rvmrc $ cd family # install rails $ gem install rails # create new rails project $ rails new.# version control $ git init $ git add . $ git commit -am "new rails project" Create two …

2013-03-12 11:45 · Ruby On Rails · 评论(0)

有关嵌套资源的使用,母子表单

class Post < ActiveRecord::Base validates_presence_of :name, :title validates_length_of :title, :minimum => 5 has_many :comments has_many :tags accepts_nested_attributes_for :tags, :allow_destroy => :true , :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } end <% @post.tags.build if @po…

2013-03-12 11:43 · Ruby On Rails · 评论(0)

set vim as git commit default editor

git config --global core.editor "vim" echo "export EDITOR='vim'" >> ~/.profile export EDITOR='vim' export VISUAL=vim # ~/.bashrc export GIT_EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim -g ' When I issue git commit then I get a macvim editor but on the command line I see this message $ git co…

2013-03-11 20:43 · ruby · git · 评论(0)

objective c Basic

Passing Data Forward Passing data forward to a view controller from another view controller. You would use this method if you wanted to pass an object/value from one view controller to another view controller that you may be pushing on to a navigation stack. For this example we will have ViewContro…

2013-03-09 10:02 · ios · 评论(0)

jquery each and find

$(document).ready(function () { var selectedTable = $('table').eq('9'); $(selectedTable).css('border','10px solid green'); $(selectedTable).find('tr td').each(function(i) { $(this).css('border','10px solid blue'); }); }); <!DOCTYPE html> <html> <head> <style> ul { font-size:18px; margin:0; } span {…

2013-03-06 04:14 · javascript Jquery ext prototype · 评论(0)

find and filter out permission denied

find . 2>/dev/null > files_and_folders find . 2>&1 | grep -v 'permission denied' > files_and_folders find . 2>/dev/null > some_file find . 2>&1 | grep -v 'Permission denied' > some_file How can I exclude all “permission denied”-messages from “find .”?

2013-03-06 04:04 · 评论(0)

javascript at IE of trim problem

var ID = document.getElementByID('rep_id').value.trim(); Message: Object doesn't support this property or method Line: 604 Char: 2 Code: 0 URI: http://test.localhost/test.js if(typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, '');…

2013-03-06 04:02 · Ruby On Rails · 评论(0)