月歸檔:四月 2007

Learning Ajax 2, url, link and button

with <Ajax on Rails>
S2.3. Bringing Rails into the Picture

complex url_for example:
url_for :only_path => false, :protocol => ‘gopher:// ‘,
  :host => ‘example.com’, :controller =&gt; ‘chapter2′,
  :action => ‘myresponse’, :trailing_slash => true, :foo => ‘bar’,
  :anchor => ‘baz’
#=> ‘gopher://example.com/chapter2/myresponse?foo=bar/#baz’

ajax on rails(aor) alert:
<p><%= link_to_remote "Alert with javascript Helper", :url =>
   "/chapter2/myresponse", :success => "alert(request.responseText)" %></p>

aor insert:
<p><%= link_to_remote "Update  with javascript Helper", :url =>
  {:action => "myresponse"}, :update => "response5" %></p>
<p id="response5"></p>

Chapter 3. Introducing Prototype

3.2 Ajax Links

:method => :delete
<%= link_to "Delete", "/people/1", :method => :delete %>

==>
<a href="/people/1"
  onclick="var f = document.createElement(‘form’);
           f.style.display = ‘none’;
           this.parentNode.appendChild(f);
           f.method = ‘POST’;
           f.action = this.href;
           var m = document.createElement(‘input’);
           m.setAttribute(‘type’, ‘hidden’);
           m.setAttribute(‘name’, ‘_method’);
           m.setAttribute(‘value‘, ‘delete’);
           f.appendChild(m);
           f.submit(  );
           return false;">Delete</a>

Return false;
<a href="#"
   onclick="new Ajax.Updater(‘current_time’, ‘/chapter3/get_time’,
               {asynchronous:true, evalScripts:true});
            return false;">Check Time</a>
<div id="current_time"></div>
The link will only be followed if the expression evaluates true (or if the user has javascript turned off). That’s why the link_to_remote helper puts return false at the end of the onclick attribute.

Callbacks:
<%= link_to_remote "Check Time",
    :update   => ‘current_time’,
    :url      => { :action => ‘get_time’ },
    :before   => "$(‘indicator’).show(  )",
    :success  => "$(‘current_time’).visualEffect(‘highlight’)",
    :failure  => "alert(‘There was an error. ‘)",
    :complete => "$(‘indicator’).hide(  )" %>
<span id="indicator" style="display: none;">Loading…</span>
<div id="current_time"></div>

hide( ) and show( )
for an element to be dynamically shown via javascript, its CSS display: none property must be defined inline

this won’t work:
<style type="text/css">
  #indicator { display: none; }
</style>
<div id="indicator">Hidden DIV</div>
<script type="text/javascript">
  $("indicator").show(  ); // won’t work
</script>

But this will work:

<div id="indicator" style="display: none">Hidden DIV</div>
<script type="text/javascript">
  $("indicator").show(  ); // will work
</script>

:condition
<li><%= check_box_tag ‘checkbox’ %> Thing #1</li>
<%= link_to_remote "Delete checked items",
    :condition => "$(‘checkbox’).checked",
    :url       => { :action => ‘delete_items’ } %>

:submit
it allows you to simulate a form submission. By providing the ID of a page element, any fields contained in it will be sent along with the request.
<div id="fakeForm">
  <input type="text" name="foo" value="bar" />
</div>
<%= link_to_remote "Submit fake form",
       :submit   => "fakeForm",
       :url      => { :action => ‘repeat’ },
       :complete => "alert(request.responseText)" %>

nested forms

<form id="myForm">
  <input type="text" name="text_to_reverse" id="text_to_reverse" />
  <%= link_to_remote "Reverse field",
       :url      => { :action => ‘reverse’ },
       :submit   => "myForm",
       :complete => "$(‘text_to_reverse’).value=request.responseText" %>
  <input type="submit" />
</form>

:with
<%= link_to_remote "Link with params",
       :url      => { :action => ‘repeat’ },
       :complete => "alert(request.responseText)",
       :with     => "’foo=bar’" %>
