电影 The Happening 预告+英文剧本

五月 17th, 2008 | 1,273 次浏览

之前在电影院看别的电影时 看到了这个电影的预告… 觉得很感兴趣, 但是电影6月份才会上映, 为了解馋, 在网上搜了个剧本, 拿出来分享下.

 

剧本下载地址: http://www.k4ng.com/The_Happening.pdf

预告:

如何在Netbeans中开发Android程序.

四月 3rd, 2008 | 8,493 次浏览

Google Android项目的用IDE开发时通常是Eclipse + Android SDK + Android plugin for Eclipse.  Eclipse因为有IBM撑腰, 前几年一直是Java IDE的首选..不过现在Sun公司经过多年的摸黑和偷窥(..-_-|||)  从NetBeans 5.5开始  就已经让很多的JAVA开发者开始接受Sun自己的Java IDE, 目前又新推出了NetBeans 6.0.1, 无论从哪方面讲, 都已经是可以和Eclipse相提并论甚至很多方面也已经强过了Eclipse (尤其是俺学校做作业开始要求用NetBeans了….)  所以俺一直在找寻在NetBeans下开发Android的方法… 写作业用NetBeans , 做Android用Eclipse 那我不是吃饱了没事闲的给自己找罪受么… 于是, 答案被俺在NetBeans的wiki上找到.. 下面就分享下..

*****插播刚看的新闻(April 3rd, 2008): 美国最大的通信公司AT&T 已经同意将推出运行Google Android操作系统的手机*****

 

首先需要下载以下的程序

NetBeans

Android SDK

Android plugins for NetBeans (Undroid)

 

1. 安装Undroid(为Netbeans设计的Android 开发插件)

下载插件并安装, Tools-> Plugins -> Downloaded

确定你安装了Platform Support 和Project Support模块. 再装个Examples看看例子也不错..

image

2. 填加 Android Platform

装完插件后, 你需要从Tools-> Java Platforms中填加Android Platform

image

指向你的Android SDK目录

image

3. 创建新的Android项目

从Files-> New Projects.  你可以看到分类里有一个新项目叫Android

image

换不换默认程序名随你便…

 image

新Android项目的结构应该是下面这样的

image

MainActivity.java的代码如下

package org.me.androidapplication1;

import android.app.Activity;
import android.os.Bundle;

/**
 *
 * @author amit
 */
public class MainActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // ToDo add your GUI initialization code here
    }

}
4. 运行项目
现在就可以试着运行一下了, 运行成功的话, Android模拟器就会跳出来
image
 5. NetBeans中Android 的Hello World
填加一行
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
在这一行的上面
// ToDo add your GUI initialization code here
 

然后你会发现Netbeans告诉你"Cannot find symbol". 这是因为还需要导入TextView…(-_-|||..)

Netbeans里导个这东西很简单.

image
 代码现在应该看起来是这样的
package org.me.androidapplication1;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

/**
 *
 * @author amit
 */
public class MainActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
    }

}
再次运行, 俺们的Hello World 就出来了.
image 
 附:  Android SDK M5-rc15 发布后 Netbeans的Android开发插件Undroid无法运行的解决方案:
http://abhrajit.blogspot.com/2008/03/undroid-and-android-sdk-m5-rc15.html

[转]互联网周刊:Google的全球计算机猜想

四月 1st, 2008 | 740 次浏览

想象一下,未来的企业将不再需要自己桌面软件和数据中心,全球数据处理和存储服务都由Google将进行托管, 这个猜想如此另人兴奋,以致于让人怀疑其现实性与可行性.

尼克拉斯卡尔(Nicholas Carr)曾经是《哈佛商业评论 》的编辑,在他的新书 《大转变》(The Big Switch)中,他向人们描述了将要发生的数字生活的巨大转变.

