月歸檔:四月 2007

開始支持男同性戀

最近在百度貼吧上經常看到有男人發求找同性伴侶的貼子。我一直對這個很反感。這反感來自好幾個原因
1.這樣的貼子到處都是。幾乎不管哪個分類下都可看到。這算廣告貼。即使發貼人對伴侶的要求多麼強烈,也無論他尋找的是同性還是異性,都不應該做發垃圾廣告這種不道德的行為。
2.這些“同性戀“者到處發貼,好像不是在找戀人,而是在找可以發生一夜情(一夜性)的
同性性伴侶。他們的行為給我同性性愛是一種可以隨便發生的性關係,我甚至懷疑他們經常隨便亂倫。
3.雖然我看過A片中兩個女性發生同性行為,但沒有,也不想看兩個男性發生性行為,甚至帶有傳統申美觀的我去想象那樣的場景都會感到無比的嘔心。

但今天我卻突然改變了想法。原因是大街上看到的很帥的女生帶着另一個女生。這是經常看到的場景,但今天好像我第一次去思考這個問題!李宇春!新時代到來了!如果我不時地遇到這麼帥的女生,這麼不帥的我不但不能追她,而且她還帶走了另一個女生!(帶走一個是樂觀估計,像李宇春不知道能帶走多少!),這樣我不但要同眾多的男生競爭本來有限的資源,現在還多了很帥的女生成為新的競爭對手!

在面對這個危難時我突然想起了百度上的那些男同性戀貼,猶如在黑暗中看到了幾點燈火!多一個男同性戀不就少於二個競爭對手嗎?於是我想大聲地呼籲:“你們去搞吧,我也開始支持你們了!!!“

發表在 某時雨集 | 一條評論

殺死那個人

戰國春秋,夕陽,大漠。
兩個武士一前一後地走着。前者中年,帶刀,後者帶劍,二十齣頭。前者越走越慢,後者窮追不捨。
“為什麼?”中年回頭向青年無奈地大叫。
“我 要 殺 你”青年用一種很平靜的口氣回答,沒有停下腳步。
“為什麼?”
青年沒有回答。
“為什麼!!!!???"中年看着不斷向自己走來的青年發瘋似的大喊。

青年還是沒有回答。這時中年已經在前面不遠,“拔 刀 吧“
中年搖了搖頭,發出一陣苦笑,繼續帶着疲憊的身軀前走。
“拔 刀 吧“青年平靜地重複了一遍。
中年還是沒有理會。但隨着一絲詭異的笑容,他臉上露出了殺氣,然後繼續慢慢前走,腳步輕了許多。
青年見中年不理會,停下了腳步,取出水壺,仰面喝水。
就在這時,飛刀,和中年的大刀前後緊隨而來。。。
夕陽下只見一身影閃動了幾下。。。
青年的臉上多了一道口子,而他的左手的劍穿過中年的身體,滴着鮮紅的血。。。
“這不是魯國的劍法!”中年不解。
“不 是”青年還是那樣的平靜,像什麼事都沒有發生一樣。
“你是哪人?”中年突然也平靜了。
“廣 東“
”你是從哪知道我的?“
”網 上“
”哦!“中年大悟,“是博客。。。我明白了。看來我的確不應該上傳那張照片!”
“是的 我見到那張帶淚的臉的第一刻就註定了你的死亡“
“為了這個,你追了我幾千里路?“
”是的 幾千里路和2000多年“
“就為了一個小女孩?”中年發出一陣冷笑。
“不 是為了我自己“,青年一邊慢慢地從中年身上拔出他的劍,一邊回答道,“為了在你那張照片前顯得如此無助和平庸的自己 “
“所以你要殺我?”
“是 的“,青年臉上還是沒有任何錶情。
“就算在自己的夢中?”
青年張口,卻沒能說出什麼。中年躺下後閉目了。
青年從中年身上扯下一塊布,一邊擦着劍一邊說出了含在嘴裡的話,“是的,就算在自己的夢中”。第一次,他的語氣顯得有點低顫。
擦完劍,青年起身向遠方走去。
夕陽下他的影子越來越長,直到化成鬧鐘的指針。

