4月25日工作心情感想

最近工作的范围主要是在后期的修改,以及美化工作。今天也出现一个难以解决的技术问题,明天得继续研究。

这几天,突然对 Nodejs 产生了兴趣。很久之前已看过,它是一个 server side Javascript 实现,是一种 event driven 的程序语言。它是单线程 (single threaded),同时允许 parallel task,及 event driven 调用的程序语言。我刚完成了我的第一个 Nodejs Hello World,并且是运行在 Amazon EC2 云计算服务上的,有兴趣的读者可以点击这里阅读我编写的 Step By Step 教程

这几天,读NUS的妹妹最近在考试,所以,看有空的话,过去Kajau一下吧。

这个星期我也设定了几个目标,一定要达到:
1. 迈出第一步 (40分)
2. 解决Project所有未知问题 (30分)
3. 设计一个简单的 iphone web apps, 使用 ajax / comet 技术,nodejs,架设在 Amazon EC2 上,并发布原始码。(15分)
4. 讲15句话。(15 分)

Hello world to Node.js on Amazon EC2

This post is all about my first hello world to Node.js runs on Amazon EC2. I will note down the steps on how to get through Amazon EC2, start an instance, and how to download and build Node.js on Amazon EC2, and runs a Hello World Example!

This post includes nearly complete steps from how to setup Amazon EC2 and setup Node.js, it is recommended for all level of readers who don’t know Node.js and Amazon EC2, but at least you need to know how to use Linux and have basic programming skills.

First of all, you need a credit card to apply Amazon EC2, assume you are using Windows, you need a Putty to access Amazon EC2 Linux Server instance, and Puttygen, to generate your private key files.

Next, navigate to https://console.aws.amazon.com, login with your Amazon EC2 account, sign in to AWS Management Console, and navigate to EC2 Tab.

Steps:

1. To launch an Amazon EC2 instance.

Click on “Launch Instance” on the top left just under My Instances panel.

image

Then select “Community AMIs”, type “nodejs” on the keyword box, an AMI with ID ami-a8ca37c1 is shown, and click “Select”.

image

Then for “Instance type”, choose “Micro” for free tier (not need to pay for 1 year), or you can use Small instance (1 hour $0.087), I chose Small instance.

image

Click “Continue” at the bottom to navigate to next steps. For “Advanced Instance Options”, we not need to choose, just click “Continue” again. And then you will come to a screen with key – value pairs. Normally we not need to bother also, but for convenience you can type key (name) value (nodejs) to help you organize, browse your created instances, like a Tag.

Click “Continue” you will come to screen to create keypair. OK, choose “Create a new Key Pair” if there is no existing key pairs created before. As shown below, you can enter a easy-remembered name for your key pair, for example, I write “fyhaokey2”, and then click “Create & Download your Key Pair”, you should get a “.pem” file. Save it at some convenient location.

image

Now, open your Puttygen, click on Load, remember to choose (All File Types), and then select your “.pem” file. And then, click “Save private key”, you will get your “.ppk” file. “.ppk” file will be used with Putty later which used in authentication when you log in to Amazon EC2.

image

Back to your AWS browser, click on “Continue”, you will come to the screen to configure a firewall. You can select “default” OR, to ensure port 22 and port 80 is enabled, and then click “Continue” further to finish the process create the instance.

Once back to the main screen, you will see your instance’s status is in pending mode, wait a minute, it will become running mode.

Next step, we need to apply for “Elastic IPs”, click on “Elastic IPs” at the bottom left of the screen.

image

Let’s allocate a new address, and associated with your just created EC2 instance. Once done, back to main screen by click on “Instances” on the left menu bar. Click on your instance, see below, you will got something like this:

image

Let’s ping your elastic IP see whether it is on or not. By the time you reading this post, my elastic IP (50.19.125.189) had been released, so that this IP address is disabled, you may try your own.

2. To use Putty to access our EC2 instance.

image

At host name, write your elastic IP address, port remained 22.

Then, click on left side under “Category”, click “SSH” and expand and click “Auth”. Then, at right side, for “Private key file for authentication”, you browse your “.ppk” file, and then click “Open” to open the session.

image