为了更好地说明,卡尔首先引入了一个类似的变革:电力的发明.卡尔认为,真正的电力发明并不是爱迪生,他的想法是为每家工厂安装独立发电机,这个想法现在看来如此地不切实际,而具有功效的发明应该来自于爱迪生的财务员工萨穆埃尔因苏尔(Samuel Insull),他首先想到了创建一个中心电厂来为整个地区供电.因苏尔的想法使电真正转化为效用,并大幅降低了电的成本.

卡尔在接受福布斯专访时,谈到,100年前曾经在机械动力领域上演的这一幕,现在又将发生在今天的计算领域.在19世纪末期,如果你的企业需要运转一台机器,你没有其它选择,只能自己生成动力.因此,你需要在企业内建造一个大型的动力运营部门,最初利用的是水力和蒸汽动力,然后便是电力.当尼克拉特斯拉(Nicola Tesla)发明了电力传输方式之后,一切都发生了变化.你只要处于一个供电网络之中,就可以获得来自遥远地方的电力.因苏尔首先认识到了集中供电的经济优势,并创建了多家公司共享电力资源的模型,因为生产制造公司不需要再自己发电,所以大幅降低了电价.

早些时候,Google推出一款名为Google Apps的免费软件包,是 Google 推出的在线的应用服务.说得通俗一点,通过 Goolge Apps ,你可以向你的用户提供带有私人标志的电子邮件、即时通信(网上聊天),日历工具,网站设计工具,协同办公工具等.当然,这些服务都是由 Google 托管,而不需要你安装或维护任何软硬件,并且和 Google 的其他服务一样,它们都是免费的. Google刚刚进入企业市场的,大多数客户都乐意试用这款免费产品. 其实,Google Apps缺乏Microsoft Office中的许多功能.但Google这样解释:大多数人只用了Office中很少一部分功能.产品负责人戴夫格罗伍德所取得的成果感到很满意.他说,每个工作日有约2000家公司签约使用Google Apps.Google Apps是面向任务的小型软件工具, Google的涉足已经激起了在企业中普及“云计算”技术的兴趣.包括通用电气和宝洁在内的一些大公司已经公开表示将至少试用Google Apps.他预测,明年将有大量大公司使用Google Apps.这将可以为Google带来更多的与搜索相关的广告收入.

Google Apps只不过是Google通过互联网向用户提供更大计算能力计划的一个步骤.对于大多数人而言,计算机是复杂而不可靠的.如果Google能够通过 Web提供计算服务,将是人们计算体验的真正改进.Google认为这一切将发生在遥远的数据中心中的服务器,用户可以通过许多有线和无线设备访问这些服务,这就是所谓的“云计算” (cloud computing),这和电力革命有着何等相似之处啊!

Google的CEO施密特指出,随着互联网连接速度的提高和互联网软件的改进,“云计算”能够完成的任务会越来越多.他说,90%计算任务都能够通过“云计算”技术完成,其中包括几乎所有的企业计算任务和白领员工的任务.仍认为Google只是一家搜索引擎公司的看法已经过时.尽管 Google Docs、Google Spreadsheets、Blogger和YouTube等产品或服务还没有给Google创造太多营收,但它们绝非是Google的附属业务.卡尔认为,这些网络应用代表着根本性的变革,意味着从桌面到网络的巨大转变,这将重新定义计算和Google的业务模式.

微软这个后腿

如果Google获得成功,Google基本模式将改变软件世界的所有规则,那么目前微软提供的基于桌面PC的许多价值都将化为乌有.

计算机科学家出身的施密特职业生涯中大部分时间都在与微软抗争,眼看着微软战胜了其大多数竞争对手.在Sun担任技术总监时,施密特与麦克利尼一道反对微软及其领导人.

施密特相信,无论他如何努力地避免激怒微软,Google与微软的摩擦是不可避免的.当然了,微软也不会停滞不前,它已经在搜索和互联网广告领域投资数十亿美元,以赶超Google,但迄今为止并没有获得成功.它们还在其它一些领域相互争斗,例如Web地图、在线视频、手机软件.