two sets of quote marks. javascript expression

include references to javascript variables or DOM elements:
<input id="myElement" type="text" value="bar" />
<%= link_to_remote "Link with dynamic params",
       :url      => { :action => ‘repeat’ },
       :complete => "alert(request.responseText)",
       :with     => "’foo=’+escape($F(‘myElement’))" %>
escape it (so that it can safely be included in a URL query string)

link_to_function
<%= link_to_function "Toggle DIV", "$(‘indicator’).toggle(  )" %></p>
toggle( ), which hides and shows elements on the page.

button_to_function
<%= button_to_function "Greet", "alert(‘Hello world!’)" %>

combine with remote_function
<%= button_to_function "Check Time",
      remote_function(:update => "current_time",
        :url => { :action => ‘get_time’ }) %>

DIY button_to_remote
def button_to_remote(name, options = {})
  button_to_function(name, remote_function(options))
end
==>
<%= button_to_remote "Get Time Now",
      :update => "current_time",
      :url    => { :action => ‘get_time’ } %>

發表在 Ruby on Rails, 站長文檔 | 留下評論

Ruby on Rails, Layout

<%= render :partial => "person" %>

the partial is named "person," the main template will look for an instance variable @person, and pass it to the partial as a local variable, person.if the instance variable doesn't match the name of the partial, you'd explicitly pass it, like this:

<%= render :partial => "person", :locals => { :person => @scott } %>
All the key/value pairs in the :locals hash will be made into local variables for the partial.

<%= render :partial => "person", :collection => @people %>
In this example, the main template has an array @people that will be looped through, passing a local variable person to the partial.

render :layout => false
def reverse
  @reversed_text = params[:text_to_reverse].reverse
  render :layout => false
end

發表在 Ruby on Rails | 留下評論

Learning Ajax 1, Prototype

with <Ajax on Rails>
Chapter 2 .Getting Our Feet Wet

S2.1. The Old-Fashioned Way
<p><a href="#" onclick="asyncAlert(  )">Call async server-side</a></p>
<script type="text/javascript">
  function asyncAlert(  ) {
    //Call server(IE-safe)
    function getRequestObject(  ) {
      try { return new XMLHttpRequest(  ) } catch (e) {}
      try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) {}
      try { return new ActiveXObject("Microsoft.XMLHTTP") } catch (e) {}
      return false
    }
    var request = getRequestObject(  );
    request.open('get', '/chapter2/myresponse');
    //we define a function that checks to see if readyState is 4 (which means the request is complete)
    request.onreadystatechange = function(  ) {
      if(request.readyState==4) alert(request.responseText);
    }
    request.send(  );
  }
</script>

s2.2. javascript Libraries and Prototype
Prototype Way:
<script src="/javascripts/prototype.js" type="text/javascript">
</script>
<p><a href="#" onclick="prototypeAlert(  );">Call with Prototype</a></p>
<script type="text/javascript">
 function prototypeAlert(  ) {
  new Ajax.Request('/chapter2/myresponse', { onSuccess: function(request) {
   alert(request.responseText);
  }})
 }
</script>

Update a element's innerHTML
<p><a href="#" onclick="updateElement(  )">Update element </a></p>
<p id="response"></p>
<script type="text/javascript">
  function updateElement(  ) {
    new Ajax.Request('/chapter2/myresponse', { onSuccess: function(request) {
      $('response').update(request.responseText);
    }})
  }
</script>

================>
<p><a href="#" onclick="updater(  )">Update with Ajax.Updater</a></p>
<p id="response2"></p>
<script type="text/javascript">
  function updater(  ) {
    new Ajax.Updater('response2', '/chapter2/myresponse');
  }
</script>

insert content:
<p><a href="#" onclick="appendToElement(  )">Append to element</a></p>
<p id="response3"></p>
<script type="text/javascript">
  function appendToElement(  ) {
    new Ajax.Updater('response3', '/chapter2/myresponse',
      { insertion:Insertion.Bottom });
  }