And then, login as “ec2-user”, then “sudo bash” to execute command on behalf of “ec2-user”.

image

3. To install Nodejs setup.

Then, come to this link: https://gist.github.com/579814, see the first sh command file.

node-and-npm-in-30-seconds.sh (As below)

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc

. ~/.bashrc

mkdir ~/local

mkdir ~/node-latest-install

cd ~/node-latest-install

curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1

./configure --prefix=~/local

make install # ok, fine, this step probably takes more than 30 seconds...

curl http://npmjs.org/install.sh | sh

Copy the contents, and execute it on your putty.

Wait for about 10 to 20 minutes, the nodejs will be installed completely.

4. To test our Hello World Nodejs !!!

OK, now we create a file called hello.js, with the content:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World Nodejs run on Amazon EC2 by fyhao\n');
}).listen(80);
console.log('Server running on Amazon EC2');

and then,

we execute this, by type:

node hello.js

Then, you should see the Putty console with the text “Server running on Amazon EC2”.

OK, last step, open your favorite browser (for me Google Chrome), navigate to your created Elastic IP address, you should see the plain text you have made in hello.js !!!

image

image

WOW, finally, we done the first hello world job.

Have a nice try!

Facebook Iphone Apps News Feed Not Responding

Recently my Facebook Iphone Apps news Feed is not responding, it always show “No Internet Connection” while I am in Internet Conection. I can use Facebook Messages, Place, Chat, Friends, but can’t use news feed feature.
I just found the workarounds by blog.dk.sg, the method is simple:

1) Go to Facebook app’s main page
2) Go to Account on the top left corner
3) Select Help Center
4) Login to your account (Remember to check “Keep me logged in”)

4月20日工作心情感想

In this post, I will write what technical stuff, work related I experienced, and my in-heart feeling throughout today. Today I will use English to touch about work related, but use Chinese to express my thoughts.

WOW, first hour in this morning I had implemented an interesting stuff, that is to build a simple cache manager in front of Dao (Dao Access Object) class. It is an in-memory model, the data will be kept in the server’s memory. Every cached data will have expired time, it will be automatically refreshed when the time is expired, moreover, when the insert / update / delete operation of specific Dao class is executed, the cache data associated with it will be refreshed automatically. The best thing is in current system framework can easily migrate to use this cache manager without having a big changes. The next step I should do is to create custom configuration setting for cache manager, or by using Annotation to realize auto configuration. OK, the benefits of Cache Manager is, the system is able to not query database everytime when need it but read from the cache directly, it should be able to increase application performance since database operation always eat up more resources. I just have make cache for certain parts of system that need cache, and any other places is not affected. I should continually to test it to know the real performance had brought by this changes.

At the time I feel boring in front of computer, I had researched Asynchronous Servlet 3.0 Proposal, it added some additional methods to existing Servlet 2.5 to handle asynchronous use cases, such as Ajax, or Comet (Reverse Ajax), or Streaming. I also thought if current system framework is able to integrate with this feature, and I need more research in order to make conclusion. In our company we use Tomcat, and I know Tomcat 6 had its own Comet Servlet implementation, but I am not sure if it is a standard or not, the better for us is following standard in order our system can be migrated to any type of web server. Now, Java EE 6 had supported Asynchronous Servlet 3.0 and had been released last year, and the best supporting web server is Glassfish, by using Glassfish you can easily deploy Java EE 6 and EJB 3.1 applications, furthermore, it supports what "modern browser" had supported, HTML5 WebSocket (bi-directional socket connection between server and browser client). Let’s try it if you interested.

Additional Links:

Introducing Java EE 6 Platform
Hello World(): EJB3 by NetBeans 6.8 and GlassFish v3 (Java EE 6)

For information, I had also briefly introduced cloud computing service I had used to my colleagues. But I am sorry I have no convey clear information when I am introducing. Now, here, to all readers, why cloud is your better choice?

I had used Google Appengine and Amazon Web Service before, even in my final year project during degree study, these two are the leading cloud computing service provider in the world. If you don’t know what is cloud computing, many information online had told you what this is. Many advantages brought from cloud, to enterprise and to individuals. In simple, the main advantage is to cut cost, pay on what you use; easy to scale up to more server instances in short time when your application needs it, and scale down when your application don’t need it; more secure (somebody may not agreed this, but theoritically to hack cloud is very hard in this stage).

