Thứ Tư, 30 tháng 12, 2009

Android: Native Android Action

Native Android Action

Native Android applications allow Intents to launch Activities and Sub-Activities.
Actions list:
=> + content://contacts/people/1 -- Display information about the person whose identifier is "1".
=> + content://contacts/people/ -- Display a list of people, which the user can browse through.
=> +tel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI. => +content://contacts/people/1 -- Display the phone dialer with the person filled in.
=> +tel:123 -- Display the phone dialer with the given number filled in.

Thứ Ba, 29 tháng 12, 2009

Android: SharedPreferences

Shared Preferences
SharedPreferences let you save groups of key/value pairs of primitive data as named preferences. SharedPreferences is a lightweight mechanism to store a known set of values such as: user preferences, configuration, application settings...
The data which had created by SharedPreferences can be shared between applicaton components running in the same "Context".
Creating and Saving SharePreferences

//Define SharePreference Name
private static final String STRING_SHAREREF_NAME_USERREF = "USER REFERENCES";
//SharedPreferences object
private SharedPreferences mShareRefs = null;
//Create and save
protected void savePreferences() {
//get value from ui
boolean bAutoUpdate = mCbxAutoUpdate.isChecked();
int iFrequency = mSpinnerFrequency.getSelectedItemPosition();
int iMinMag = mSpinnerMinMagtitude.getSelectedItemPosition();

//Create SharedPreferences object
mShareRefs = getSharedPreferences(STRING_SHAREREF_NAME_USERREF,
Activity.MODE_PRIVATE);

//update to Preference by editor interface.
Editor editor = mShareRefs.edit();
editor.putBoolean(STRING_SHAREREF_USERREF_AUTOUPDATE, bAutoUpdate);
editor.putInt(STRING_SHAREREF_USERREF_FREQUENCYUPDATE, iFrequency);
editor.putInt(STRING_SHAREREF_USERREF_MINMAG, iMinMag);
editor.commit();
}
Notes:
- If you want to save information that doesn't need to be shared with others component, you can call Activity.getPreferences(Mode) without a specifying preference name.
(Activity).getPreferences(Activity.MODE_PRIVATE);

Retrieve the saved values:
SharedPreferences object offers some method to get persist data (type boolean, String, int, Long, ..):
  • getBoolean(..);
  • getInt(..);
  • getString(..);
  • ...


Ref:
- Pro Android June 2009
- Profession Android Application Development.

Android: Services

Because of the limited screen size of the mobile devices, typically only one application is visible and activate on device screen at any given time. Android offers Service class to create application components specifically to handle operation and functionality that should run silently, without a UserInterface. Android Services is higher priority than an inactive Activity, so they're less likely to be killed when the system requires resources. By using Service, you can ensure that applications continuous to run and response to events, even when they're inactive.

Android offers several techniques for application to communicate with users with an Activity providing a direct UserInterface, for ex: Notifications, Toast.
  • Toasts are a transient, non-modal Dialog-box mechanism used to display information to users without stealing focus from the active application.
  • Notifications represent a more robust mechanism for alerting users. Many users, when they're not actively using their mobile phones, they sit silent and unwatched in pocket or on a desk until it rings, vibrates or flashes. Should a user miss these alerts. This case, status bar icons are used to indicate that an event has occurred. All of these attention-grabbing antics are available within Android as Notifications.
  • Alarms provide a mechanism for fi ring Intents at set times, outside the control of your application lifecycle. An Alarm will fire even after its owner application has been closed, and can (if required) wake a device from sleep.
If your application regularly, or continuously, performs actions that don't depend directly from a user input, Services my be the answer. Start Service receive higher priority than inactive or invisible Activity, making them less likely to be terminated by run time's resource management. The only time Android will stop a Service prematurely is when it’s the only way for a foreground Activity to gain required resources; if that happens, your Service will be restarted automatically when resources become available.

Creating and Controlling Service
Services is extended from Service base class. Services are designed to run in the background, so they need to be started, stopped and controlled by other application component.

Notes:
- Once you've contructed a new Service, you have to register it in the application manifest file within the service tag:
...

(... to be continuous...)


Ref:
- Pro Android June 2009
- Profession Android Application Development.

Thứ Hai, 28 tháng 12, 2009

Android: Http Connection

This time, I'm going to building a service in Android. There are a lot of types of services with Android included: IPC (communication between applications on the same device), get resources outside the devices by various type of connections. I'll focus on Http connection first.
Although Android included web-browser application in the basic applications, but there are several benefits to creating thick and thin native application rather than relying on entirely web-base:
- Bandwidth
- Caching
- Native features.
With currently connection methods:
- GPRS, EDGE, 3G.
- Wi-Fi.
more details could collected from reference books below.

Connection permission for Android application
By Eclipse ADT plug-in:
- Open AndroidManifest.xml file (in design mode)
- Select "Permissions" tab ==> click "Add" and select "Uses permission"
- At the "Name" property, select "android.permission.INTERNET"
- Save setting.

By XML editor:
- Open AndroidManifest.xml file (in editor mode)
- Add below code:
Open an URL connection and get content:

public static String getHttpContent(String prURL) {
String strResult = "";
StringBuffer sbfResult = new StringBuffer();
String newline = System.getProperty("line.seperator");

try {
URL url = new URL(prURL);
URLConnection urlcon = url.openConnection();
HttpURLConnection httpurlcon = (HttpURLConnection) urlcon;

int responseCode = httpurlcon.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpurlcon.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line = "";
while ((line = br.readLine()) != null) {
sbfResult.append(line).append(newline);
}
br.close();
in.close();
}
} catch (Exception e) {
sbfResult.append(e.getMessage()).append(newline);
}finally{
if (sbfResult != null) {
strResult = sbfResult.toString();
}else{
strResult = "StringBuffer has failed.";
}
}
return strResult;
}
}

