Time of Update: 2014-07-08
標籤:rubyIn Ruby language, the return statement in the Ruby functions are interesting, Let‘s explore them as below:def concatenate(name_one=nil, name_two="") return name_one + name_twoendname = concatenate "wuhan",
Time of Update: 2014-07-10
標籤:http 使用 strong os 問題 for https://ruby-china.org/wiki/install_ruby_guide如何快速正確的安裝 Ruby, Rails 運行環境對於新入門的開發人員,如何安裝 Ruby, Ruby Gems 和 Rails
Time of Update: 2014-07-28
標籤:style blog color for 問題 代碼 div new 在ruby中寫頂層函數的時候,總會有一個問題,self是誰,這些方法是誰的,是什麼方法。如下:1 p self2 3 p self.class4 5
Time of Update: 2014-07-19
標籤:style blog http color 使用 strong self,自己,在ruby中表示當前對象或預設對象。程式執行的任一時刻,有且僅有一個self。 1.誰成為self,在什麼位置成為self?要知道哪個對象是self,就必須知道當前的上下文。上下文主要有頂層上下文,類
Time of Update: 2014-07-16
標籤:style blog http color 使用 os 維特比演算法可以解決隱馬爾科夫模型的最可能狀態序列問題。wikipedia上關於維特比演算法,提供了一個python的例子,原文地址如下http://zh.wikipedia.org/wiki/%E7%BB%B4%E7%89%B9%E
Time of Update: 2018-12-08
在上次的內容裡,我們建立了訂單的Model,和表示頁面,這次繼續編寫CHECKOUT的處理。 1. 在checkout.rhtml的頁面上,有一個CHECKOUT按鈕,上次還沒有給它編寫處理代碼,現在在store_controller中添加save_order方法,代碼如下:def save_order@cart = find_cart@order = Order.new(params[:order])@order.line_items <<@cart.itemsif @
Time of Update: 2018-12-08
在上次的內容裡,我們編寫了CHECKOUT的處理。這次我們將顯示購物車和訂單放在一個頁面上表示,這樣使用者在下訂單的時候就可以很方便地看到自己的購物情況。 1. 修改checkout.rhtml檔案,只要添加一句代碼:<%= error_messages_for("order") %><%= render_component(:action => "display_cart") %> ――這句 <%=
Time of Update: 2018-12-07
首先,在ruby1.8中類變數是所有子類和父類共用的,可以看下面的代碼: class IntelligentLife @@home_planet = nil def self.home_planet @@home_planet end def self.home_planet=(x) @@home_planet = x end #... end class Terran
Time of Update: 2018-12-08
Page 3 概述¨ 解釋執行:Python,Ruby,互動性很好;¨ 編譯執行:Pascal, C,速度較快。n 本地執行,如C,C++;n 虛擬機器執行,如Java, C#。 ¨ 動態語言,如JavaScript,Ruby;¨ 靜態語言,如C++,Java。 語言¨ 文法關鍵字¨ 語義¨ 語用 松本行弘(Matz) 1993Ruby [`ru:bi]
Time of Update: 2018-12-08
#scanweb.rb #用法ruby scanweb.rb www.jb51.net 將當前結果儲存在c:\1.txt require 'net/http' filename= File.new('c:\1.txt',"w+") if $*[0]==nil puts "hehe,沒有輸入網址" else h = Net::HTTP.new($*[0], 80) resp, data = h.get('/index.html', nil) if resp.message == "OK"
Time of Update: 2018-12-08
實體的行為取決於其類,但很多時候我們知道一個特定的實體需要特定的行為.在很多語言裡,我們必須陷入另外再定義一個類的麻煩裡,即使它只是用來接著實體化一次.在Ruby裡,我們可以賦予任何對象屬於其自身的方法. ruby> class SingletonTest | def size | print "25\n" | end | end nil ruby> test1 = SingletonTest.new
Time of Update: 2018-12-08
首先,你得檢測Ruby是否已經安裝了.在shell的提示符處(這裡表示為"%",所以不要敲入%),敲入 % ruby -v (-v 告訴解譯器列印出Ruby的版本),然後敲斷行符號.如果安裝了Ruby,你會看見類似如下的資訊: % ruby -v ruby 1.6.6 (2001-12-26) [i586-linux] 如果Ruby未安裝,你可以讓管理員安裝它,或者可以自己做,Ruby是一個沒有安裝或使用限制的自由軟體.
Time of Update: 2018-12-05
1、Ruby-China網站原始碼包: https://github.com/huacnlee/ruby-china $ cd ~/workspace$ git clone https://github.com/huacnlee/ruby-china.git2、如果想要省心一點,請千萬不要嘗試在WINDOWS下安裝。昨晚上花了30分鐘嘗試WINDOWS下安裝,還安裝了git的WINDOWS用戶端,各種報錯,解決了幾個,後來太晚了,睡覺作罷。3、今天使用UBUNTU LINUX 11.10來安裝。
Time of Update: 2018-12-06
Block,lambda,Proc要好好理解下,在Ruby中很重要。Block塊就是一個匿名函數,被調用的方法調用,在調用的方法裡面通過field調用。Block主要用於迭代。Ruby代碼 : arr = [1,2,3,4,5]arr.each{|item| puts item}Proc也是一個代碼塊,相當於過程吧Ruby代碼 :a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}a_proc.call(9, 1, 2, 3) #=> [9,
Time of Update: 2018-12-07
第3章Ruby的資料類型數字:Fixnum超出範圍後,自動轉換為Bignum。Numeric是所有數字類型的基類,Float和Integer類是Numeric的子類,Fixnum和Bignum都是Integer的子類型。整型可以是任意長度,在一定範圍內通過在一個ASCII字元或者一個逸出字元前面加一個問號得到它的數字值。字串:Ruby的字串是簡單的8位位元組序列,可以用#{運算式}來把任何的Ruby運算式的值插入到字串中,如果那個運算式是全域變數、類變數或者執行個體變數,就可以省略大括弧。可以使
Time of Update: 2018-12-07
由於當前的ruby並不支援unicode, 所以中文相關的處理在ruby中一直比較模糊,基本上是各自嘗試的路子, 我也列出一些協助自己整理思路utf8和unicode的關係utf其實是(Unicode Translation Format), 也就是unicode在傳輸時候的編碼, 有utf8和utf16等多種編碼, 其實uf8是一個對中文字很不友好的編碼, 為什麼呢,因為在utf8中, 一個中文是佔用3個位元組,而一個英文ascii字元卻只佔用1個位元組, 這樣一方面使得中文體積膨脹較厲害,
Time of Update: 2018-12-07
在bigbold上看到Get the currently running method name in Ruby程式碼片段:Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
• First and foremost, run your scripts with warnings enabled (the -w command-line option).• If you happen to forget a “,” in an argument list—especially to print—you can produce some very odd error messages.• A parse error at the last line of the
Time of Update: 2018-12-07
Ubuntu 安裝,開發包$ sudo apt-get install wget vim build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf automake libtool imagemagick libpcre3-dev步驟1 - 安裝 RVMRVM
Time of Update: 2014-07-03
想邊自己寫ruby代碼,邊部署隨時可以到處查看,heroku網域名稱又不友好,速度在國內又慢,於是乎想起來capistrano,於是學起 ...capistrano 一點入門認知https://www.evernote.com/shard/s6/sh/72a2b7c8-d531-4efc-9e16-ac82af2a92b7/e54fca8a9e7014ad87c79e7a7a5538c4capistrano