In short, Google Appengine provides full stack infrastructure framework includes everything what you needs such as Google Datastore (a BigTable key-value data store implementation) that you can used to store data (like database) using JPA or JDO that you familiar or low-level API if you want to. It also provides Memcache, Image Service, Task Scheduling Service, Queue, Channel API (to make Comet Application). It provides free to use at first, you don’t need to pay single cent to run your first Hello World Google Appengine application, and only the time your application had brought in more bandwidth, meant that is the time you start to earn money, then you have to pay, just pay on what you use.

Amazon Web Service is another cloud computing service provider besides from Google Appengine. AWS provides many types of cloud service, such as Amazon EC2, Amazon Simple Storage Service, Amazon RDS, and many more. It provides lower level cloud infrastructure, therefore you need more knowledge to operate on.

By using Amazon EC2, it virtualizes a blank server for you, and you are able to install anything you want, just like a normal server you get from data centre. Second, it is pay on what you use, one hour just 0.085 US Dollar. You can run it in, say 3 hours, and closed it when you don’t want. Sometimes I want to test my web application, I just click click click in the user interface (or you can also use window command prompt) to access a Linux server instance and upload my applications and test, from my home, very convenient. I really not need to buy a Linux server keep in my home, waste my money, when I don’t want it, I can close it and return back, it will not charge me afterwards. EC2 has also provides an important feature called AMI (Amazon Machine Image). Meant, when you had headache to build up your web server, your database, and your applications, you can store the current setting into AMI, and then you close the EC2 server instance, AMI will be stored on Amazon S3. When you need it, you can just restart your application based on AMI you have made last time, you don’t need even to have another headache time to rebuild up your web server and cumbersome database. Some people had also created some setup and saves as public AMI and you can directly use their AMI to continue your own setup. You can also sell your created AMI in marketplace, or make it private, use by yourself. WOW… Additional information, EC2 provides full stack of real time monitoring feature, you can always easily know the performance or health of every part of your server.

EC2 is for computation, it cannot keep data last long. You should use Amazon S3, to store your static files. You are able to upload any static files, video, images, create folders on Amazon S3, and it provides a public URL for your friend to download. You can set different access permission to different folders, files, you had created. Same, pay based on what you use. Currently, I had used Amazon S3 for more than 700MB, and charged me 10 cents US Dollar each month. WOW, amazingly, so cheap. I used it to backup my company program code (I had backup in many places in case any accidents occurred) every days. I used it for private usage, and it should not be able for publicly viewed.

Who use Amazon Web Services? The fact is that part of the Facebook Photos using Amazon S3 to store their photos because Amazon S3 provides more stable and easy to use feature. Secondly, Second Life used Amazon EC2 to run their virtual 3D world instance. They can just focus on development of application logic but leaves the lower infrastructure to Amazon EC2.

Maybe our company should try cloud computing service (or maybe had already tried), but I am not sure if it is suitable, still need more research to make conclusion. Because I know the manager should have many problems regarding this: is it safe? is it really cut cost? is it suitable for us and customers and I can’t answer it clearly at this time.

Additional Links:

How to getting started with amazon EC2

完成了技术记录,接下来将是我的内心心情记录。我想,英文比较适合来写技术相关的感想,而中文则能比较好的表达我的内心心情。

今天偶然的被其他部门的同事询问了一个技术的解决方式,基本上,我对实现方法的可行性还没有可以接受的答案,将继续去研究。

今天前4个小时比较有上进心,因为实现了一个可以说有一点点成就感的东西。而后面4个小时则有点无聊,因为暂时找不到可以修改的东西,只能东看看西看看(检查code)。

之后,偶然的就和大伙们一起去吃饭。我还是踏不出那一步,打个招呼很难。天气很冷,一直发抖。我的发抖也不是因为冷的关系,而是和她同桌吃饭。当时我很紧张,当她降临的时候,我也只能,”东看看西看看”(抒发紧张感)。她对我应该没意思吧,我想,但我却对她有好感,只是不善于表达。这显得,我和其他人比起来很懦弱,是的,我的人际交流需要改进,在慢慢改进。尝试吧,fyhao,没什么好怕的(说得容易,做得难)。