發表在 某時雨集, 蓋世武功 | 留下評論

Question-Driven Learning – the learning skill for information age

Question-Driven Learning(QDL) is an effective learning approach. It means learning by solving questions.

Learning was often taken before questions
At school, or university, learning often is done before the questions is given. At school, Questions(mainly included in the  homework) is given after students have the lesson. And, students attend the school, learn knowledge for years, and after they have graduated, they take jobs. This means they meet practical problems (questions) after the learning.

What is the problem with traditional learn method?
1. The knowledge or skills that are learned before you need may never have chance to be used.  Some may be out of range, (for instance — if you learned Computer Science before you become a English teacher), or some may be outdated (if you learned a Computer Skill before you get a computer related job, four years later).
2. The knowledge information have been growing very fast, especially in the last decades, with the help of computers and other information technologies. Information are exploding. There are just to much to learn before you meet real problem, when you don’t know what you really need.
3. If the question come from real life, not from text books or school teachers, you understand the question in a more realistic way, and as the question/problem either stop you from doing some thing, or by solving it you will get rewarded, you will pay more attention to it and try harder to solve it.
4. The skills and knowledge that are learned by doing, will be longer lasting in your memory.

How to do it?
When problems come, ask, search (google) the learn the related knowledge, come up ways to solve the problem. If the problem doesn’t be solved, ask, search and learn more, or skip this problem, deal with another (hope it’s an easier one), after time when by, more problems will be solved. And, always review the questions and solutions, think what you have learned from them, and if necessary, note them down.

And, Still, you need to Learn before the question!
Why? Because Question-Driven Learning has its weakness.
1. If you want to do something, and you meet tons of problems, and you have hundreds of questions want to ask, you should not ask  these questions, instead,  take a book about the subject,  perfectly  a basic, fundamental one, leaving the details behind, and understand this thing you want to do by reading/scanning the book. After you have a specific question about the subject, then you are ready to ask or search.
2. If you don’t know what to do, what to ask or what to search. Reading books or taking an essential course about the subject will be necessary.

發表在 成敗幾何 | 標籤為 | 留下評論

REST and ActiveResource

REST (Representational State Transfer)
REST is An Architectural Style
It uses the following standards:

    *  HTTP
    * URL
    * XML/HTML/GIF/JPEG/etc (Resource Representations)
    * text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
The Whole WWW is a REST system!

RESTful

RESTafarians

HTTP methods: PUT, GET, POST and DELETE.
database operations: CREATE, READ, UPDATE, DELETE (CRUD)

URI -> Resource
REST Is a Conversation
The verbs of the REST conversation are the aforementioned request methods, while the nouns are URIs, A URI should be only a pointer to a resource.
e.g.
GET "/books/1"
DELETE "/books/1"

URI,URL and URN
A Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource.

A Uniform Resource Locator (URL) is a URI that, in addition to identifying a resource, provides means of acting upon or obtaining a representation of the resource by describing its primary access mechanism or network "location".

Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace. (e.g. urn:isbn:0-395-36341-1)

Web service, a software system designed to support interoperable Machine to Machine interaction over a network.

Remote Procedure Call (RPC)

REST Is Design
A clear approach to controller-design that’ll reduce complexity for the implementer and result in an application that behaves as a much better citizen on the general web.

REST gives us a framework for simple but extensible application design.