Referenced:
- Pro Android June 2009
- Profession Android Application Development.

Thứ Năm, 24 tháng 12, 2009

Android: Overridable functions in Application's lifecycle

onSaveInstanceState
onSaveInstanceState() is called by Android if the Activity is being stopped and may be killed before it is resumed! This means it should store any state necessary to re-initialize to the same condition when the Activity is restarted. It is the counterpart to the onCreate() method, and in fact the savedInstanceState Bundle passed in to onCreate() is the same Bundle that you construct as outState in the onSaveInstanceState() method.

Thứ Tư, 23 tháng 12, 2009

Android: Introduction

What is Android ?
q
Is a Platform:
  • §Built on Linux kernel.
  • §For open handset devices.
  • §Open-source libraries for Web, SQLLite, OpenGL, SSL,…
Also included Middle-ware
  • §Base on C/C++ Linux kernel.
  • §Fully support for Java developer (by JNI).
  • §Use XML for flexible UI and Effect definition.
And is Key Applications with Android Software Stack
  • §Have a lot of applications fully support for PIM. (Contacts, Calendar, Phone, SMS Manager, Browser, Player, ..)

Android Application Software Stack
Slide 4
-
Linux Kernel 2.6 -Set of C/C++ open-source libraries had been converted to Java protocol for Java developer. -Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications -Android runtime with multi Dalvik VM instances and GC,.. Each Android Application (process) have it own Dalvik VM. -Application Framework: include so many services for management: - Content Providers: share data between components or applications. - Activity Manager: manages the lifecycle of applications and provides a common navigation back stack. (based on Android Software Stack) - Window Manager: - View System: Create interfaces for user. - Package Manager: manage installed applications, packages, librabries. - Telephony Manager: Phone’s services. - Resource Manager: providing access to non-code resources (strings, graphics, and layout files) - Location Manager: - Notification Manager: display custom alerts in the status bar. -APIs (JDK or NDK) for fully interacted with services and devices.
The Dalvik Virtual Machine
The Dalvik VM is a registered-base virtual machine. It is optimized for low memory requirements, and is designed to allow for multiple VM instances to run at once, relying on underlying operating system for process isolating, memory management and threading support. Dalvik use .dex files format:
A dx tool will compile Java class files to. dex file format. Multi classes are included in one .dex file, alls duplicate string or resource will be reduced for smallest size. Java byte codes are also converted into a alternative instruction set used by Dalvik VM. Dalvik executables may be modified again when they get installed onto a device.
Dalvik VM was slimmed down to use less space. Dalvik has modified constant pool to use only 32-bit indexes to simplify the interpreter. Dalvik VM use it own byte code, not Java byte code. The name “Dalvik” is belong to the name of a village in Iceland where Dan Bornstein’s ancestors lived. -The executable code on Android, as a result in Dalvik VM, is based not on Java byte code, but on .dex files format instead. -The java compiled class or .jar standard executable file are not compatible with Android. Why no “JIT” : Google has fine-tuned the garbage collection in the Dalvik VM, but it has chosen to omit a just-in-time (JIT) compiler, in this release at least. The company can justify this choice because many of Android’s core libraries, including the graphics libraries, are implemented in C and C++. For example, the Java graphics APIs are actually thin wrapper classes around the native code using the Java Native Interface (JNI). Similarly, Android provides an optimized C-based native library to access the SQLite database, but this library is encapsulated in a higher-level Java API. Because most of the core code is in C and C++, Google reasoned that the impact of JIT compilation would not be significant.

Thứ Năm, 17 tháng 12, 2009

Android: Error on missing resource

Now in Android - Eclipse IDE technique.
Have you ever got into an error like:

""is missing required source folder: 'gen'"
or this pic:


On Eclipse IDE, just right click and delete "gen" folder in your Package Explorer and Build project again. Got that ?

Gook luck,

Thứ Năm, 10 tháng 12, 2009

How to create a certificate with "makekeys"

Duty:
Create a self-sign certificate to sign on MIDlet, Symbian apps, Applet, .Net appls, ..

Resource: makekeys.exe executable file

Command:
%prompt%>makekeys -expdays 3650 -cert -password yourpassword -len 2048 -dname "CN=CertificateName OU=OrganizationUnit OR=ORganization CO=COuntry EM=yourEMail@now
here.com" keyfilename.key certificatefilename.cer


Result:
Reference from Symbian.com

Good luck!!

Thứ Ba, 8 tháng 12, 2009

Symbian - Carbide: Compilation Fails: Bareword Found Where Operator Expected (Wrong Active Perl version)

Compilation Fails: Bareword Found Where Operator Expected

Problem: When compiling an application, the process fails. The Problems view of Carbide.c++ reports that a .hlp.hrh file cannot be opened. In the Console view, problems with a Perl script are obvious (params.pm).

.hlp.hrh file cannot be opened
Problems with the perl script

Cause: The version of Perl on your system is newer than 5.6.x. The Symbian OS toolchain is not fully compatible to the 5.8.x/5.10.x release – you will probably not notice it for most projects, but, for example, compiling help files does not work with ActivePerl 5.8/5.10.

Solution: Either install Perl 5.6.1 , or follow the steps at http://wiki.forum.nokia.com/index.php/KIS001302_-_Compiling_context-sensitive_help_fails_with_latest_version_of_Perl:

Go to your SDK installation's "Epoc32\tools\perllib" path:

