2011-08-02

Using Link Shell Extension to create NTFS Junction

Trước giờ mọi người nghe nhiều về NTFS, sử dụng Windows không biết bao nhiêu năm và cũng không ai xa lạ gì với create shortcut. Nhưng chắc chắn rất ít người biết rõ về link của NTFS: thế nào là symbolic link hay junction. Những ai tiếp xúc với Linux thì sẽ quen với khái niệm link còn người dùng Wins thì phần lớn chỉ biết shortcut.

Tuy nhiên shortcut không phải khi nào cũng dùng được, nó có nhiều hạn chế hơn những dạng khác mà những dạng này ít người biết mà Wins cũng không hỗ trợ trực tiếp. Mình sẽ không nói gì về lý thuyết cả, chỉ giới thiệu một cách dùng Junction của NTFS trong thực tế như thế nào. Sẵn tiện cài xong game mình viết một vài dòng luôn. Vì sao lại dùng Junction thì có thể tham khảo link http://comptb.cects.com/2268-overview-to-understanding-hard-links-junction-points-and-symbolic-links-in-windows
Mình trích 1 đoạn như sau:


Junction Point (Directory Hard Link):
  • A file that acts like a representation of a target directorypartition or volume on the same system
  • Has the same size as the target without duplicating it (doesn’t use any space)
  • Interpreted at the operating system level – transparent to SW programs and users
  • Deleting the Junction Point does not remove the target*
  • If the target is moved, renamed or deleted, the Junction Point still exists, but points to a non-existing directory
  • Changing the contents through the Junction Point changes the target contents
  • Can reside on partitions or volumes separate from the target on the same system
  • Compatible with Win2k and above in Windows
*A Junction Point should never be removed in Win2k, Win2003 and WinXP with Explorer, the del or del /s commands, or with any utility that recursively walks directories since these will delete the target directory and all its subdirectories. Instead, use the rmdir command, the linkd utility, or fsutil (if using WinXP or above) or a third party tool to remove the junction point without affecting the target. In Vista/Win7, it’s safe to delete Junction Points with Explorer or with the rdir and del commands.
Symbolic Link (Soft Link):
  • A file containing text interpreted by the operating system as a path to a file or directory
  • Has a file size of zero
  • Interpreted at the operating system level – transparent to SW programs and users
  • Deleting the Symbolic Link does not remove the target
  • If the target is moved, renamed or deleted, the link still exists, but points to a non-existing file or directory
  • Points to, rather than represents, the target using relative paths
  • Can reside on partitions or volumes separate from the target or on remote SMB network paths
  • Compatible with UNIX and UNIX-like systems and with Vista and above in Windows
Shortcut:
  • A file interpreted by the Windows shell or other apps that understand them as paths to a file or directory
  • File size corresponds to the binary information it contains
  • Treated as ordinary files by the operating system and by SW programs that don’t understand them
  • Deleting the shortcut does not remove the target
  • Maintains references to target even if the target is moved or renamed, but is useless if the target is deleted
  • Points to, rather than represents, the target
  • Can reside on partitions or volumes separate from the target on the same System
  • Compatible with all Windows versions


Ví dụ 1: chơi The Sims, download objects phải để trong My Document/EA Games/The Sims 2/Downloads, nhưng việc này dẫn đến 2 vấn đề rắc rối: thứ nhất dung lượng ổ C chẳng hạn có giới hạn, thứ 2 muốn giữ lại download mỗi khi cài lại máy hay muốn để một nơi nào đó (một ổ đĩa khác ổ Data là D:).

Ví dụ 2: một trường hợp nữa là khi không muốn cài hết tất cả trong C: vì lỡ chia partition quá nhỏ mà không resize được, nhưng một số app rất khó chịu, đã chọn installation location là ổ đĩa khác vẫn install vào C: (điển hình là Visual Studio).

Lúc này mình sẽ dùng Junction như sau:

Bước 1: download  hardlink shell, một tiện ích miễn phí cho phép tạo các dạng NTFS link khác nhau, ở đây mình sẽ xài Junction
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html
Trong trang download cũng có chỉ cách dùng, tuy nhiên để rõ ràng mình sẽ mô tả cách dùng Junction.

Bước 2: cài đặt link shell extension. Sau khi cài đặt xong, nhấp chuột phải vào một folder nào đó sẽ có một shell extension là 'Pick Link Source'. Tới đây là đã cài Link Shell Extension thành công.