ActiveResource
RailsConf Keynote: David Heinemeier Hansson Video the World of Resources
online video: http://www.scribemedia.org/2006/07/09/dhh/
download address: http://downloads.scribemedia.net/rails2006/01_dh_hansson.m4v
(the slides http://www.loudthinking.com/lt-files/worldofresources.pdf)

David Heinemeier Hansson’s blog on ActiveResources
http://www.loudthinking.com/arc/000593.html

script/generate scaffold_resource

http://www.xfront.com/REST-Web-Services.html
http://en.wikipedia.org/wiki/Representational_State_Transfer
http://en.wikipedia.org/wiki/Uniform_Resource_Identifier
http://en.wikipedia.org/wiki/Web_service
Rails Cookbook

發表在 Ruby on Rails, 信息處理 | 留下評論

Web Services on Rails note

By Kevin Marshall

The Basics
APIs(application programming interface)

three architectures:
Representational State Transfer (REST)
Simple Object Access Protocol (SOAP)
Extensible Markup Language Remote Procedural(XML-RPC)
(SOAP grew out of XML-RPC)

SOAP
Web service signatures are really just data types that the service either expects or returns.
WSDL(Web Service Description Language)
a WSDL file is an XML document that defines the interface to a SOAP service.

REST
URL, http
The world wide web itself can be considered a REST system.

Searching Yahoo using REST
need:
1.Connect( net lib)
2.store
3.Parse results ( REXML lib)

Yahoo! web service API (up to 5,000 requests/IP per day)

Google AJAX Search API

use the CGI library to escape our search term, ensuring that the search term is safe for use in our HTTP GET request:
query = CGI.escape("SEARCH TEXT")

https://www.google.com/accounts/NewAccount?continue=http://api.google.com/createkey&followup=http://api.google.com/createkey:

Searching Google Using SOAP or SOAP with WSDL Files
UTF-8 can contain special characters that Ruby can’t handle in a string, causing our driver to throw an XSD::ValueSpaceError error upon invocation. To avoid this problem, we manually set our encoding to UTF-8 using the XSD library.
XSD::Charset.encoding = ‘UTF8′

Displaying Photos from Flickr Using XML-RPC

Building Web Service Servers
Make sure you turn off layouts for the methods you’ll be using in your service
Associate RXML templates with the methods in your controllers, instead of RHTML templates
xml is an XML document object that’s available in any RXML template
xml.name("Kevin", :id => 1, "age" => "31")
# creates <name id="1" age="31">Kevin</name>

 xml.exampledata do
     xml.name("Kevin")
 end
 # creates <exampledata><name>Kevin</name></exampledata>

SOAP and XML-RPC Web Service Servers
ActionWebService (AWS)
 script/generate web_service YOURSERVICE YOURMETHOD1 YOURMETHOD2

 three dispatching options, :direct, :delegated, or :layered.
web_service_dispatching_mode:direct
:delegated or :layered is the best way to go for any large or complex web service
With :delegated, clients use a distinct URL for each method in the API
With :layered, clients use the same URL for all attached methods and rely on AWS to route the request based on information passed in its header

:expects and :returns symbols
Ruby types (:string, :int, :bool, :float, :time, :datetime, :date, and :base64), or the names of ActiveRecord::Base or ActionWebService::Struct classes (for example, Greeting or Account), or a single element array to represent arrays of objects (for example, [:string] to represent an array of Strings or [Account] to represent an array of ActionWebService::Struct Account objects).

 raise "Access denied!"

發表在 Ruby on Rails | 留下評論

將日誌系統換成了typo

以前的日誌系統是基於asp+mssql的。功能上來說很滿足我的須要,簡單好用。即便這樣我也無時不刻想把它換成typo,經過幾天的努力,終於如願以償了。

為什麼要轉成TYPO?
typo基於Ruby on Rails語言,而自己正在學習使用ror,所以很希望在使用中熟悉別人的代碼寫作方法。而且typo可以在linux+mysql+apache的服務器上使用,我準備將使用更多的linux空間,最後去掉windows的服務器。所以我處心積慮地要轉向typo.

轉向typo

typo是為大多是國外在使用,國內很少用,原因是多方面的。1它要用到rails平台,現在比較難找到空間,2它的功能對國內用戶來說不友好,3它到目前只有英文版(4.1開始正在做多語言功能)。

換成typo時我做的第一步就是修改typo系統,
1.將typo和fckeditor整合,去掉textfilter的功能,這樣更方便我的使用習慣。
2.改進圖片上傳功能,使圖片上傳馬上顯示出來,這樣我就可以copy進fckeditor去,而不用寫代碼引用圖片。
3.修改鏈接顯示樣式,本來想改成和原來的blog系統一樣,但發現原來的blog使用html後綴,現在所有html文件被過濾了,所以只能改成大概和原來的鏈接一樣。
4.本來想找個好看點的theme,但找來找去竟然沒有一個讓人滿意的,這時懷念起來原來的界面,於是改!將原來的界面搬到了typo上!

比較費時的是數據轉換,寫了個程序轉換,現在轉過了所有的文章(個別文章的站內鏈接還有點問題),對文章分類進行了整理(typo支持一篇文章同屬於多個分類)。所有的評論沒有轉換,還好本來評論就不多。

發表在 其它 | 留下評論

MirrorMask, 2005

MirrorMask, 2005
http://www.imdb.com/title/tt0366780/
一部充滿幻想的英國電影。畫面真是太奇幻了,可惜的是故事沒有一點新意。
6


不知道這是哪裡,看起來不錯的地方。

發表在 電影評論 | 留下評論

惡魔的拍球歌, 1977

惡魔的拍球歌
http://www.imdb.com/title/tt0075650/
橫溝正史著名的金田一系列故事之一。可惜電影有點無聊,而且畫面有點恐怖(我想看推理電影不要恐怖電影。。),想起來還是古煙任三郞讓人起興得多。

4


這種字幕顯示方式很不錯。
發表在 電影評論 | 留下評論

Epic Movie, 2007

Epic Movie, 2007
http://www.imdb.com/title/tt0799949/

一部搞惡的電影。 看起來比較低俗,粗糙,而且一些畫面很嘔心。
4

發表在 電影評論 | 留下評論

Learning Ruby 1 Ruby.new

with <Programming Ruby 2nd>
Ruby Basic

                   Variables        &nb[-aa--]sp;          Constants and
Local          Global        Instance Class    Class Names
name           $debug        @name    @@total  PI

fish_and_chips $CUSTOMER     @point_1 @@symtab FeetPerMile
x_axis         $_            @X       @@N      String
thx1138        $plan9        @_       @@x_pos  MyClass
_26            $Global       @plan9   @@SINGLE JazzSong

statement modi?ers
puts "Danger, Will Robinson" if radiation > 3000
square = square*square while square < 1000

Regular Expressions
In Ruby, you typically create a regular expression by writing a pattern
between slash characters (/pattern/).

/P(erl|ython)/
This pipe character means “either the thing on the right or the thing on the left,” in this case either Perl or Python.
 /ab+c/ matches a string containing an a followed by one or more b’s, followed by a c.
/ab*c/ creates a regular expression that matches one a, zero or more b’s, and one c.

\s, which matches a whitespace character (space, tab, newline, and so on);
\d, which matches any digit;
\w, which matches any character that may appear in a typical word.
A dot ( . ) matches (almost) any character.

if line =~ /Perl|Python/

line.sub(/Perl/, ‘Ruby’)    # replace first ‘Perl’ with ‘Ruby’
line.gsub(/Python/, ‘Ruby’) # replace every ‘Python’ with ‘Ruby’

Blocks and Iterators
{ puts "Hello" }      # this is a block
do                    ###
  club.enroll(person)   # and so is this
  person.socialize      #
end                   ###

    def call_block
      puts "Start of method"
      yield
      yield
      puts "End of method"
    end
    call_block { puts "In the block" }
produces:
    Start of method
    In the block
    In the block
    End of method

def call_block
  yield("hello", 99)
end
call_block {|str, num| … }

iterators: methods that return successive elements from some kind of collection, such as an array.
   animals = %w( ant bee cat dog elk )  # create an array
   animals.each {|animal| puts animal } # iterate over the contents
# within class Array…
def each
  for each element    # <– not valid Ruby
    yield(element)
  end
end

Reading and ’Riting
puts writes its arguments, adding a newline after each.
print also writes its arguments, but with no newline.
printf, which prints its arguments under the control of a format stringejfkldfjai

發表在 Ruby on Rails | 留下評論