最近的消息是,微软计划将软件业务纳入“云计算 ”,看一下资本支出,该公司和Google一样在中心数据中心投入了数十亿美元.但是,微软所面临的一大难题是,该公司绝大多数营收来自于原有模式,如何推广新模式,但又不影响到旧模式生成的营收.微软心有旁骛地希望这一转型进程将非常缓慢,从而能够不伤及公司现有业务.微软拥有客户资源,而Google 没有旧业务拖后腿.

Google和微软之间日益激烈的对立将是一场史诗般的企业战争,这将是一场有趣的竞赛.两家公司的成功和发展将决定了消费者和企业未来将如何工作、购物、通讯,勾勒出数字生活的真实图景.

在曾经担任Novell CEO的4年中,施密特认为,任何戏弄微软的竞争对手都是愚蠢的,这只会激发微软的愤怒.

微软将Google的乐观称作是一厢情愿. 微软企业部门总裁莱科斯表示,Google对微软的攻击被误导了,也是自大的.Google关注的是自己的利益,它是为了削弱微软,而不是满足客户的需求.微软在产品开发和客户研究上花费了数年时间并投入了数十亿美元,仔细研究了员工和企业使用软件的方式. 确实,微软的优势在于其在办公软件市场上巨大的领先优势.有人说,Google不能在桌面软件领域与微软直接对抗就开始另辟蹊径,引领桌面软件正在向 Web软件转型.

而另外一方面,利用Web软件收发电子邮件、处理文档和电子表格、进行协作很方便吗?高速宽带连接会象Google断言的那样普及和可靠吗?企业、大学、消费者会让Google保存他们的资料吗?另外,如何解决“飞机问题”,以及在不能上网时,用户如何工作?

这些问题是否都能从Google那里找到答案?

人工智能搜索

施密特承认“云计算”不会在一夜之间普及.象年长的消费者一样,大公司通常会慢慢地改变自己的习惯.他说,这 是为了解决其它问题.

未来五年,Google要解决的问题就是不断地完善搜索,很多人仍认为Google是一家搜索公司.一年之前,Google高层也表示该公司只挖掘了 5%的搜索潜力.Google联合创始人拉里?佩奇(Larry Page)和塞吉?布林(Sergey Brin)在接受《大转变》作者卡尔采访时曾表示,Google认为搜索是人工智能的最基本形式.这就意味着,为了提供最佳的搜索结果,Google搜索引擎需要了解用户的意图甚至用户的思维方式.

在这方面,国内的搜索老大百度也曾发表过关于智能搜索的看法,在今年,李彦红在上海会见了英国首相布朗,布朗作为政治舞台上的大腕对于新技术,新商业模式的如数家珍让李彦红大吃一惊,布朗最后告诉李说,未来的搜索引擎将会越来越智能化,而李彦红说,人工智能只是一个方面,更多的还要靠百度知道这类产品来匹配检索.

而《大转变》一书的作者卡尔所预测的Google的人工智能是将把搜索和人脑整合在一起.这听起来有些像科幻小说,但这正是Google的终极目标. 如果这一预测成真,人们将不再需要坐在计算机前,也不再需要键盘,搜索将会自动完成.按照佩奇的想法,只要你想到一个问题,Google就会通过手机告诉你答案.

这就是未来将要发生的大转变吗?但无庸质疑的一点是,Google越接近人类大脑的思考,就会赚到越多的钱.

官方出版的苹果机安装Windows指南+工具包 — Apple Boot Camp

三月 28th, 2008 | 1,267 次浏览

根据Apple官网上介绍, 用这套方法可以安装最新32bit的Windows XP和Vista,  并且能够完全发挥苹果的性能. 安装时候, Boot Camp Assistant会自动创建一个新分区给Windows使用,Mac OS上的一切都会保留在硬盘的其它地方. 装完Windows后, 用Leopard DVD就可以把机器原来的驱动都装上, 省得上网找还麻烦 0.0.   开机时候可以自选是要进Mac OS还是Windows.(..当然要有要不要他有啥用..)  看起来还不错..自带PDF guide可以参照.

网址:

