Ai đã từng đọc Tuổi Trẻ Cười chắc chắn sẽ đều biết đến chuyên mục "Cái gì đây kỳ này?" của anh Hai Cù Nèo. Những dòng dẫn dắt ngắn gọn, hài hước, trào phúng nhưng vẫn đưa người đọc đến đoạn... ngồi đần ra rồi bỗng ngoạc miệng cười "Ha ha...".
Nhưng giờ là chuyện nghiêm túc đây, có cười gì thì cười đi rồi nghiêm chỉnh nào.
Hôm nay tớ làm bún đậu phụ mắm tôm.
Đêm qua ngủ tít mù đến gần 1h trưa mới thèm mò dậy. Bắt tay vào thực hiện kế hoạch nào (tớ định làm từ tuần trước nhưng vướng công việc nên đành lui lại). Bún có rồi, bún khô thôi, hôm trước đã nhờ anh H. mua hộ. Mắm tôm nữa chứ. Công đoạn phức tạp nhất là mua đậu về rán :-D
Kì cục đến gần 2h mới xong nhưng còn làm một số thứ việc nữa nên giờ mới chuẩn bị măm.
Hãy cùng chiêm ngưỡng tác phẩm của tớ nào.
Giờ tớ măm đây, mọi người chúc tớ ngon miệng nào. Cuộc đời đẹp làm sao ;-)
PS: Honey, khi em đọc được bài này thì anh đã măm xong rồi. Đừng trách anh ko mời nhé, ăn mảnh đấy :-P
Sunday, October 29, 2006
Saturday, October 28, 2006
IoC pattern
IoC (Inversion of Control) pattern is a very popular pattern in Java world. It is used in J2EE, Spring, WebWork,... Maybe you don't figure out what is meaning of inversion of control, but actually it's very simple.
To explain inversion of control, we see active and passive actions. In active actions, I say "I'm going to get object X". And in passive actions, I say "Give me object X when I need it". Please see this example, here I implement an action in WebWork, it needs to retrieve a request object to set an attribute.
Active way
Passive way (applied IoC pattern)
Here ServletRequestAware interface only defines setServletRequest(ServletRequest).
When using IoC pattern, you can reduce the works you need to do in a class by moving some implementation outside. Also it makes your class more clearly.
To explain inversion of control, we see active and passive actions. In active actions, I say "I'm going to get object X". And in passive actions, I say "Give me object X when I need it". Please see this example, here I implement an action in WebWork, it needs to retrieve a request object to set an attribute.
Active way
public class SetBlahAction implements Action {
public String execute() {
HttpServletRequest request =
ServletActionContext.getHttpServletRequest();
request.setAttribute("blah", "blah");
return SUCCESS;
}
}
Passive way (applied IoC pattern)
public class SetBlahAction implements Action, ServletRequestAware {
private ServletRequest request;
public void setServletRequest(ServletRequest request) {
this.request = request;
}
public String execute() {
request.setAttribute("blah", "blah");
return SUCCESS;
}
}
Here ServletRequestAware interface only defines setServletRequest(ServletRequest).
When using IoC pattern, you can reduce the works you need to do in a class by moving some implementation outside. Also it makes your class more clearly.
Friday, October 27, 2006
Integrate Tomcat 6 to Apache 2 with mod_jk
Requirements
+ JDK 1.5 or later (http://java.sun.com/javase/downloads/index.jsp - Tomcat 6 cannot run with JDK before 1.5)
+ Apache 2 (http://ftp.apache-kr.org/httpd/binaries/win32/ - already setup and run)
+ mod_jk (http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/)
+ and of course, Tomcat 6 (http://tomcat.apache.org/download-60.cgi)
Our Configuration
+ Java JDK path : C:\jdk1.5.0_09
+ Apache path : C:\www\Apache2
+ Tomcat path : C:\www\Tomcat6
+ Apache's webroot : C:\www\webroot
+ JSP/Servlet webroot (via Apache2/mod_jk) : C:\www\Tomcat6\webapps
+ JSP/Servlet webroot (via native Tomcat server, port 8080) : C:\www\Tomcat6\webapps
+ Access JSP/Servlet pages via Apache2/mod_jk : http://localhost/[jkmount-mapped url of your webapp]
+ Access native Tomcat server : http://localhost:8080/
Install JDK
+ Run file jdk-1_5_0_09-windows-i586-p.exe to install under your %SystemDrive% (C:\), forming C:\jdk1.5.0_09
Unpack and place Tomcat6 and mod_jk
+ Unpack file apache-tomcat-6.0.0.zip under directory C:\www
+ Rename directory C:\www\apache-tomcat-6.0.0 to C:\www\Tomcat6
+ Rename file mod_jk-apache-2.x.xx.so to mod_jk.so, and place under directory C:\www\Apache2\modules
Configuration and Setup
+ Set Environmental Variables : JAVA_HOME=C:\jdk1.5.0_09 and CATALINA_HOME=C:\www\Tomcat6
+ Create empty file C:\www\Apache2\conf\workers.properties, insert code...
+ Edit file C:\www\Apache2\conf\httpd.conf, insert code...
+ Edit file C:\www\Tomcat6\conf\tomcat-users.xml, insert lines...
Install and Start Tomcat
Tomcat can be installed as a Service or started as a Standalone Console application. Note to make sure that Apache has been started at this point.
As a service
+ Open the command-line prompt (Start » Run... cmd.exe)
C:\www\Tomcat6\bin> service.bat install
...> NET START Tomcat6
+ To shutdown the Tomcat Service : ...> NET STOP Tomcat6
+ To remove/uninstall the Tomcat Service : C:\www\Tomcat6\bin> service.bat remove
As a standalone console application
+ Open the Command-Shell (Start » Run: cmd.exe), change to dir C:\www\Tomcat6\bin...
Run file startup.bat to start Tomcat
Run file shutdown to shutdown Tomcat
Testing
+ Test the native Tomcat server...
http://localhost:8080/
http://localhost:8080/manager/status -- User:manager, Password:manager
+ Test Apache/mod_jk...
http://localhost/examples/jsp/
http://localhost/examples/servlets/
+ JDK 1.5 or later (http://java.sun.com/javase/downloads/index.jsp - Tomcat 6 cannot run with JDK before 1.5)
+ Apache 2 (http://ftp.apache-kr.org/httpd/binaries/win32/ - already setup and run)
+ mod_jk (http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/)
+ and of course, Tomcat 6 (http://tomcat.apache.org/download-60.cgi)
Our Configuration
+ Java JDK path : C:\jdk1.5.0_09
+ Apache path : C:\www\Apache2
+ Tomcat path : C:\www\Tomcat6
+ Apache's webroot : C:\www\webroot
+ JSP/Servlet webroot (via Apache2/mod_jk) : C:\www\Tomcat6\webapps
+ JSP/Servlet webroot (via native Tomcat server, port 8080) : C:\www\Tomcat6\webapps
+ Access JSP/Servlet pages via Apache2/mod_jk : http://localhost/[jkmount-mapped url of your webapp]
+ Access native Tomcat server : http://localhost:8080/
Install JDK
+ Run file jdk-1_5_0_09-windows-i586-p.exe to install under your %SystemDrive% (C:\), forming C:\jdk1.5.0_09
Unpack and place Tomcat6 and mod_jk
+ Unpack file apache-tomcat-6.0.0.zip under directory C:\www
+ Rename directory C:\www\apache-tomcat-6.0.0 to C:\www\Tomcat6
+ Rename file mod_jk-apache-2.x.xx.so to mod_jk.so, and place under directory C:\www\Apache2\modules
Configuration and Setup
+ Set Environmental Variables : JAVA_HOME=C:\jdk1.5.0_09 and CATALINA_HOME=C:\www\Tomcat6
+ Create empty file C:\www\Apache2\conf\workers.properties, insert code...
workers.tomcat_home=C:/www/Tomcat6
workers.java_home=C:/jdk1.5.0_09
ps=\
# Define worker 'example'
worker.list=example
# Set properties for worker 'example' (ajp13)
worker.example.type=ajp13
worker.example.host=localhost
worker.example.port=8009
worker.example.cachesize=10
worker.example.cache_timeout=600
worker.example.socket_keepalive=1
worker.example.reclycle_timeout=300
+ Edit file C:\www\Apache2\conf\httpd.conf, insert code...
LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
Alias /examples "C:/www/Tomcat6/webapps/examples/"
<Directory "C:/www/Tomcat6/webapps/examples/">
Options Indexes +FollowSymLinks
AllowOverride None
Allow from all
</Directory>
<Location /*/WEB-INF/*>
AllowOverride None
deny from all
</Location>
JkMount /examples/jsp/*.jsp example
JkMount /examples/servlets/* example
</IfModule>
+ Edit file C:\www\Tomcat6\conf\tomcat-users.xml, insert lines...
<role rolename="manager"/>
<user username="manager" password="manager" roles="manager"/>
Install and Start Tomcat
Tomcat can be installed as a Service or started as a Standalone Console application. Note to make sure that Apache has been started at this point.
As a service
+ Open the command-line prompt (Start » Run... cmd.exe)
C:\www\Tomcat6\bin> service.bat install
...> NET START Tomcat6
+ To shutdown the Tomcat Service : ...> NET STOP Tomcat6
+ To remove/uninstall the Tomcat Service : C:\www\Tomcat6\bin> service.bat remove
As a standalone console application
+ Open the Command-Shell (Start » Run: cmd.exe), change to dir C:\www\Tomcat6\bin...
Run file startup.bat to start Tomcat
Run file shutdown to shutdown Tomcat
Testing
+ Test the native Tomcat server...
http://localhost:8080/
http://localhost:8080/manager/status -- User:manager, Password:manager
+ Test Apache/mod_jk...
http://localhost/examples/jsp/
http://localhost/examples/servlets/
Saturday, October 14, 2006
Welcome to t800t8.net
I've just finished to set up my web site at t800t8.net. Take your free time to visit it :-)
Friday, October 13, 2006
Google Code Search 1.1.0 is released
Tuesday, October 10, 2006
Google Code Search updates to v1.0.1
New features: Added supports for C and C++
You can find out more here.
I'm considering new feature for v1.1. Google Code Search should support to find source code at caret for specified language (depends on type of file which is opening in editor) when user presses a shortcut key (example: Ctrl + Alt + G). Seems I need to create another action for this feature.
What do you think about this? Any suggestion and feedback are welcome :-)
Update: I'm not familiar with Ruby and Python. Seems Ruby source code only has RB extension, and for Python is PY. Are there any more extensions for these languages? Thanks
You can find out more here.
I'm considering new feature for v1.1. Google Code Search should support to find source code at caret for specified language (depends on type of file which is opening in editor) when user presses a shortcut key (example: Ctrl + Alt + G). Seems I need to create another action for this feature.
What do you think about this? Any suggestion and feedback are welcome :-)
Update: I'm not familiar with Ruby and Python. Seems Ruby source code only has RB extension, and for Python is PY. Are there any more extensions for these languages? Thanks
Sunday, October 08, 2006
Rockstar
Nickelback
I'm through with standing in line
to the clubs i'll never get in
It's like the bottom of the ninth
and I'm never gonna win
This life hasn't turned out
quite the way I want it to be
(Tell me what you want)
I want a brand new house
on an episode of Cribs
And a bathroom I can play baseball in
And a king size tub big enough
for ten plus me
(so what you need)
I'll need a, a credit card that's got no limit
And a big black jet with a bedroom in it
Gonna join the mile high club
At thirty-seven thousand feet
(Been there done that)
I want a new tour bus full of old guitars
And my own star on Hollywood Boulevard
Somewhere between Cher and
James Dean is fine for me
(So how ya gonna do it?)
I'm gonna trade this life for fortune and fame
I'd even cut my hair and change my name
[CHORUS]
'Cause we all just wanna be big rockstars
Living in hilltop houses driving fifteen cars
The girls come easy and the drugs come cheap
We'll all stay skinny 'as we just won't eat
And we'll hang out in the coolest bars
In the VIP with the movie stars
Every good gold digger's
Gonna wind up there
Every Playboy bunny
With the bleach blond hair
and well..
Hey hey I wanna be a rockstar
Hey hey I wanna be a rockstar
I wanna be great like Elvis without the tassels
Hire eight body guards that love to beat up assholes
Sign a couple autographs
So I can eat my meals for free
(I'll have a quesadilla haha)
I'm gonna dress my ass
with the latest fashion
Get a front door key to the Playboy mansion
Gonna date a centerfold that loves to
blow my money for me
(So how ya gonna do it?)
I'm gonna trade this life
For fortune and fame
I'd even cut my hair
And change my name
'Cause we all just wanna be big rockstars
Living in hilltop houses driving fifteen cars
The girls come easy and the drugs come cheap
We'll all stay skinny 'as we just won't eat
And we'll hang out in the coolest bars
In the VIP with the movie stars
Every good gold digger's
Gonna wind up there
Every Playboy bunny
With the bleach blond hair
And we'll hide out in the private rooms
With the latest dictionary and
TV's who's who
We'll get you anything
with that evil smile
Everybody's got a
drug dealer on speed dial
well..
Hey hey I wanna be a rockstar
I'm gonna sing those songs
that offend the censors
Gonna pop my pills
from a pez dispenser
Get washed-up singers writing all my songs
Lip sync 'em every night so I don't get 'em wrong
Well we all just wanna be big rockstars
Living in hilltop houses driving fifteen cars
The girls come easy and the drugs come cheap
We'll all stay skinny 'as we just won't eat
And we'll hang out in the coolest bars
In the VIP with the movie stars
Every good gold digger's
Gonna wind up there
Every Playboy bunny
With the bleach blond hair
And we'll hide out in the private rooms
With the latest dictionary and
TV's who's who
We'll get you anything
with that evil smile
Everybody's got a
drug dealer on speed dial well..
Hey hey I wanna be a rockstar
Hey hey I wanna be a rockstar
Saturday, October 07, 2006
Google Code Search 1.0 is released
Google released code search service, and now I release Google Code Search 1.0, an IntelliJ IDEA's plugin supports users to search source code via Google's code search.
For more information, you can see here.
Update: Batch Generator is downloaded over 200 times :-)
For more information, you can see here.
Update: Batch Generator is downloaded over 200 times :-)
Monday, October 02, 2006
IntelliJ IDEA 6 is released
Time after time, and now time is came, IntelliJ IDEA 6 is released. JetBrains spent many resource to born a new version of IDEA. IDEA 6 has many new features to provide more powerful to developers who want to create more productive software.
I followed the road JetBrains created IDEA 6 from the first EAP. I knew that JetBrains met many problems during that journey with many users' blames and complains. And the lesson I learned from it is "Listen to the users but under pressure you must always follow your own way".
Congratulation, JetBrains! Congratulation, developers! Development with pleasure is here!
Update: At the same time, JetBrains released version 1.0 of Team City, an integrated team environment.
I followed the road JetBrains created IDEA 6 from the first EAP. I knew that JetBrains met many problems during that journey with many users' blames and complains. And the lesson I learned from it is "Listen to the users but under pressure you must always follow your own way".
Congratulation, JetBrains! Congratulation, developers! Development with pleasure is here!
Update: At the same time, JetBrains released version 1.0 of Team City, an integrated team environment.
Subscribe to:
Posts (Atom)