Bước 3: cách dùng
Giả sử với ví dụ 1 ở trên. Chúng ta muốn link The Sims 2/Downloads sang ổ data D: chẳng hạn (có nghĩa là chúng ta cần kết quả cuối cùng trong The Sims 2 có folder Downloads nhưng thực chất nó là một folder ở D:).
- Tạo trong D:\My Games\The Sims 2\Downloads. Phần trước Downloads là gì cũng được tùy bạn quản lý nhưng phần sau chắc chắn là Downloads. Đây là folder thật 100%.
- Chọn chuột phải, hiện ra 'Pick Link Source', thực hiện Pick Link Source bằng cách click vào đó ;-). Sau bước này chúng ta đã chọn link source.
- Vào My Document/EA Games/ tức tại đây chúng ta thấy folder The Sims 2 nghĩa là folder cha của Downloads mà chúng ta sẽ tạo, nhấn chuột phải, lúc này sẽ thấy xuất hiện Cancel Link Creation tức hủy việc tạo link (nếu tạo nhầm chẳng hạn), và Drop As ..., ta chọn Drop As ... -> Chọn Junction, như vậy là đã tạo link xong. 





Folder link sẽ có biểu tượng link nhỏ bên góc biểu tượng folder, nếu nhấn chuột phải thì trong menu context sẽ có mục Delete Junction.


- Giờ test thử, new một text document (New Text Document.txt) ngoài desktop chẳng hạn, paste vào My Document/EA Games/The Sims 2/Downloads hay vào trực tiếp tạo text file trong Downloads link folder mới tạo, rồi chuyển sang D:\My Games\The Sims 2\Downloads, trong đó có file text vừa tạo. Bây giờ 2 folder ở 2 vị trí nhưng bản chất là một.


Với ví dụ 2: chúng ta làm tương tự, giả sử cài Visual Studio 2010, tạo trong D: thư mục là D:\Microsoft Visual Studio 10.0 (là default installation folder name). Chọn Pick Link Source, xong vào C:, chọn chuột phải lên folder Program Files, và chọn Drop As ... > Junction. Sau khi thực hiện xong chúng ta cài Visual 2010 bình thường, chọn thư mục cài đặt là C:\Program Files\Microsoft Visual Studio 10.0, thực chất sẽ cài lên ổ D:. Có thể mình cài trước, rồi move cái folder cài đó sang D:, xong tạo link ngược lại cũng OK.

Vậy là có thể bạn đã biết thêm 1 các dùng link trong Windows. Rất cảm ơn developer tạo ra cái shell extension này, rất tiện lợi.
Nice day,

2011-07-09

Install The Sims 2 with Windows 7 compatibility issues (all EPs and SPs)

Hôm nay ngồi cài The Sims 2 cho vợ, lần trước cũng kêu sẽ cài nhưng rồi bị lỗi không cài được vài EP nên thôi không cài nữa. Lần này mới cài lại máy, nghĩ cũng tức không cài được EP thì chơi cái gì nữa. Mình cũng có sở thích 'giết người' và 'xây nhà tập thể' (có nghĩa là sưu tập bia mộ hoặc xây sao ở nhiều người mà bọn nó ko xung đột) trong The Sims 2.

OK vấn đề là sau khi install 4 đĩa gốc từ Disk 1 đến Disk 4, có thể chơi nếu chỉnh
Compatiblity mode Windows XP SP2 + Disable visual themes, Disable desktop composition, Privilege Level Admin (optional). Tới đây thì có thể chơi game rồi nếu không patch hoặc cài thêm EP. Tất nhiên ta không dừng lại ở đây.

The game will now run but you will not be able to install the patch or add a new EP. This is because each EP checks for an update which Windows 7 co-operate with. In my experience I still wasn’t able to install the patch even run TSBin/TS2UPD.exe in compatibility mode.

Bản patch có thể download tại website của EA nhưng không cần download nếu tiếp tục cài thêm EP.

The patch can be downloaded at http://thesims2.ea.com/update/ but it's unnecessary if we continue install EPs. The updater will automatic launch the patch after EP installation completed.

+ Patch, EPs installation

Nhưng tới đây vẫn chưa thể cài EP, nói chính xác là bản EP1 University. Nó sẽ ra thông báo 'Please insert The Sims 2 CD 4 to continue' và không thể hoàn tất cài đặt.

Can't complete patch after install EP1, even both Physical DVD and Virtual DVD Drive have The Sims 4 CD). If we cancel, the installer will rollback, OMG.

Tới đây thì đuối rồi, search hoài không ra cách nào để qua bước này. Cuối cùng thì mình cũng đã làm được. Tới đây đừng đụng đậy gì đến nó, shutdown máy và vào chế độ Safe Mode, F8. Nhớ là khi vào chế độ Safe Mode ta dùng Physical CD/DVD Drive vì Virtual CD/DVD Drive không hoạt động. Chạy EP1 Install Folder/TSBin/TS2UPD.exe với compatiblity mode. OK thành công.

After installation completed and the installer launch the patch, ignore the dialog 'Please insert The Sims 2 CD 4 to continue' and shutdown the PC. Restart PC in Safe Mode (F8), alter the patch/updater to compatibility mode and complete patch with The Sims 2 CD 4 in Physical CD/DVD Drive.

