月归档:四月 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 条评论