</script>
//insertions: Before, Top, Bottom, and After.

===============>
<p><a href="#" onclick="new Ajax.Updater('response4',
'/chapter2/myresponse', { insertion:Insertion.Bottom });">
Append to element</a></p>
<p id="response4"></p>

發表在 Ruby on Rails | 留下評論

A Bloody Aria, 2006

A Bloody Aria, 2006
http://www.imdb.com/title/tt0821462/

好噁心, 沒想到韓石圭會參演這樣的電影。
不過剛開始那一小段很不錯。
4

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

大電影之數百億, 2006

大電影之數百億, 2006

搞的電影沒有想像中多,也沒有想像中惡。。。

5

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

Google的病毒式營銷

Google AdSense廣告收入是Google收入的主要來源之一。
Google AdSense讓站長發布其廣告,與站長瓜分收益,同時又讓以重金為酬,讓站長向其它站長或公司推薦AdSense和與其相對的廣告收集項目AdWords. 站長們一傳十,十傳百, 不用專門的推銷人員,省下管理了人員,卻帶來乘方式的回報。這種新式的病毒式營銷既與Google這類早去蓬勃的信息產業類型門當戶對, 又低耗高效, 實在是高!

Google在其它領域使用的病毒式營銷
Gmail的邀請式註冊

病毒式營銷(viral marketing/viral advertising)

self-replicating viral processes
analogous to the spread of pathological
to obtain a large number of interested people at a low cost.

Word of Mouth Marketing (WOMM)

發表在 信息處理 | 留下評論

Babel,2006

Babel,2006

http://www.imdb.com/title/tt0449467/
今天去書店看到一本名為

的書,可能很是暢銷,被擺在了電梯口。
看來很多人都發現這個世界越來越小了。
我也很想說明萬物是關聯的,用電影,告訴大家,今天在街上和你擦肩而過的,今天之前你不認識,今天之後你們或許也永遠沒有機會再次相見的人,卻可能是和你關聯着的。

感覺這片的結構是這個意思,但內容卻比較分散。兩年前(?)類似的電影<Crash>給我的印象好一些。

7

Babel,2006
繁華的日本都市

Babel,2006
這是一套很爽的房子,下面跟着電影鏡頭重點參觀一下,看點是它的陽台

Babel,2006
透過窗戶可以看到都市夜景

Babel,2006
繞過那個窗戶可以出到陽台

Babel,2006
陽台上看到的美麗夜景

Babel,2006
偶爾陽台本身也可以成為風景

Babel,2006
大廈遠景(左部那橦),那套房子是頂層(31樓或以上樓層)右角

發表在 電影評論 | 一條評論

越劇電影大全

下面是我整理出來的越劇電影單目。目前為止應該是網上最全的。如果還有遺漏大家可以留言補充。

1948年《祥林嫂》
啟明公司
原著:魯迅 改編、導演:南薇 攝影:董克毅、董紹泳
演員:袁雪芬 范瑞娟 徐天紅 張桂鳳 吳小樓 項彩蓮 張雲霞

1949年《越劇精華》
文華公司
導演:桑弧 攝影:黃紹芬
包括:
范瑞媚、傅全香的《樓台會》;
徐玉蘭、王文娟的《販馬記》中的《寫狀》;
袁雪芬,徐玉蘭、筱小招、吳小樓的《雙看相》;
竺水招、戚雅仙的《賣婆記》。

1949年《相思樹》
中國電影實驗工廠
導演:程述堯
編劇:鍾 泯 邵慕水
袁雪芬 魏鳳娟 金艷芳 陳金蓮 高劍琳

1950年《石榴紅》
中國電影實驗工廠
導演:韓義
編劇:沈默
徐天紅 戚雅仙 焦月娥 高劍琳

1953年《梁山伯與祝英台》
上海電影製片廠
編劇:徐進、桑弧 導演:桑弧、黃沙 攝影:黃紹芬
布景設計:胡倬雲、張曦白
根據華東戲曲研究院舞台劇本改編
袁雪芬 范瑞娟 張桂鳳