加油吧!

4月19日简短感想

今天,主要还是继续开发剩余的部分,也已大致完成继昨天的一个开发设计失误而提出的新设计方案。

啊,今天没学到特别的技术,没什么成就感,一直在研究 iText 来设计 Table 的 线条。。。搞了4个小时多。它所支持的 HTML 的 CSS style 还不是很足够,幸好还能用 Java API 动态来篡改。

还有,要抽时间去问问 Singtel 关于月付的问题,及尝试申请 GIRO。看下个星期再去吧。

这个星期五是 Good Friday,可以休息多一天了。在新加坡,很难找到特别假期,在大马,什么时候都有假期。但是,假期,少一天,就少了一天工作,就少了一天可以见到她。

最近大家都很忙,忙着赶工,大家加油吧!

Anything about Java world happening recently

This posts touched anything happened in Java world recently. It involves some flash news, or some added discussions.

Twitter move from Ruby-on-rails to Java

Heard Twitter had recently changed their back end structure, by changing into Java server called Blender, and changing MYSQL database into real time search database called Lucene, and as a result Twitter search is 3 times faster than former. Ruby is still a good programming language for faster development for small and medium web application, however, traditional Java still bring benefits for larger web applications for its well-structured, higher scalability.

James Gosling Joined Google

Father of Java, James Gosling, recently left from Oracle, formerly Sun Microsystems, and joined Google in 28 May 2011.

Most people from industry thought the action of Oracle taken over Sun Microsystems is not clever, although they had succeeded for the process of taken over, but they lost some leaders from open source world, such as James Gosling (Father of Java), Tim Bray and Simon Phipps (Father of XML). They thought that the objective of Oracle taken over Sun Microsystems is to sue Google which violates Oracle’s Java patent, Google Android Dalvik VM. No doubt, Java is very important to Google, added Father of Java had joined Google, not only he can extend Java features and contribute his talents, but also helps Google to fight with Oracle on the Java patent war. Added James’s joining to Google will be also benefiting the continually opening of Java.

Java be the First on Tiobe Rank

Java is still be the first on Tiobe Rank for 10 years. C, always be the second popular than Java. People believed in long term, C#.net maybe the only programming language can fight with Java, what do you think? I am so opening and I loved C# also, same as how I love Java. People compared C#.net over Java, where C#.net had built in modern and advanced language features such as Lambda, or we said functional programming (although Java introduced Lambda on Java 7, but still cumbersome if compared with C#.net, maybe try Scala if you intend to.)

OK, why, Java always be the first? 8 reasons.

  1. It is free.
  2. It is cross-platform.
  3. It got strong supports from academic field.
  4. It is simpler language compared with C++, and C.
  5. Mature enterprise platform.
  6. Wireless mobile application.
  7. Java Community Process (JCP), an open organization for exchange information and comments for Java.
  8. Supports from open source organization and non-profit organization.

4月18日工作心情感想

4月18日,好日子,我大妹的生日,也是我母亲的母难纪念日,也是好日子。我的妹妹,祝你生日快乐!

OK,今天,我想说,我遇到的事情,我的看法,我未来的初步计划,对感情的想法,以及放一些简单的技术学习记录。

首先,今天我遇到了几个挫折,也遇到了几个好事。一连两三个挫折,但不说了,因为我不认为他们是个挫折,反而是成功之母,借镜。

好事就是:慢慢和圈子以外的人接触了、第一次深情演唱生日歌给我的妹妹(using webcam)、受到朋友的认可。

开场完毕,说回正题吧

最近遇到的事情,虽然和工作无关,还是想提一下。

最近我的一个朋友,最后一个学期,他的毕业Project,向他借来看了几张图。他给了我几个思考,分几点讲。第一点,他本是一个网页设计很强的人,学习速度很快,很有干劲的年轻人,可以认识他,是我的福气。他的设计思想,很体贴,很人性化,UED,让我学了很多,很多地方值得借鉴。第二点,他网页设计很强,而Back End数据库比较新手。但是从现在看来,他也有进步了。有干劲,我喜欢,他有很大的发展前景。

