Friday, May 27, 2011

How to project the screen of iPad or iPhone to the projector

I have investigated this issue for several months, and finally come to a good solution.

1. The first simple solution without paying any money is to do it on the programming level: you can capture the screen image of the iPhone inside your app, so this is the clue that you can use to first take the screen shot and send it via TCP network connection to a remote computer which can show the screen image. You can use the following code to capture the screen and convert the image to jpeg format. Of course you should use asynchronize TCP connection to send the image data, otherwise the user interface of your app will stop working for some time while sending the image. On the remote computer, you also need to build an application which first listens to a port of the computer, and then receives an image and displays it.
// Capture Screenshot
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImageJPEGRepresentation(screenshotImage,self.jpegCompressionRate);
NSUInteger len=[data length];

2. another solution is to use the Apple VGA cable:
http://store.apple.com/sg/product/MC552ZM/B?fnode=MTc0MjU4NjE&mco=MjEzNTM1NjI
, together with the TVOutManager as described on the following web page:
http://www.touchcentric.com/blog/archives/123
The steps of using this TVOutManager are quite clear and simple.

I first used the TVOutManager in my app on iPhone, and it works really very well.
I then used it in my app on iPad, and unfortunately it slowed down my app.
I guess the reason is that the TVOutManager needs lots of computing power to show the screen.
After investigating for a long time, I finally found the way: in the source file TVOutManager.m, you can find two lines:
// #define USE_UIGETSCREENIMAGE
// CGImageRef UIGetScreenImage();
, and you just need to let the two lines work. As a result, your app will work much faster.


3. in fact the Apple VGA cable can directly project the real-time screen output of iPad 2 to the projector, but can only show the video and pictures for the iPhone 4 or iPad 1. If you have iPad 2, then you just need to buy the cable to project anything to the projector.

Wednesday, May 18, 2011

哈尔滨工业大学新加坡校友会召集信

亲爱的哈尔滨工业大学校友:

我们在此发起成立哈工大新加坡校友会的号召。
事缘五月初中国教育展在新加坡举行,哈工大也来参展,几位校友不约而同询问哈工大人在新加坡有没有校友会。答案是否定的。随后大家通过网络相互联系,反响积极在意料之中,但热烈程度却是意料之外。显然,开始筹备并成立正式的校友会,时机已经成熟。
哈工大的发展令人瞩目,秉持“规格严格,功夫到家”的校训,哈工大人在世界各地踏实努力地工作。在新加坡,留学、工作的校友数以千计,成立校友会迫在眉 睫。校友会的正式成立有利于我们与母校保持联系,及时了解哈工大的发展动态,并为母校献计献策;通过校友会,我们也可加强相互之间的联系,有利于事业发 展,又可为社会做出更大贡献。校友会将举办各种活动,丰富我们的社交生活,并提供各种支援和帮助。当然,我们也会与世界各地的哈工大校友会及其它高校的校 友会保持联系。
总而言之,成立哈工大新加坡校友会有利于在新加坡及其它地区的哈工大人,有利于哈工大,也有利于新加坡社会和新中友谊。我们随时欢迎您加入哈工大新加坡校友会,请大家相互转告或转发此信息:

1. 校友信息登记
哈工大在新加坡的校友,请尽快在如下网址登记信息:
http://bit.ly/hitsingapore
2. 如果您有任何建议或愿义务参与校友会的筹备工作,请发邮件至以下邮箱:hitaas@gmail.com

哈尔滨工业大学新加坡校友会期待您的加入!

哈尔滨工业大学新加坡校友会临时筹备小组
2011年5月18日

Saturday, May 14, 2011

新加坡 哈尔滨工业大学(哈工大)校友召集 ( HIT alumni association in singapore )

Hi 大家好,

我们正在联合在新加坡的哈工大校友,准备组建哈工大新加坡校友会,HITAAS(HIT Alumni Association in Singapore),我们已经建立了一个Google group,hitsingapore@googlegroups.com,希望大家可以加入,有什么关于建立校友会的信息也会在这个google group里面发布。加入这个group后,所有的信息就会直接发到你的email帐户。谢谢大家支持!

加入方法:
您只需要用你的email帐户(最好是私人的固定email帐户)发一个email到
hitsingapore+subscribe@googlegroups.com
管理员就可以看到你申请加入这个group了。

如果您遇到什么问题,请发email与hitaas@gmail.com联系。

再次感谢大家的支持!

HITAAS

Wednesday, May 4, 2011

Latex: how to control the column width of a table

Latex will automatically adjust the width of a cell in a table, but it will not consider the width of the page, so sometimes parts of the table are out of the page. If you want to control the column width of a table, you may want to use p option instead of l, c or r for left, center or right alignment.


For example:


\begin{table}[ht]
\centering
\begin{tabular}{|c|p{2cm}|p{1cm}|}
\hline
a & bb & c\\
\hline
\end{tabular}
\end{table}

Good luck!

Wednesday, April 20, 2011

How to add a new metric to ZMERT

1. you need to download ZMERT from its official homepage:
http://www.cs.jhu.edu/~ozaidan/zmert/

2. decompress the zip file that you just downloaded:
unzip zmert_v1.50.zip

3. you can find the jar file (zmert.jar) in the ./lib directory

4. extract zmert.jar content by using command:
jar xf zmert.jar

5. following the video: http://www.youtube.com/watch?v=Yr56pD8bTUc&fmt=18
to add new metric java file

6. after adding the new metric java source file, you need to recompile the java files:
javac *.java

7. the last step is to create a new version of zmert.jar by typing:
jar cvfM zmert.jar *.java* *.class

Tuesday, April 12, 2011

Python Repeatable Timer Example

def hello():
print "hello, world"
global t
t = Timer(3.0, hello)
t.start()

t = Timer(3.0, hello)
t.start() # after 3 seconds, "hello, world" will be printed

Sunday, February 20, 2011

VIM keyboard shotcuts

vim file +54
open file and go to line 54 any : command can be run using + on command line

vim -O file1 file2

open file1 and file2 side by side


:qa close all windows add trailing ! to force

undo/redo
u undo
Ctrl+r redo
. repeat

navigation
gg Goto start of file
G Goto end of file

search/replace
/regexp searches forwards for regexp ? reverses direction
n repeat previous search N reverses direction
* searches forward for word under cursor # reverses direction
:%s/1/2/gc search for regexp 1 and replace with 2 in file c = confirm change
:s/1/2/g search for regexp 1 and replace with 2 in (visual) selection
:%s/
^[\ \t]*\n//g # replace all the empty lines
:5,12s/foo/bar/g # changes each 'foo' to 'bar' for all lines between line 5 and line 12.
:.,$s/foo/bar/g # changes each 'foo' to 'bar' for all lines between the current line (.) and the last line ($).

windows

:e set buffer for current window you can optionally specify a new file or existing buffer number (#3 for e.g.). Note if you specify a directory a file browser is started. E.g. :e . will start the browser in the current directory (which can be changed with the :cd command).
:sp new window above ditto
:vs new window to left ditto
:q close current window
:qa close all windows add trailing ! to force
Ctrl+w {left,right,up,down} move to window
Ctrl+w Ctrl+w toggle window focus
Ctrl+w = autosize windows to new terminal size for e.g.
:ba new window for all buffers ":vert ba" tiles windows vertically