1958年《情探》
江南電影製片廠
編劇:田漢、安娥 導演:黃祖模 攝影:李生偉 美工:盧景光
演出:上海越劇院
傅全香、陸錦花

1959年 《西廂記》
香港文華電影公司
金寶花、張茵、高佩

1959年 《追魚》
天馬電影製片廠
改編:集體 導演:應雲衛 攝影:馬林發 美工:葛師承 副導演:丁然
演出:上海越劇院
徐玉蘭、王文娟、鄭忠梅、周寶奎

1960年《斗詩亭》
天馬電影製片廠
編劇:胡小孩 導演:應雲衛 攝影:馬林發、任志新 美工:葛師承
演出:浙江越劇二團
根據浙江省越劇二團演出本改編

1961年《雲中落繡鞋》
長春電影製片廠

1961年《王老虎搶親》
香港長城影業公司 上海越劇院配合
導演:金庸
編劇:金庸
夏 夢 李 嬙 配 音 畢春芳 戚雅仙等

1962年《紅樓夢》
海燕電影製片廠、香港金聲影業公司聯合攝製
編劇:徐進 藝術指導:朱石麟 導演:岑范 攝影:陳震祥美工:胡倬雲、張曦白
演出:上海越劇二團
徐玉蘭 王文娟 金採風 呂瑞英 周寶奎 徐天紅 孟莉英

1962年《碧玉簪》
海燕電影製片廠、香港大鵬影業公司聯合攝製
改編、導演:吳永剛 攝影:羅從周、彭恩禮 美工:張曦白 副導演:趙煥章 舞台導演:黃沙
演出:上海越劇二團
根據上海越劇院演出本改編
金採風 陳少春 周寶奎 姚水娟 錢妙花

1962年《三看御妹劉金定》
香港長城影業公司 上海越劇院配合
編劇:李萍倩
夏 夢 丁賽君 李 嬙 馮 琳 配 音 陳 琦 徐涵英

1962年《柳毅傳書》
長春電影製片廠
改編:南京市越劇團創作組集體,計大為、葉至誠執筆
導演:蔡振亞 攝影:吳國疆 美工:崔永泉、陳德生
演出:南京市越劇團
竺水招、筱水招、商芳臣

1963年《毛子佩闖宮》
珠江電影製片廠、香港鴻圖影業公司聯合攝製
編劇:裘鳳 導演:斯蒙 攝影:李生偉 美術:葛興萼 副導演:黃丹彤
演出:武漢市越劇團
金雅樓、筱靈鳳

1963年《金枝玉葉》
香港長城影業公司 上海越劇院配合
編劇:胡小峰
夏 夢 丁賽君 李 嬙 馮 琳 配 音 陳 琦 徐涵英

1965年《烽火姻緣》
香港長城影業公司拍攝 上海越劇院配合
編劇:李萍倩
夏 夢 丁賽君 配 音 陳 琦 徐涵英

1974年《半籃花生》
長春電影製片廠
編劇:《半籃花生》創作組 導演:朱文順 攝影:常彥 美工:汪滔
演出:浙江越劇團

1978年《祥林嫂》
上海電影製片廠、香港鳳凰影業公司聯合攝製
改編:吳琛、庄志、袁雪芬、張桂鳳 導演:岑范、羅君雄
攝影:蔣錫偉 美工:胡倬雲、謝棨前
袁雪芬、金采鳳

1982年《花燭淚》
浙江電影製片廠
編劇:胡小孩、謝枋、天方 導演:殷子、陳蟬
攝影顧問:石鳳歧 攝影:龔國良蓖、周榮震 美工:駱德灝
演出:浙江越劇一團

1983年《莫愁女》
南京電影製片廠
編劇:張弦 導演:周予、吳秋芳 攝影:馮秉鏞、單興良 美術顧問:張曦白 美術:胡榮法
竺小招、林婷婷

1984年《五女拜壽》
長春電影製片廠 編劇:顧錫東 導演:陸建華、於中效
總攝影:王啟民 攝影:李俊岩 美術:徐振鵾
演出:浙江省小百花越劇演出團
董柯娣、徐愛武