还有一个朋友,才18岁。网友,没见过他,但他发表过许多很出名的 Discuz 插件,我的站也用了他的插件。好了,他才18岁,但是网页设计也是很强,编写PHP Back End也是不错,都很有创意。他写的插件我很喜欢。他也是一个有干劲的人,看得出他一直在努力,做得更好。他现在也是一个 Web Hosting Provider,做得不错,大家可以去支持哦!

这两位朋友,值得关注!很想向他们学习,像他们一样。

说说未来初步计划。

新加坡是个居住,就业,做研究的好地方。据说,半年后,我就可以尝试申请新加坡的PR(Permanent Resident, 永久居民)了,可以去尝试,朝这个目标迈进。现在,我也要慢慢习惯这里的生活,慢慢实现定居计划。目前,我weekend都回大马,还没在这里度过weekend过。而且现在还不是很稳定,工作上,也还没度过试用期,这里的朋友虽然很多(来自大马,在这里读书),但是很少联络,没有比较可以依靠的朋友,除了妹妹和爸爸之外不说。简单来说,就是缺乏安全感。虽然,我是一个非常有自信的人,但是我走每一步都非常的小心。

但基本上,我的计划是,未来,有可能会继续就业,或继续升学做研究,以新加坡为基地,因为它提供了一个很好的环境,方便。

我希望 25岁能做一件大事,30岁,40岁再做到一些大事。大事,有可能是就业方面的(比如提高价值、知识,或许升职,或自行创业),也可能是学术方面的(比如升硕士博士,或做学术研究)

钱很重要,但是钱对我来说是排最后一位,愿景,目标,才是排第二位。排在第一位的是家人和朋友。没有他们的支持,实现了目标也是死的。

另外,说说下,关于我的行事风格吧。自从2009年年头开悟后,我的行事风格开始变得有规章了。我是个有自信的人,虽然我什么都不是,但是我始终相信,任何目标都能实现,只要你不放弃。第二,人生很多时候都要做选择,当我在做选择的时候,都是经过深思熟虑,减低走错路的几率,所以基本上我选择或认可的人事物,都不是随随便便出结论的。当我选择了一个人事物,我都不会随意更换,都会较长时间的坚持,因为我不随意否定我做出的选择。

我现在呢,就在做选择中。选择什么呢,选择我未来要走的路,现在要做的事情,该不该做什么。

接下来,我要谈谈大家最关心的议题:fyhao,再次暗恋了!我想说的是,爱一个人,不是占有,而是用心去体会,去关心。所以,交往?有没有机会,这些都不重要。但我想我也没有机会吧,我不帅,没才华,没资格,什么都不是,而她,却是完美的。

今天晚餐去吃炒米粉,啊,档口auntie说只剩一半了,还要吗,我想了1秒,还是决定要了。既然一路上都选择来吃炒米粉了,即使只有一丁点的机会,都会好好把握。

你或许会问:吃得饱吗?我说:我忠于我的第一个选择

关于这个议题,下一篇继续说吧。

最后,写了三个小时,睡觉前,补充一些技术性的东西,以做日后记录吧。

最近查看了 Oracle Java EE Certifications,发现,多了几个Certs可以考虑进修的。比如之前的 Sun Certified Web Component Developer (据 Oracle 官方所说,旧版 Sun Certs 还是受认可的,只是名字换掉而已,变成 Oracle Certified…)。 新版的有,”Oracle Certified Expert,Java Platform, Enterprise Edition 6 JavaServer Pages and Servlet Developer”,还有 EJB 和 Java Persistence 的,看来都不错,可以考虑进修升级,况且对目前的工作肯定也有帮助。

同事也介绍了一个叫做 Virtualbox 的东西,装在 Linux Server 里,就可以往里面装 Mac OS, Windows 了,非常不错的东西。

另外,还有一个 logmein 的网站,可以注册电脑上去,然后可以在任何地方 remote log in 那个电脑,学习。

OK,这篇文章终于写完了,to be continued….