http://www.apple.com/macosx/features/bootcamp.html

百度hi公测开始…

三月 27th, 2008 | 702 次浏览

刚拿了个帐号…我靠百度hi长得巨像tm2008 preview. 给个图:

百度hiTM 2008

GPhone?.. Android!!

三月 27th, 2008 | 1,153 次浏览

 一直传言google要出手机了, 现在看来手机的事一直还是未知, 不过这个新的操作系统已经是板上定钉了…05年时google收购了Android Inc. 三年时间终于有成果了… 这个貌似要成为手机界的windows的系统貌似真的不错.. 拭目以待吧. 具说第一个支持Android的手机会是HTC的HTC Dream….不知是真是假…很想弄个试试的说…期待.

Emacs & VI

二月 3rd, 2008 | 1,090 次浏览

 





     Vi and Emacs

NOT “Vi vs. Emacs” — Despite twenty or thirty years of abuse thrown at each other by adherents of the Church of Vi vs the Church of Emacs, I feel the two editors are complementary, rather than antagonistic. They have a very different “look and feel”, but that’s not a real reason for choosing one over the other. They were designed for different jobs, they are better at different things, and I use both of them, depending on the job.

Specifically, I use GNU Emacs and Vim, and every time I say “Emacs” or “Vi”, assume these programs unless proven otherwise.




Vi and Emacs are alike:

  • Full-function editors
    • Indenting, reformatting.
    • Syntax highlighting.
    • Unlimited undo and redo.
    • Multiple cut and paste clipboards.
    • Spell checking.
    • Multiple language support (including Unicode, R-to-L for Hebrew, Arabic, etc.)
    • Extendable
      • Macros and functions.
      • Fully customizable keys vs. actions.
    • Handle text strings, full lines, rectangles.
    • Adapt to type of file (.txt, .c, .html, etc.) being edited.
    • No line length or file size limits, within reason.
    • Automatically handle UNIX, MAC, DOS line endings (LF, CR, CRLF respectively).
    • Binary file editing.
    • Well documented, both internally and via available books and ebooks.
  • TTY and GUI versions.
    • The command emacs will start in either TTY or GUI mode, depending on where it is invoked. Use emacs -nw to force the program to use an Xterm window in text mode instead of starting its own.
    • The command vi[m] always starts in TTY mode, even in an Xterm session; use gvim or vi[m] -g to start the graphical version.
  • Implemented on many platforms:
    • Unix/Linux
    • Win32
    • Mac
    • Etc.
  • Widespread Availability
    • Both will be on any Unix/Linux machine
    • Freely available for download for Windows, Mac, etc.
  • Several versions available:
    • The original GNU Emacs from RMS, and Xemacs, forked from an earlier version of GNU Emacs source, are the most common. Other editors like Epsilon and JOVE are Emacs derivatives.
    • The original UNIX Vi (which almost nobody uses), Nvi (New Vi), Vim (Vi Improved), Vile (Vi like Emacs), Elvis.
    • For Linux distributions at least, “emacs” gives you the GNU version, and “vi” gives you vim.



Vi and Emacs are different:

  • Most simply, Vi was designed to write PROGRAMS, with all other types of file possible. Emacs was designed to write TEXT, with all other types of file possible.
  • Vi is much smaller and loads much faster; it will fit on a diskette while Emacs quite definitely will not.
  • The Biggie: Emacs is modeless, Vi has modes.
    • This relates to how an editor performs its two main functions: entering text and executing commands relating to the text.
    • Most modern editors and word processors are modeless, so that a user may enter text (e.g., typing “A”) or a command (^S to save the file) at any time.
    • Vi has three modes:
      • Text insert mode
      • Keystroke command mode (vi mode)
      • Command line mode (ex mode)
  • Plus and Minus for modeless (Emacs):
    • (+) Familiar.
    • (+) Easily adapts to standard GUI pull-down menu style.
    • (-) Commands have complicated syntax and hard-to-type keystrokes, since a limited number of keys are available for commands.
    • (-) Some needed keys might not be available on all keyboards.
  • Plus and Minus for modes (Vi):
    • (-) Confusion about which mode program is currently in.
    • (-) Nuisance of switching modes frequently.
    • (+) Many more keystrokes (~90) available for commands.
    • (+) Touch typists tend to become very proficient because the fingers can stay in their normal positions almost all the time.
  • The bash shell can be configured for either style through the commands set -o emacs (the default) or set -o vi