Kết luận:

1. Cài đặt 4 đĩa The Sims 2, sẽ chơi được với compatiblity mode. 
Completed install 4 CDs, alter the compatibility of the game. The game is runable in compatiblity mode (it's not all we needs).

2. Cài EP và để thông báo lỗi đó, thực hiện tắt máy.
Complete EP installation, leave the updater message alone, turn off PC.

3. Khởi động với Safe Mode
Start PC in Safe Mode

4. Chạy patch với compatibility mode
Alter the compatibility of the patch (EP Install Folder/TSBin/TS2UPD.exe)

5. Cài patch thành công
Install patch

6. Restart và tiếp tục cài trong Safe Mode với các EP còn lại nếu không patch được
Repeat install in Safe Mode with the next EPs. Restart and run game

2011-06-09

AS3 Array size hole



Nhiều khi code ra cái lỗi không thể nghĩ đến, may mà search ra (smartfoxserver2 forum)

The length property does not really return the size of the array, but return the highest index available.

var a:Array = []
a[1000] = "Hello"
trace(a.length)

It will return a lenght of 1001, which is clearly not the size of the Array.

2011-05-21

Install FlashTracer for Firefox 4, configuring Chrome with Flash Player Debugger

Disable Firefox 4 add-on compatibility
http://www.nirmaltv.com/2011/03/19/disable-add-on-compatibility-check-in-firefox-4/

Download and install Flash Tracer
http://www.sephiroth.it/firefox/flashtracer/

+ Config
SuppressDebuggerExceptionDialogs=1


Configuring Chrome with Flash Player Debugger 
Với Chrome chúng ta không thể install debugger vào bản release như FF vì nó dùng update Flash player mới nhất kèm theo trong bản cài đặt ;-(.

Tắt plugins Flash bằng cái vào about:plugins thực hiện disable. Install Flash Player Debugger là xong xuôi.

2011-04-05

Started playing with as3isolib

Mấy bữa nay mình tập tành Flash rồi coi những thứ liên quan tới isometric game. Hy vọng là sẽ có thể hiểu biết thêm 1 chút gì đó. Làm những gì liên quan đến game có cảm giác thú vị. Isometric game thì là loại mình đã chơi từ hồi bé, trừ mấy năm gần đây không chơi nữa chắc cũng được 20 năm. Có điều mình không có khiếu mỹ thuật nên nhiều cái chẳng làm được, 1 phần search trên net một phần nhờ người này người khác làm giùm.

Search qua 1 vòng thì mình chọn as3isolib. Để tìm hiểu thêm 1 chút nữa.  Một engine khác là OpenSpace cũng nổi tiếng nhưng khá là mắc 2200 EUR nhưng đúng là engine đó tổ chức tốt mình đã học nhiều thứ trên website của nó http://www.openspace-engine.com/.

Gambatte ...

2011-03-21

Beginning Flash and ActionScript: FlashBuilder 4 setting colors scheme, code formatter

Trước khi bắt đầu coding gì đó PL đều thực hiện chỉnh lại IDE, chọn màu dark cho dịu mắt, vừa làm được ban ngày lẫn ban đêm.

Chỉnh colors schema của IDE.
Có thể dùng theme pluggin - http://eclipse-color-theme.github.com/update
Đầu tiên chọn colors schema của Eclipse trước có thể ghé qua trang http://www.eclipsecolorthemes.org/?list=toppicks&filter=dark
Mình chọn Obsidian trước sau đó sẽ thay 1 số thứ như selection background, download Obsidian.epf về, nhưng mới chỉ là chọn colors schema cho Eclipse, sau khi chỉnh Eclipse colors schema thì cần chỉnh editor của ActionScript nữa. Nói chung toàn bộ colors chỉnh như sau.
Window > Preferences > General > Editors > Text Editors >


Line number foreground: 129, 150, 154
Current line highlight: 47, 57, 60
Print margin: 129, 150, 154
Find Scope: 224, 226, 228
Selection foreground color: 224, 226, 228
Selection background color: 85, 87, 83
Background color: 41, 49, 52
Foreground color: 221, 227, 230
Hyperlink: 25, 74, 165

Chỉnh thêm Text Editors > Annotations > ActionScript Occurrences là Text as Highlighted 47, 57, 87

Bây giờ cần chỉnh thêm ActionScript colors schema
Window > Preferences > Flash Builder > Editors > Syntax Coloring > ActionScript >

ASDoc: #7d8c93
Bracket/Brace: #11a37c
Comment: #7f7e7e
Default text: #c9c9c9
Keyword: class: #5fa0c1
Keyword: functio #5fa0c1
Keyword: interface: #5fa0c1
Keyword: package: #5fa0c1
Keyword: trace: #76b0c3
Keyword: var: #11a37c
Metadata: #11a37c
Operator: #11a37c
Reserved: #5fa0c1
String: #96cee1
Flash Builder > Editors > Syntax Coloring > MXML >
ASDoc: #7d8c93
Comment: #7f7e7e
Component Tag: #2b91af
Default Text: #c9c9c9
Processing Instruction: #11a37c
Special Tag: #5fa0c1
String: #11a37c
Còn lại một phần nữa là CSS, tùy mỗi người thích sao thì chọn tiếp.
Kết quả như sau:
Default, current line, occurrences

Selection

Download formatter
OK đến đây có vẻ ổn ổn rồi. Còn lại là một vài shortcut và chỉnh lại ASDoc template.

For a complete list of available keyboard shortcuts, see Accessing keyboard shortcuts. For information about editing existing or creating new keyboard shortcuts, see Changing keyboard shortcuts.
Name Keyboard shortcut Description
Switch between Source and Design mode Control+`(Left Quote) Switches between the MXML editor’s Source and Design modes.
Go to Documentation (Flash Builder plug-in)
Find in API Reference
(Flash Builder stand-alone)
Shift+F2 When you edit MXML or ActionScript, selecting a language element and pressing Shift+F2 displays language reference Help for the selected element. For more information, see Getting help while writing code.
Context-sensitive Help F1 (Windows)
Command+Shift+/ (Mac OS)
Displays context-sensitive Help for the currently selected workbench element (editor, view, dialog box, and so on).
Add Block Comment Control+Shift+C (Windows)
Command+Shift+C (Mac OS)
Adds block comment formatting to the currently selected lines of code or adds a comment at the insertion point. For more information, see Adding comments and comment blocks.
Add CDATA Control+Shift+D (Windows)
Command+Shift+D (Mac OS)
Adds a CDATA statement at the insertion point so that you can add ActionScript to an MXML document.
Find Matching Bracket Control+Shift+P (Windows)
Command+Shift+P (Mac OS)
Moves the cursor to the matching bracket of the selected code statement.
Content Assist Control+Space (Windows)
Command+Shift+Space (Mac OS)
Displays code hinting. For more information, see Using Content Assist.
Find All Declarations in Workspace Control+G (Windows)
Command+G (Mac OS)

Finds declarations in your code base. See Finding references and refactoring code.
Find All References in Workspace Control+Shift+G (Windows)
Command+Shift+G (Mac OS)
Finds references to identifiers in your code base. See Finding references and refactoring code
Go to Definition F3 Open the source of an external code definition. For more information, see Opening code definitions.
Go to Line Control+L (Windows)
Command+L (Mac OS)
Displays the Go to Line dialog box where you can enter a line number and navigate to it in the editor.
Last Edit Location Control+Q (Windows)
Control+Q (Mac OS)
Highlights the last edited line of code.
Mark Occurrences n/a Marks every occurrence of the selected item in code.
Organize Imports Control+Shift+O (Windows)
Command+Shift+O (Mac OS)
When editing ActionScript, using this keyboard shortcut alphabetizes any import statements contained in the document. For more information, see Organizing import statements.
Open Type Control+Shift+T (Windows)
Command+Shift+T (Mac OS)
Quickly browse all class types. For more information, see Browsing and viewing classes.
Open Resource Control+Shift+R (Windows)
Command+Shift+R (Mac OS)
Displays the Open Resource dialog box where you can quickly search for and open a resource in the editor.
Quick Outline Control+O (Windows and Mac OS)

Displays the Outline view in Quick mode in the editor. For more information, see Using Quick Outline view in the editor.
Toggle Comment Control+/ (Windows)
Command+/ (Mac OS)
Toggles ActionScript comments in ActionScript code. See Adding comments and comment blocks.
Toggle BlockComment Shift+Control+C
Shift+Command+C
Toggle MXML comment blocks. See Adding comments and comment blocks.
Toggle Folding Control+Numpad_divide Toggles the folding of code blocks. See Setting, folding, and unfolding code blocks.

2011-03-08

How to disable Flash Debugger Error Messages in Firefox

Develop với Flash và install Debugger Player lâu lâu bị dialog báo lỗi, mà modal dialog nên không thể làm gì nếu không tắt nó, rất là bực mình. Vẫn biết là sẽ chỉnh được trong mm.cfg nhưng không biết là param gì. Cuối cùng search trên net cũng có.

Thêm vào file mm.cfg trong user folder, với Windows 7 thường là C:\Users\{user-name}\mm.cfg
SuppressDebuggerExceptionDialogs=1

http://perezj.blogspot.com/2010/08/how-to-disable-flash-debugger-error.html
http://www.senocular.com/?entry=475
http://yoavgivati.com/2009/09/disable-flash-debugger-error-messages/