- Open file args.pm, change the following line (# 688)

$self->_iSpecArray->{$aName}= New CArgsSpec($aName, $aDefault, $aPattern,
$aExclusions, $aMandatory, $aRepeatable);

to

$self->_iSpecArray->{$aName}= CArgsSpec->New($aName, $aDefault, $aPattern,
$aExclusions, $aMandatory, $aRepeatable);

- Open file params.pm, search for the word "New" and replace it with "foo->New()"; for example, if there is a function "New CLogs()".

Reference from Developer.Symbian.com and Wiki.forum.nokia.com

Thứ Hai, 9 tháng 11, 2009

Thứ Ba, 7 tháng 7, 2009

Bonus Games: Free Popcap games

Hôm nay được người bạn chỉ cách free-time các game con con popcap chơi giải trí. Mình phải lưu lại để nhớ chứ hông quên mất.
Bước 1: Bật thuộc tính show hidden files and folders của window explorer.
Bước 2: Lên Popcap site download về một game nào đó (giờ đang có game Plants vs Jombies rất hài)
Bước 3: Cài đặt game này vào máy (chỉ có next next và next), ví dụ cài vào C:\games\PnJ\ và tập tin chạy game sau khi cài đặt là "PnJ.exe". Mở sẵn một cửa sổ Window Explorer ở vị trí thư mục cài đặt game.
Bước 4: Chạy PnJ.exe để chơi game. Popcapgame chưa đăng ký sẽ hiển thị một màn hình lựa chọn đăng ký (Buy) hoặc chơi thử (Play trial). Chọn Play Trial, khi vào đến màn hình chính của game thì ... qua bước 5 nha.
Bước 5: Switch ra ngoài window explorer. Bây giờ trong cửa sổ Window Explorer đã mở lúc nãy sẽ thấy có 1 file thực thi ẩn có tên "popcapgame1.exe" (hoặc một file thực thi ẩn có dung lượng tương đối bằng (nhỏ hơn) dung lượng file thực thi game PnJ.exe)
Bước 6: Đổi thuộc tính của file popcapgame1.exe thành Read-Only và bỏ thuộc tính Hidden. Ok
Bước 7: Tắt chương trình game đang chạy (tắt luôn cửa sổ Trial Game của Popcap). Quay lại cửa sổ Window Explorer, xóa file PnJ.exe và đổi tên popcapgame1.exe thành PnJ.exe.
Bước 8: Thực thi game PnJ.exe và ... hưởng thụ cuộc chơi miễn phí he he he..

Làm thử vài chục game từ cổ chí kim bắn trứng, hứng kim cương, dương quả tiễn rocket, lẫn các
game mới hấp dẫn như heavy weapon, plants vs jombies, peg night đều okie ^_^. Thôi chơi game tiếp thôi, chơi hoài cháy máy quá. ^_^

Thứ Sáu, 12 tháng 6, 2009

Bonus Manga: Manga terms

Có một thời gian say mê manga, tìm hiểu các thuật ngữ và các thể loại truyện tranh, dưới đây là một số thuật ngữ dùng trong manga để sưu tầm. (bài viết sưu tầm từ internet)
Phân loại theo khán giả:
Kodomo: dành cho trẻ em
Joise hoặc redikomi: dành cho phụ nữ
Shoujo: dành cho con gái
Shounen: dành cho con trai
Shounen-ai: quan hệ giữa nam-nam cấp độ 1
Shoujo-ai : quan hệ giữa nữ-nữ cấp độ 1
Yaoi : quan hệ giữa nam-nam cấp độ cao hơn (nghĩa là trong đó sẽ có nhiều *** hơn)
Yuri : quan hệ giữa nữ-nữ cấp độ cao hơn ( tương tự yaoi )
Hentai : được chuyên thể từ game ***
Ecchi : những manga này có lẽ hơn " hở " 1 chút nhưng thua Hentai
Chú thích : *** là những cái "không ai nói ra mà ai cũng biết"

Các thuật ngữ khác:
Mangaka :danh từ chỉ các tác giả manga

Doujinshi: là thể loại ăn theo của manga , dựa vào manga phần nào hoặc hoàn toàn khác manga .Sáng tác doujinshi có thể là những mangaka chuyên nghiệp ,cũng có thể là mangaka nghiệp dư hoặc fan (nhiều người bắt đầu sự nghiệp mangaka bằng cách làm doujinshi đấy).

Doujinshika:danh từ chỉ các tác giả Doujinshi

Fanfiction :gần gần giống Doujinshi , chỉ có điều là ko phải vẽ mà là viết văn.
ADR (Automated Dialogue Recording) :là cách tạo soundtrack tiếng Anh phù hợp với cử động miệng trên màn hình.

AMV (Anime Music Video) :là các video clip sử dụng cảnh trong anime và *****g music vào .Các otaku thường rất khoái cai này.

Anime TV Series :là Anime dài tập được chiếu trên TV .Nội dung thường khác manga 1 chút & điều đó chính là yếu tố ko gây hứng thú cho các độc giả sau khi đã xem Manga .Sau khi chiếu hết trên TV, các Anime này mới được sản xuất ra DVD/VCD/VHS bán cho các otaku.

Anime OVA/OAV :chỉ khác TV Series là nó được chuyển thẳng ra DVD/VCD/VHS để bán chứ không chiếu trên truyền hình. Số lượng các bản OAV thường rất ít ,các otaku dĩ nhiên rất hứng thú sưu tập nó.OVA luôn được làm kĩ hơn Anime Series (về đồ họa).Nội dung thường là tiếp theo hay là các câu chuyện ngoài lề Anime Series.

Anime the Movie :cũng gần giống với OAV ,nhưng ko chia làm nhiều chap mà là 1 câu chuyện liền mạch với thời lượng rất ngắn và được chiếu trong các rạp (màn ảnh rộng) .Đây cũng là thể loại Anime có cơ hội đoạt Oscar và các giải khác . Anime đầu tiên dành giải thưởng đó là Sen to Chihiro Kamikakushi (Spirited Away) của đạo diễn lừng danh Hayao Miyazaki, đoạt Oscar cho phim hoạt hình hay nhất năm 2001.

Art Work :giống giống Fanart , nhưng chất lượng hơn vì do các họa sĩ chuyên nghiệp vẽ. (cũng có artbook của loại này)

BGM (Background Music) là nhạc nền. (nhạc không lời và cả có lời).


CGI/CG (Computer Generated Imagery): là công việc thiết kế hình ảnh trên máy tính.

CG Division: là hệ thống máy tính và thiết bị hỗ trợ CGI

Chibi :C&B , dùng để chỉ các nhân vật được vẽ dưới hình dáng nhỏ nhắn , dễ xương ( đầu bự ,thân nhỏ )

Cosplay (Costume Play) : diễn kịch , hoặc là hóa trang( mặc đồ ,làm tóc)thành các char trong Anime & Manga.*vui thật*

Digisub (Digital Subtitle) :là một fansub nhưng ở dạng kỹ thuật số cho máy tính.

Dub là *****g tiếng trong phim. (Eng Dub, Fren Dub, Chin Dub,...)

ED (ending theme)& OP( opening theme) :music clip mở đầu và kết thúc của Anime ( hay 1 chap Anime)

Episode (Ep hay Epi):giống như chapter trong Manga.Mỗi Epi thường dài khoảng 20-25 min.

Eye Catch :là chỉ những đoạn ngắt giữa Anime. Thường thì Eye Catch có độ dài chỉ dưới 10 giây với vài hình ảnh có kèm theo tên của Anime.

Fan Art :tranh do fan vẽ

Fansub:là sub do fan làm.

Fanboy Một tên chỉ sống vì anime. Ngoài ra, thành một fanboy có nghĩa là lập một "thánh đường" hay tôn thờ bất cứ một nhân vật nữ của Anime nào và thậm chí là làm cái đuôi của những "tiểu thư" cosplay theo nhân vật đó.

Fandom: nhóm người có chung sở thích (như chúng ta chẳng hạn)

Fangirl: ngược lại với Fanboy

Henshin có nghĩa là biến đổi ,hóa thân ,biến hình (trong A-M)

Idol :thần tượng.

Lemon :là Fiction có nội dung về quan hệ thể xác. Từ này ít dùng hơn nhiều so với Hentai hay Doujinshii.

Omake :là đoạn phim thêm quay những cuộc phỏng vấn hoặc hài kịch ngắn. Nói chung nhiều Anime/Manga có các đoạn omake.

Original DVD :là DVD gốc, được sản xuất bởi chính hãng.. DVD gốc có rất nhiều interesting stuffs cho người xem như Cover và Box cực đẹp,Trailer, Char's Profile, Other Film's Trailer, Making of the Film, Gallery,... Được sở hữu những thứ này là mơ ước của Otaku (1 rich otaku cơ ,vì những thứ này rất mắc)

OST (Original Sound Track) :được dùng để chỉ chung các đoạn nhạc nền trong phim, kể cả OP và ED.

RPG = Role Playing Game: người ta dịch từ này là Game Nhập Vai. Có một số Anime có cốt truyện dựa theo các RPGs và cả Online RPGs.

RAW: file Anime gốc ,chất lựơng 5 sao.

Seiyuu :diễn viên *****g tiếng. Thường các Seiyuu đều là ca sĩ hay diễn viên cả.

Side Story : là truyện ngoài lề.Nội dung là khai thác các khía cạnh khác trong Anime-Manga gốc ,hoặc nói rõ hơn về 1 nhân vật nào đó trong Anime-Manga gốc.

Subtitle (Sub) :là phụ đề (dòng chữ hiện phía dưới cho biết nhân vật trong phim đang nói gì).

Trailer: là đoạn phim quảng cáo ngắn về 1 Anime.

Shoujo Manga :Manga dành cho con gái, được biệt là dành cho thiếu niên. Về một phía nào đó, nó giống với "tiểu thuyết tím". Thế nhưng nó không hẳn là như vậy.vì trong Shojo Manga tràn đầy những hình vẽ hoa lệ và lời văn hoa mỹ. Shojo Manga có thể dễ dàng được nhận ra với những cậu "đẹp trai", cô gái mắt to, hoa thơm rơi đầy trang... (Shojo có nghĩa là **** gái")

Josei Manga :Cũng là một dạng như Shojo Manga nhưng được vẽ dành cho lứa tuổi lớn hơn ( các bà vợ, nữ nhân viên ...). Thể loại này cũng cuốn hút nữ thiếu niên và đôi khi ... cả con trai. Chúng ta cũng có thể loại Seinen Manga dành cho con trai đã trưởng thành.

Shonen Manga :Manga nhắm vào các cậu con trai, đánh nhau chí ***e, đầy bạo lực, đẫm máu, kèm theo một mớ "anh hùng" ("Tôi chiến đấu cho trái đất... blah...blah...blah...)...và thường có cả những cô gái ngực to nữa. Shounen nghĩa là **** trai".

Shounen Ai :Hãy cẩn thận phân biệt giữa Shounen và Shounen Ai, chúng không hề giống nhau. Shounen Ai nhắm vào con gái. Các cô gái "phát cuồng" lên vì cái nhánh này của Shojo Manga. Đầu tiên, đây chỉ là một bộ phận nhỏ của Shojo Manga, sau đã phát triển thành một thể loại riêng biệt. Shounen Ai mở ra trước mắt người đọc thế giới của những anh chàng đẹp trai và đồng tính luyến ái. Về một phía cạnh nào đó, những anh chàng này đẹp trai, hào hoa và mối tình giữa bọn họ lãng mạn tới mức nó hẫp dẫn các cô gái trẻ một cách kì lạ. Ngày nay, thể loại này được biết đến một cách rộng rãi trong giới đọc Shojo Manga. Một số trong thể loại này cho ta thấy một thể giới không có gì khác ngoài các chàng trai "xinh đẹp". (Trong tiếng Nhật, "ai" nghĩa là "yêu" như từ "ái" của Trung Quốc vậy. Ta có thể hiểu Shounen Ai là "tình yêu con trai")

Yaoi :Một thứ không thể tưởng tượng được do phụ nữ sáng tác. Thể loại này tập trung vào tình yêu và các cảnh làm tình CON TRAI với CON TRAI. Nó có thể kết thúc với các cảnh kinh khủng với các hành động làm thực ... !!!

Ecchi / Hentai :Ecchi Manga là tiếng lóng của Hentai Manga. Hentai tiếng Nhật nghĩa gốc là "dị thường", nhưng ở phương Tây, nó được dùng với nghĩa là "mất dạy" hay "***". Không chỉ thể hiện các cảnh làm tình giữa nam và nữ mà còn thể hiện CON TRAI với CON TRAI, CON GÁI với CON GÁI.

Otaku : người hâm mộ cuồng nhiệt Anime hay Manga

Shoujo Ai : nghe là hỉu liền đúng ko . Dây là dạng manga mà tình cảm của các đôi trong này là GIRL x GIRL . Nhưng mức độ nhẹ nhàng thui , chỉ là yêu , thích chứ ko quá đáng

Yuri : Đây là thể loại manga mà mối quan hệ đó là những quan hệ của GIRL x GIRL nhưng là những quan hệ thật sự như girl x boy bình thường

(sưu tầm internet)

Thứ Hai, 8 tháng 6, 2009

Bonus: Hướng Dẫn Sử Dụng DNS Free

Hướng Dẫn Sử Dụng DNS Free
Domain quốc tế (.com /.net / .org / .info ....) của bạn sẽ không thể chạy nếu nó chỉ là một domain mà không có Hosting. Để cho Domain hiểu được Hosting thì phải thông qua DNS. Hay nói cách đơn giản, DNS tức là cầu nối để Domain và Hosting hiểu nhau, cùng nhau song song tồn tại trên Internet.
Hướng Dẫn Sử Dụng DNS Free

Nếu bạn có tiền, khi bạn mua Hosting của bất kỳ 1 nhà cung cấp hosting nào thì người ta sẽ send cho bạn thông tin DNS của Hosting đó. Ví dụ : ns1.SinhVienHost.com , ns2.SinhVienHost.Com ; hoặc ns1.SinhVienHost.net , ns2.SinhVienHost.net. Để Domain và Hosting của bạn cùng hoạt động, bạn chỉ việc vào mục quản lý (control) của domain, add DNS của hosting đó là xong.

Nhưng đối với các bạn học sinh, sinh viên thì đa số chỉ có tiền mua Domain quốc tế (.com/.net /.org/ .info....) và vẫn thích sài Hosting free của nước ngoài như yahoo, google, websamba.... Vậy làm sao để domain quốc tế của bạn trỏ vào những hosting free này ( các hosting free này chạy độc lập, và bạn không hề biết DNS của host free của mình đề add vào domain) ? Vậy các bạn sẽ kiếm ở đâu ra DNS để add vào domain ...?

Chúng tôi xin giới thiệu giải pháp không tốn tiền dành cho các bạn: đó là sử dụng DNS trung gian ( hay còn gọi là DNS free cũng được). Để kiếm được 1 DNS Free rất đơn giản, bạn chỉ việc vào google.com, gõ từ khoá " Free DNS".

Tức là từ Domain quốc tế bạn đã mua (.com /.net /.org/ .info ... ), bạn add DNS trung gian vào. Rồi từ DNS trung gian bạn Forward đến Hosting Free.

Hiện nay có rất nhiều nhà cung cấp Free DNS nổi tiếng như : everydns.net, sitelutions.com, zoneedit.com ....Chúng tôi xin giới thiệu với các bạn 1 nhà cung cấp DNS Free dễ sử dụng là Zoneedit.com

I/ PHẦN I: ĐĂNG KÝ 1 DNS FREE CHO DOMAIN

Bước 1: Bạn truy cập vào http://www.zoneedit.com/ , chọn Free Sign Up để đăng ký 1 DNS miễn phí cho riêng mình

Hướng Dẫn Sử Dụng DNS Free

Bước 2: Đây là phần đăng ký mẫu, Bạn hãy sửa lại thông tin đăng ký cho phù hợp, rồi bấm Sign Up Now

Hướng Dẫn Sử Dụng DNS Free

Bước 3: Nếu quá trình đăng ký thành công, bạn sẽ nhận được thông báo như thế này

Hướng Dẫn Sử Dụng DNS Free

Bước 4: Tiếp theo bạn hãy vào Email của mình để kích hoạt và xem thông tin đăng nhập.
Chú ý: rất có thể bạn vào Email kiểm tra sẽ không thấy thông tin này, bạn hãy vào mục Spam để tìm nhé!

Hướng Dẫn Sử Dụng DNS Free

Bước 5: Bạn truy cập www.zoneedit.com/auth/ sau đó điền đúng thông tin user, pass, màn hình sẽ ra như thế này.
Hãy bấm vào chữ Add Zones để điền tên domain mà bạn muốn sài DNS FREE này.

Hướng Dẫn Sử Dụng DNS Free

Bước 6: Sau khi add tên Domain muốn sử dụng DNS này, bạn sẽ thấy màn hình hiện ra như sau:

Ở Dòng H2 thì ns7.zoneedit.com , ns14.zoneedit.com
chính là DNS của domain bạn.
(Đây là account thông tin của tôi, rất có thể DNS của bạn là ns10.zoneedit ..... , ns12.nzonedit...., .... hay thông số khác)

Ở Dòng H1 thì bạn bấm vào WebForward để trỏ Domain của bạn đến bất cứ 1 hosting free nào.

Hướng Dẫn Sử Dụng DNS Free

Bước 7: Ví dụ tôi muốn trỏ Domain http://www.sinhvienhost.com của tôi chạy đến http://www.yahoo.com/ thì tui điền thông tin như thế này. Bạn hãy sửa lại theo của bạn cho phù hợp nhé !!!

Hướng Dẫn Sử Dụng DNS Free

Bước 8: Chọn Yes coi như là bạn đã hoàn thành

Hướng Dẫn Sử Dụng DNS Free

II/ PHẦN II: VÀO DOMAIN, ADD DNS ĐÃ Đ.KÝ

Sau khi đăng ký DNS và trỏ DNS của bạn đến 1 hosting free nào đó, bước cuối cùng là bạn đăng nhập vào Domain và trỏ Domain của bạn đến DNS là xong.
Dưới đây là hình ảnh minh hoạ:

Bước 1: Sau khi đăng nhập vào account của bạn, bạn hãy chọn Menu Domain/ List Last 10

Hướng Dẫn Sử Dụng DNS Free


Bước 2:
Sau đó chọn Domain bạn cần quản lý hay thay đổi thông tin: Bấm vào Domain Name - Click to Manage

Hướng Dẫn Sử Dụng DNS Free

Bước 3: Chọn Modify Name Server để thay đổi DNS

Hướng Dẫn Sử Dụng DNS Free

Bước 4: Sau khi điền DNS vào thì bấm Submit để hoàn thành

Hướng Dẫn Sử Dụng DNS Free

Chú ý: Sau khi đổi DNS thì bạn phải chờ Domain active với DNS. Nếu nhanh thì domain của bạn sẽ chạy trong vòng vài giờ sau khi đổi DNS. Còn chậm thì sẽ mất từ 24 đến 48 giờ Domain của bạn mới nhận ra DNS.

(Nguồn: suutam)

Thứ Bảy, 25 tháng 4, 2009

Java: Spring beginning (Review Project Part 2)

Bắt đầu với Spring
Spring là một java framework nguồn mở dùng ở tầng "bussiness layer" trong kiến trúc sau:

Nhiệm vụ của nó là tạo chỉ mục đến một "bean" trong tổng thể các "beans" đã định nghĩa trước đó. Để hiểu rõ ràng hơn thì bạn hãy tìm đọc các sách hoặc ebook về Spring, Spring in Action, ... Ở ví dụ step by step dưới đây chỉ phần nào thể hiện công cụng cơ bản của Spring.
Với IDE MyEclipse:
- Hãy tạo một project trống rỗng với tên DemoSpring
- Ở cửa sổ Package Explorer, right click vào "DemoString" -> MyEclipse -> Add Spring Capabilities, chọn Finish ở cửa sổ "Add Spring Capabilities"
Sau khi Finish, kết quả ở cửa sổ Package Explorer sẽ có thêm file applicationContext.xml (file này là file định nghĩa các bean) và Spring 2.5 reference library:
- Tới đây, ta tạm ngưng các hoạt động với Spring để định nghĩa các đối tượng, hành động ví dụ. Tạo các lớp như sau :
và codes:
------- DemoSpring.java --------------
import java.util.Scanner;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;


/**
* @author Hung.Trinh
*/
public class DemoSpring {

private static String CONFIG_FILE_LOCATION = "applicationContext.xml";
private static volatile BeanFactory beanFactory = null;

/**
* Copyright by tqhung at Apr 24, 2009 - 3:09:09 PM
* @param args
*/
public static void main(String[] args) {
System.out.println("Hello to Demo Using Spring with MyEclipse.");
Scanner sn = new Scanner(System.in);
String beanname = "";
getBeanFactory();
do {
try {
beanname = sn.next();
if (beanname.compareToIgnoreCase("exit") == 0) {
break;
}
IActionClass aclass = (IActionClass) beanFactory.getBean(beanname);
System.out.println(aclass.showMessage());
} catch (BeansException be) {
System.out.println("No bean found.");
} catch (Exception e) {
System.out.println(e.getMessage());
}
} while (true);

System.out.println("completed");
}

public static BeanFactory getBeanFactory() {
if (beanFactory == null) {
final ClassPathResource resource = new ClassPathResource(CONFIG_FILE_LOCATION);
beanFactory = new XmlBeanFactory(resource);
}
return beanFactory;
}
}
------- IActionClass.java --------------
/**
* @author Hung.Trinh
*/
public interface IActionClass {
String showMessage();
}
------- ActionClass1.java --------------
/**
* @author Hung.Trinh
*/
public class ActionClass1 implements IActionClass{

public String showMessage(){
return "In action 1 of class" + ActionClass1.class.toString();
}
}
------- ActionClass2.java --------------
/**
* @author Hung.Trinh
*/
public class ActionClass2 implements IActionClass{
public String showMessage(){
return "In action 2 of class" + ActionClass2.class.toString();
}
}
- Công đoạn kế tiếp là ta định nghĩa các bean cho Spring. Mở file applicationContext.xml:
-------- applicationContext.xml - Default ----------
[?xml version="1.0" encoding="UTF-8"?]
[beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"]

[/beans]
Có 2 cách định nghĩa bean: định nghĩa bằng dòng lệnh và định nghĩa bằng giao diện. Định nghĩa bằng dòng lệnh theo cấu sẽ đơn giản hơn với người lập trình chuyên sâu. Ở đây coi như ta chưa biết gì, ta dùng giao diện vậy :D. Mở cửa sổ Spring Explorer (Window -> Show View -> Other.. -> Spring Explorer), right click lên "bean" chọn "New Bean"
Và định nghĩa "action1", "action2" tương ứng với 2 lớp ActionClass1 và ActionClass2 mới vừa được tạo:
Nên nhớ là sau mỗi lần tạo bean bạn đều phải thực hiện save file applicationContext.xml. Kết quả sau 2 lần tạo bean, nội dung file applicationContext.xml sẽ là:
--------- applicationContext.xml - Configured ----------
[?xml version="1.0" encoding="UTF-8"?]
[ơbeans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"]
[bean name="action1" class="ActionClass1" abstract="false"
lazy-init="default" autowire="default" dependency-check="default"]
[/bean]
[bean name="action2" class="ActionClass2" abstract="false"
lazy-init="default" autowire="default" dependency-check="default"]
[/bean]
[/beans]
nhưng thực tế cần thì ít hơn:
[?xml version="1.0" encoding="UTF-8"?]
[beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"]
[bean name="action1" class="ActionClass1" /]
[bean name="action2" class="ActionClass2" /]
[/beans]
save lại 1 lần nữa cho chắc ăn :D,
Tới đây bạn có thể test kết quả vừa làm. Run DemoSpring java application, ở console, nhập chuỗi "action1" -> enter, "action2" -> enter sẽ thấy kết quả:
input : action1 --> output: In action 1 of classclass ActionClass1
input : action2 --> output: In action 2 of classclass ActionClass2
input : exit --> output: completed
Chúc thành công.

Thứ Tư, 1 tháng 4, 2009

Java : Mapping DB tour with Middlegen and Hibernate (Review Project Part 1)

Hôm nay, nhận được một yêu cầu trời giáng choáng váng cả tiếng. Tui phải tìm hỉu mã nguồn một cái dự án Java tổng hợp bao gồm Hibernate, Spring, Strut, Mina 2.0, + linh tinh những thứ mà tui lờ mờ như tờ giấy trắng ngoại trừ ngôn ngữ Java basic.
Để bắt đầu, tui chọn sử dụng MyEclipse để đỡ mắc công cài các plugin lằng nhằng cho mấy cái framework khủng, trong khi thứ tui iu thích nhẹ nhàng lại là Eclipse đã từng cắn xé Javacard.
Quả thật là sau khi cài đặt MyEclipse vào, tui nhận thấy hầu như các framework mình cần cho thực tế đều có sẵn (thiệt đỡ quá). Đối với dự án tui tìm hỉu chỉ cần thêm một cái MySQL connector và vài cục jar log4net, .. là xong, he he

Khởi động ME (MyEclipse), theo thói quen tui tạo luôn một project rỗng trơn không gì cả, xài lại một cái ant builder.xml có sẵn đâu đó và sửa lại mỗi properties name.

Bắt đầu với Hibernate và Middelgen:
- Đọc lòng vòng thì tui biết, Hibernate chỉ đơn thuần là để "mapping" với một database ở đâu đó. Lợi ích của dùng Hibernate là để đơn giản hóa và chuẩn hóa thao tác với cơ sở dữ liệu, biết nhiêu đó là đủ rùi.
- Tuy nhiên, để có thể hoàn thành việc "mapping" này thì cần phải có các thứ linh tinh khác như sau:
+ hibernate mapping files: các file cấu hình định nghĩa các bảng trong database. Thường mỗi bảng ta lại định nghĩa một file dạng ".hbm.xml"
+ hibernate configuration file: một file cấu hình để định vị đối tượng database bao gồm : connection string, database connection provider, username, password ...
+ Implementation files: các file hoặc gọi là các lớp thể hiện của các bảng trong database.
Chài ai, tìm hiểu đến đây, tui nghĩ hỏng lẽ mình thay cái thao tác Connection rồi query xưa cũ lòng thòng bằng một đống file ngồi gõ chít bỏ. Tính sơ sơ ra mỗi table có thao thác là phải tạo ra 1 file mapping và 1 file đối tượng, Hibernate thiệt là khùng hết sức !! T_T !! Nhưng việc làm thủ công đó là trước đây, các anh các chị trước đây đã chịu khổ và sản sinh ra công cụ Middlegen...
- Middlegen được ứng dụng để truy vấn đến database và xuất ra các table mapping file
một cách tự động và chuẩn xác. Đồng thời Middlegen cũng tự động phát sinh java code các lớp đối tượng table tương ứng, nhưng tui được khuyến cáo là không nên dùng những lớp code này. Tìm hiểu tới đây là đủ nhức mắt ngứa tay rồi, thôi quay lại cái bàn phím thôi.
- Để sử dụng Middlegen, ta tạo một middlegen build file (xml) bằng cách right click vào Project -> New -> Other -> Middlegen -> Middlegen Build File. Click next đến của sổ "Configure Database and Table", ở đây phải cung cấp các thông số bắt buộc để xác định database như: xác đinh gói JDBC, Database URI, Username, Password như hình dưới:
sau đó click "Finish" cửa sổ Middlegen Generator sẽ mở thể hiện mối quan hệ các bảng trong cơ sở dữ liệu, click "Generate" và sau đó đóng cửa sổ. Kiểm tra lại thư mục "src" của project sẽ thấy package các file Middlegen vừa xuất
tới đây tui được các đàn anh mách bảo là xóa hết các class object đi, chỉ để lại các mapping file và right click -> Hibernate Synchronizer -> Synchronize Files, kết quả là được 4 package như sau:
tạm thời tui chỉ hiểu 4 package này chứa các lớp đối tượng thể hiện chính xác các bảng dữ liệu và mối quan hệ bảng ở database. Tới đây, dường như nhiệm vụ của Hibernate và Middlegen đã hoàn thành.

Sau đó còn sử dụng tiếp String, Mina 2.0, ... hồi sau sẽ rõ !!!


Thứ Tư, 25 tháng 3, 2009

C# .Net Tools: MbUnit Test Framework


About MbUnit

The framework was first created by Jonathan 'Peli' de Halleux as a hobby project while studying for his PhD. Later Peli and Jamie Cansdale added support for MbUnit to Jamie's NUnitAddin (later it would become the TestDriven.NET addin). After Peli's departure to Microsoft in 2005 (working first as a SDET on the CLR and more recently in the Foundations for Software Engineering group in Microsoft Research) the project was opensourced under Andy Stopford.

Download

MbUnit v2.4.2 release.


License MbUnit 2.4

Copyright © 2005-2007 Andrew Stopford

Portions Copyright © 2000-2004 Jonathan De Halleux, Jamie Cansdale

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

License Note

This license is based on the open source zlib/libpng license. The idea was to keep the license as simple as possible to encourage use of MbUnit in free and commercial applications and libraries, but to keep the source code together and to give credit to the MbUnit contributors for their efforts. While this license allows shipping MbUnit in source and binary form, if shipping a MbUnit variant is the sole purpose of your product, please let us know.

Development

MbUnit has an active open source development team and are grateful of any support which can be provided to the project.

Documentation for the project, including how to get started developing for the framework, submitting bugs, and other important information can be found at:
http://docs.mbunit.com

They are also hosting their code at GoogleCode and SVN. This can be access by going to:
http://code.google.com/p/mb-unit/

And their bug tracking system is located at:
http://www.mertner.com/jira/

;( Not compatible with C# Express 2005 ;(

Please feel free to comfirm me with newest, more intelligences frameworks. Thanks!!

Thứ Năm, 12 tháng 3, 2009

Web PHP - Đơn giản một controller, một view

Bước kế tiếp để thao túng được CI là biết tạo các "Controller" xử lý và "View" thể hiện theo kiến trúc của CI.
Tạo một Controller đơn giản: CI framework được xây dựng trên nền php OOP, nên mỗi một controller của CI được tạo là một class với dẫn xuất gián tiếp hoặc trực tiếp từ lớp cơ bản "Controller" của CI.
- Qui cách đặt tên controller: capital first letter. Ví dụ: class MynewController extern Controller { }. Tên file lưu controller nên ở dạng lower case để phù hợp cho server window lẫn linux khi triển khai sau này. Tạo một controller đơn giản load một view đơn giản:

/* saved file name: /cibase/system/application/controller/controllerhome.php */


class ControllerHome extends Controller {

//hàm khởi dựng controller
function ControllerHome()
{
parent::Controller();
}

//hàm index truy cập mặc định controllerhome
function index()
{
$this->load->view('view_home');
}
?>
và View đơn giản:

/* saved file name: /cibase/system/application/view/view_home.php */
[html]
[head][title] A simple view of ControllerHome [/title][/head]
[body][p] Load view succeed in {elapsed_time} seconds [/p][/body]
[/html]

Cấu hình để chuyển controller mặc định khi truy cập url (http://localhost/cibase):
--> file: /cibase/system/application/config/route.phps
*line: 43 $route['default_controller'] = "welcome"; -> $route['default_controller'] = "controllerhome";

Okie, bây giờ ta truy cập lại vào địa chỉ http://localhost/cibase/ để hưởng thành quả lao động :)

Web PHP - Lập trình web PHP dễ dàng với Code Igniter - triển khai

Bắt đầu chập chững PHP, được người bạn giới thiệu framework PHP đơn giản là Code Igniter. Dưới đây là những ghi chú trong quá trình sử dụng:
Thông tin framework: http://codeigniter.com/
- Download trực tiếp: http://codeigniter.com/download.php
- Forum hỏi đáp: http://codeigniter.com/forums/
Khi download CodeIgniter về máy, bạn được tập tin CodeIgniter_{version}_.zip. Khi giải nén tập tin này, ta được 2 thư mục: "system", "user_guide" và 2 tập tin: index.php và license.txt
--> Thư mục "system" chứa toàn bộ kiến trúc framework cơ bản. Từ đây là nơi bạn bắt đầu mọi công việc lập trình Web với CodeIgniter.
--> Thư mục "user_guide" là toàn bộ hướng dẫn cơ bản của CodeIgniter cho người mới bắt đầu. Khi phát triển sản phẩm với CodeIgniter, thư mục này có thể bỏ đi.
--> Tập tin "index.php" là tập tin đầu vào mặc định cho framework CodeIgniter.
Các công cụ kèm theo để bắt đầu viết Web với CodeIgniter:
- PHP Server: xampp hoặc wamp server 2.0
- PHP Code IDE: NotePad++ hoặc Netbean 6.5 for PHP, Notepad

Tiến hành cài đặt Wamp Server 2.0, và xác định vị trí thư mục "www" của server sẽ là nơi triển khi web ở "http://localhost/"
Triển khai framework CodeIgniter:
- Giải nén tập tin CodeIgniter_{version}_.zip vào 1 thư mục (ví dụ "cibase") đặt ở trong "www".
- Cấu hình lại đường dẫn truy cập web cibase:
--> file: /cibase/system/application/config/config.php
line 14: $config['base_url'] = "http://localhost/cibase/";
Kiểm tra sự hoạt động của framework mới cài đặt:
- Mở trình duyệt web và nhập địa chỉ: "http://localhost/cibase/", nếu framework CI đã cài đặt thành công, bạn sẽ thấy kết quả tương tự trang dưới đây:Code Igniter thật đơn giản chỉ có thế.