Vi and Emacs Keystroke Usage

Here are a few typical commands, showing the differences between “mode” style and “modeless” style:

                        VI        EMACS
		        --        -----
Right one column        k         ^f
Right one word          w         Esc,f
Left one word           b         Esc,b
Next sentence           )         Esc,e
Previous sentence       (         Esc,a
Save file               :w        ^x,^s
Delete paragraph        d}        Esc,x,kill-p[TAB],[RET]
Edit a new file         :ename   ^x,^f,name
RegEx search for "foo"  /foo      Esc,^sfoo
Repeat search           n         ^s,[RET]
Exit                    :q or QQ  ^x,^c
Save and Exit           :x        ^x,^s,^x,k,[RET]
Repeat last search      n         ^s,[RET]
Paste from clipboard    p         ^y
Delete 7 lines          7dd       ^a,Esc,7,^k
Undo                    u         ^x,u  or ^/
Change a letter to "x"  rx        ^d,x
Go to line 6            :6[RET]   Esc,<,Esc,5,^n
   ..or                 6G        Esc,x,goto-l[TAB][RET],6[RET]

You can easily see Vi tends to have simpler commands (in command mode) because it has all the “ordinary” letters and numbers available for navigational use.

Note that the Emacs documentation makes frequent mention of the “Meta” key, including key sequences like M-a, etc. Since most keyboards do not have such a key, M-a, for example, can be done two different ways:

  • Esc,a That is, hit the Escape key, let go, then hit the “a” key. This will work on all keyboards.
  • Alt-a That is, while holding down the Alt key, press “a”, then release both. This will usually work on a local PC keyboard (one actually attached to the machine where the editing is taking place), but almost certainly will not work on a remote terminal.



Vi Mode Navigation

  • [ESC] always enters vi (keystroke command) mode. If already there, it just beeps. (Hint: Bottom line is blank)
  • From vi mode, colon (:) enters ex (command line) mode. (Hint: colon (:) and cursor show on bottom line)
  • From vi mode, various commands enter insert mode: i (insert), a(append), o (open line), cw (change word), etc. (Hint: Cursor doesn’t move, –INSERT– shows on bottom line)



GUI vs TTY

  • The Vi TTY program loads very quickly, and is particularly useful for small changes to files.
  • SSH and Telnet are text-only, so you need to use the TTY version of either editor if remotely connected.
  • If you plan to spend a long time in the editor, the GUI versions are the better choice:
    • They start in different windows, so the command line is still there.
    • Font size, color scheme, window dimensions easily adjustable.
    • Editing several files at once is easier.



Emacs LISP

Emacs actually consists of a LISP interpreter executing a few pre-compiled primitive routines written in C plus about 200,000 lines of LISP code to implement all the functions of the editor. This makes Emacs extremely flexible, since an experienced LISP programmer can change anything and everything, as well as create new actions the program’s author never thought of.

Emacs can be made into an e-mail client, a web browser, a chess opponent, etc. by simply adding the proper code. A single keystroke can be mapped to execute an entire LISP program, which uses the file being edited as its subject matter. For example, here is a segment of my .emacs file, which defines a function called lookat-file and then “binds” it to the CTRL-F key.

(defun lookat-file ()
"Edit file with name delimited by colon at beginning of current line."
  (interactive)
  (save-excursion
    (save-match-data
      (beginning-of-line)
      (search-forward-regexp "^\\(.*\\):")
      (find-file (match-string 1)))))