1985年《繡花女傳奇》
中央新聞紀錄電影製片廠 改編:包朝贊 導演:石嵐
攝影:瞿金樓 美工:葉明楠
演出:浙江省杭州市桐廬越劇團
根據江南民間故事改編

1986年《桐花淚》
上海電影製片廠
編劇:包朝贊 導演:沙潔 攝影:張珥 美術:秦柏松 副導演:史鳳和
演出:杭州市越劇二團

1999《紅絲錯》
浙江省電影公司、浙江小百花越劇團聯合攝製
編劇:顧頌恩 導演:徐偉傑 攝影:瞿家振、李榮聖

2001年《唐伯虎》
茅威濤、何賽飛

2002年《醉公主》
中影集團、北京今古影視策劃有限公司聯合攝製
編劇:王雲根、錢勇 導演:森島 攝影:王健

發表在 越劇柔情 | 3 條評論

Death Note,The Last Name, 2006

Death Note,The Last Name, 2006

http://www.imdb.com/title/tt0810827/

一個是足智多謀、明察秋毫,為查真兇,捨身捨命;
一個是心狠手辣、詭計多端,為瞞身份,殺人殺神。
神探和死神的最終較量,看鹿死誰手,竟在Death Note 下集<The Last Name>!

8

電影有很多謎題,不過最讓我不解的是:為什麼 L 吃不胖?

Death Note,The Last Name, 2006
大學教室

Death Note,The Last Name, 2006
硝煙已經屬於過去

Death Note,The Last Name, 2006
我忘記了什麼嗎?

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

Ubuntu中的VirtualBox使用USB設備的權限問題

VirtualBox是一個虛擬機程序。我在Ubuntu 6.06上安裝了一個,在上面安裝了一個Windows XP, 解決一些國內軟件和網站對linux系統支持不充分的問題,如工商銀行網站只能使用Windows下的IE瀏覽器登陸管理, 又如只有在Windows下的QQ軟件才能傳送文件和語音視頻聊天。。。

VirtualBox支持將主機(host)上的USB設備連接到虛擬機(guest)上。但要以root的身份啟動VirtualBox,不然會因為權限問題無法使用。我查了好些網站,才讓我的USB攝像頭在不使用root權限的情況下,在虛擬機上的Windows XP正常工作,所以我把詳細方法貼出來,讓大家參考。本方法在Ubuntu 6.06, VirtualBox 1.3.6驗證成功,可能不適合其它版本的系統。

步驟如下:
先新建一個usbfs組:
sudo groupadd usbfs
將當前用戶加入這個用戶組:
sudo adduser $USER usbfs
打開/etc/group文件
gedit /etc/group
查找usbfs,記下ID,如,我的情況是:
usbfs:x:1002:yourname
上面1002就是ID。
打開/etc/fstab文件:
sudo gedit /etc/fstab
在後面加一行:
none /proc/bus/usb usbfs devgid=1002,devmode=664 0 0
注意devgid=1002中的1002要改成你剛在group中查到的usbfs組的ID。保存文件。

啟動VirtualBox
在Settings->USB中
勾選Enable USB Controller
並在USB Device Filters列表中添加你要使用的USB設備
(點擊列表右邊有加號的圖標可以選擇USB設備,也可以用
VBoxManage list usbhost
命令列出所有USB設備,然後自己填表增加)

好了,設置完成了。現在重啟Ubuntu,然後啟動VirtualBox中的Windows XP,現在可以使用USB設備了。
Ubuntu中的VirtualBox使用USB設備的權限問題

QQ可以視頻聊天,但有時圖像會停頓一會。CPU使用率100%(雙核之中的一個)。

附在VirtualBox下啟動QQ的方法:修改QQ安裝目錄下的npkcrypt.sys(系統文件,默認隱藏)文件名。據說修改後會有安裝隱患,請酌情使用此方法。

發表在 其它 | 4 條評論