(define-key global-map "^F" 'lookat-file)

LISP functions are all defined the same way:

(funcname arg1 arg2 …)

The last line in the example calls the function define-key with three arguments: the variable global-map, the literal ^F (the CTRL-F key), and the function name lookat-file, previously defined.

All built-in functions (like define-key and variables (like global-map) are fully documented in the extensive Emacs help system. In the definition of lookat-file shown above, every single keyword is a built-in LISP function.

Note that Emacs is fairly easy to port to a new architecture, because the “look and feel” is entirely defined by the LISP code, and that is unchanged whether Emacs is running on Solaris, Linux, Win98, or whatever. The only code that has to be modified is the LISP interpreter itself plus the primitives that handle platform-dependent stuff like file i/o and the other interfaces to the OS.




LISP Structure

LISP is actually very simple, because everything has the same form, namely a list of items enclosed in parentheses, and all program operations are function calls. Variables are untyped. For example:

(+ 2 3)             ; add 2 and 3, return 5 as the value of the function.
(setq foo "John")   ; store the string "John" into the variable foo.
(setq foo (+ 2 3))  ; store 5 into foo
(setq foo (and huey dewey louie))
                    ; set foo true if all three are true, else false
(setq bar (* (+ 2 3) (- 6 2) (* 2 2) (sqrt 9)))
                    ; store 240 into bar.
(setq ans (if (< foo bar) 1 2))
                    ; ans is 1 if foo is less than bar, 2 otherwise
(defun myfun (arglist) statements)
                    ; define function myfun

From these examples, it is easy to see why it’s a standard joke that LISP (which really stands for LISt Processor) is an acronym for “Lots of Irritating Silly Parentheses”. BTW, Vi enthusiasts tend to claim that Emacs is an acronym for “Eight Meg and Continuously Swapping”. Note that this joke has been around since the days when eight MB was a lot of memory. On the other hand, Emacs bigots will refer to Vi as “six”. (In which case Vim would be what, 994?)

I have to correct one statement I made earlier. Actually, Emacs also has a command-line. Typing Alt-x (or Esc,x) puts the cursor into what Emacs calls the “mini-buffer” at the bottom of the screen, where the user can execute thousands of built-in or user-defined LISP routines. For example, I could execute my lookat-file function by typing Alt-x lookat-file[ENTER]. (Emacs has tab completion just like bash or zsh, so in practice I would have typed Alt,x loo[TAB][ENTER], there being no other LISP function on my machine that starts with those three letters.)

Bottom Line

I use both editors regularly. Sometimes the choice is random, but for some tasks I will always use either Vi or Emacs.

  • Emacs GUI is much easier to use for large text jobs – writing the Great American Novel or whatever – and producing a “clean” file.
  • Vi TTY is always used for editing .rc files, producing quick-and-dirty scripts, etc.
  • I have extended Emacs to perform a couple of tasks that neither editor will do automatically in their virgin state.
  • Gvim is better integrated with Xwindows – easier “look and feel”, better fonts, better syntax highlighting, a button bar, etc. It looks very different from the TTY version, whereas the TTY and GUI versions of Emacs look very much the same, but some of that is because Emacs managed to implement a “pull-down” menu system in TTY mode!
  • Emacs is better at editing many files at once. It is simple, for example, to switch to a directory containing a programming project and say: emacs Makefile *.[ch] to edit the whole project at the same time. Both editors can issue the actual “make” from within the editor, capture and parse the error messages, and position the cursor on the correct line in the correct file.


    Useful Links

    My .emacs customization
    My .vimrc customization
    Vim Home Page
    Gnu Emacs Home Page
    Win32 Emacs precompiled binary
    Win32 Vim precompiled binaries You need files gvim70.exe and vim70d32.zip.
    Cygwin Unix Utilities for Win32 (rm, ls, egrep, etc.) Click on “Install Now”
    O’Reilly & Associates, publisher of full books and pocket references for both GNU Emacs and Vi (including Vim).
    New Riders, publisher of Vi Improved, by Steve Oualline.


    Last modified: Wed Apr 11 16:28:18 2007