Archive for October, 2010


Run Cassandra As A Windows Service

ne of the main issues that comes up over and over again for Cassandra is:

How do I run Cassandra as a Windows Service?

In this post I am going to answer that question and in the process demonstrate how to do it in less than 10 minutes.

Background

Cassandra is mainly developed by Linux developers so very little attention has been paid to the Windows developer or administrator as far as Cassandra goes.  So as Windows developers we have to hop through a couple more hoops than just clicking on an install.exe file and and letting it do all the work.  However lucky for us, those hoops are easy and quickly hopped through.

Step 1

If you haven’t done so already please read my jump start for Windows users on install Cassandra, this guide will get you ready for the next steps.

Step 2

The second step is also an easy one, you need to download a package called RunAsService, which provides the ability to run any program as a Windows Service.

After you have downloaded the file extract the contents to a directory of your choosing.  (I extracted it to c:\RunAsService)

Note: RunAsService was originally developed here, however I recompiled it to run on .NET 2.0.

Step 3

To install RunAsService open up a command prompt with Administrative privileges and run this command.

cd c:\RunAsService
install networkservice

This registers RunAsService with your Windows Service.  Make sure to keep your command prompt open because you will need it for the 5th step.

Step 4

To configure RunAsService for Cassandra open up the RunAsService.exe.config file in your favorite text editor and replace <service.settings> section with the following so that it looks like this:

<!– Services configuration –>
<service.settings>
<!– Run Cassandra as a service –>
<!– My Cassandra install path is C:\apache-cassandra\ –>
<service>
<name>Cassandra Database</name>
<executable>C:\apache-cassandra\bin\cassandra.bat</executable>
<parameters></parameters>
</service>
</service.settings>

<!– Services configuration –><service.settings>    <!– Run Cassandra as a service –>    <!– My Cassandra install path is C:\apache-cassandra\ –>    <service>        <name>Cassandra Database</name>        <executable>C:\apache-cassandra\bin\cassandra.bat</executable>        <parameters></parameters>    </service></service.settings>

After you have finished, save the config file and exit your text editor.

Note: My Cassandra install is in c:\apache-cassandra\ you will have to correct the config above for where you installed it if different than mine.

Step 5

The last and final step of this process is to start the RunAsService service.  You can either do it through the Services control panel or just type the following in to your command prompt.

net start runasservice

You should see a response in the command line saying that the service has been successfully started.  To verify that Cassandra has been started you can use the cassandra-cli.bat file:

cd c:\apache-cassandra\bin\ cassandra-cli.bat connect localhost/9160

It should report that it is connected to the server if the service is running.  And with that we are done, and I told you it would only take about 10 minutes.

Cassandra’s data model cheat sheet

Cassandra is a structured store. It has a rich data model that goes beyond a simple key-value model. This is a good thing as some of the complexity can be pushed to Cassandra, leading to simpler and more efficient applications. There is problem though: the guys who designed Cassandra have given complex names to the (rather simple) data model elements. This post tries to explain(again): “WTF is a SuperColumn“?

Data model elements

You can also download a PDF version.

Column

A name value pair (contains also a time-stamp, not represented here for the sake of clarity).
Cassandra ColumnColumn

Super Column

A sorted associative array of columns.

Super Column
Super Column

Column Family

A container for columns sorted by their names. Column Families are referenced and sorted by row keys.

Column FamilyColumn Family

Super Column Family

A container for super columns sorted by their names. Like Column Families,  Super Column Families are referenced and sorted by row keys.

Super Column FamilySuper Column Family

Keyspace

Top level element of a schema. Container for column families.

Examples

These examples are extracted from the model of a simple twitter clone discussed here.  I picked the statuses column family and the user relationships super column family.

Statuses Column FamilyStatuses Column Family

User Relationships Super Column Family
User Relationships Super Column Family

A name value pair (contains also a time-stamp, not represented here for the sake of clarity).

Cassandra meets Hector(Sharp)

A few days ago, I set up a Cassandra node on my machine.  Time to write some code now! In this post, we’ll get started with HectorSharp, a .NET client for Cassandra.

I assume you have a Cassandra node up and running on your machine on port 9160. If you didn’t do this already, you might find this useful. You will need to download and build the HectorSharp library (I didn’t find any pre-built binaries?).

To get a first taste, here is the traditional “Hello World!”:

var clientFactory = new KeyedCassandraClientFactory(
new CassandraClientPoolFactory().Create(),
new KeyedCassandraClientFactory.Config());
var client = clientFactory.Make(new Endpoint("localhost", 9160));
var keyspace = client.GetKeyspace("Keyspace1");
var path = new ColumnPath("Standard1", null, "greeting");
keyspace.Insert("0", path, "Hello World!");
Column column = keyspace.GetColumn("0", path);
Console.WriteLine(column.Value);

Looks pretty straight forward. Let’s do a quick walk-through:

var clientFactory = new KeyedCassandraClientFactory(
new CassandraClientPoolFactory().Create(),
new KeyedCassandraClientFactory.Config());

We create a factory for the clients we will be using to access Cassandra. The factory takes two parameters: a pool for clients, as you’d have for database connections, and a configuration object.

var client = clientFactory.Make(new Endpoint("localhost", 9160));

The factory is used to get a client for the local machine on port 9160, where our Cassandra server is already listening and waiting for requests.

var keyspace = client.GetKeyspace("Keyspace1");

I didn’t change the out-of-the box config. It happens that the default key space name is Keyspace1.

var path = new ColumnPath("Standard1", null, "greeting");

The column path object indicates where a column is located in a family or super family. Standard1 is the family name. The second argument is null since the column we want to acess is not embedded into a super column. The last argument is the column name. If you are confused about Cassandra’s data model, you can have a look at this post.

keyspace.Insert("0", path, "Hello World!");
Column column = keyspace.GetColumn("0", path);
Console.WriteLine(column.Value);

We used the path object to put and get back the string “Hello World!”. The column family at row “0″ is now containing a key “greeting” pointing to the value “Hello World!”.

Hello World!

So far, HectorSharp seems to be doing the job. Time to write a bigger application!

In this post we will write a sample account management system for Asp.NET MVC applications using Cassandra as a back-end and HectorSharp as Cassandra’s .NET client.

Before we begin, if you are not familiar with HectorSharp, here is a gentle introduction. Note also that we will be using .NET framework 3.5 and Asp.NET MVC 1.0 in the code fragments presented here.

Interface

In our application, account management and authentication is handled by a dedicated MVC controller: AccountController. As you would expect, this controller will handle actions like: LogOn, LogOff, Register, ChangePassword etc. The actual work is not implemented in the controller methods. It is instead delegated to a separate authentication service. This separation of concerns is important as it will make the code cleaner and easier to change. Moreover, it eases controller testing as we will be able to inject a mocked disconnected authentication services into the controller.

Let’s start by specifying the contract of our authentication service:

using System.Web.Security;
public interface IAuthentificationService
{
bool SignIn(string userName, string password, bool createPersistentCookie);
void SignOut();
MembershipCreateStatus SignUp(string userName, string password, string email);
bool ChangePassword(string userName, string oldPassword, string newPassword);
}

This interface allows the basic operations needed to back up our controller actions, let’s keep it simple for the moment. We’ll refactor the code as new requirements and needs emerge during development iterations. Notice that we are reusing the MembershipCreateStatus enumeration from System.Web.Security.

Implementation

Now, time to implement the interface using Cassandra as a store for user information. Basically, each time a new user sings up we will insert his info into Cassandra, and each time a user want’s to sign in, we will look for his info in Cassandra. Before writing code, let’s have a look at the schema we will be using. For the purpose of demonstration, we will simplify things.  We will use a single column family, keyed by user names, to hold the user information: name, password and email. Here is an example of what a column family row would look like:

User Info

Our column family is defined in the storage-conf.xml as follows:

<Keyspace Name="Chripper">
<ColumnFamily Name="Users" CompareWith="UTF8Type" />
</Keyspace>

Based on this schema, the authentication service implementation is straightforward. We will use FormsAuthentication for maintaining the authentication cookie and focus on the membership management.

using System.Web.Security;
using HectorSharp;
public class AuthentificationService : IAuthentificationService
{
private static readonly ColumnPath UsersPasswordPath =
new ColumnPath("Users", null, "Password");
private static readonly ColumnPath UsersNamePath =
new ColumnPath("Users", null, "Name");
private static readonly ColumnPath UsersEmailPath =
new ColumnPath("Users", null, "Email");
private readonly ICassandraClient client;
public AuthentificationService(ICassandraClient cassandraClient)
{
client = cassandraClient;
}
private IKeyspace Keyspace { get { return client.GetKeyspace("Chirpper"); } }
public bool SignIn(string userName, string password, bool createPersistentCookie)
{
if (!ValidateUser(userName, password))
{
return false;
}
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
return true;
}
public void SignOut()
{
FormsAuthentication.SignOut();
}
public MembershipCreateStatus SignUp(string userName, string password, string email)
{
Column nameColumn;
if (Keyspace.TryGetColumn(userName, UsersNamePath, out nameColumn))
{
return MembershipCreateStatus.DuplicateUserName;
}
Keyspace.Insert(userName, UsersNamePath, userName);
Keyspace.Insert(userName, UsersPasswordPath, password);
Keyspace.Insert(userName, UsersEmailPath, email);
return MembershipCreateStatus.Success;
}
public bool ChangePassword(string userName, string oldPassword, string newPassword)
{
if (!ValidateUser(userName, oldPassword))
{
return false;
}
Keyspace.Insert(userName, UsersPasswordPath, newPassword);
return true;
}
private bool ValidateUser(string userName, string password)
{
Column passwordColumn;
if (Keyspace.TryGetColumn(userName, UsersPasswordPath, out passwordColumn))
{
return string.Equals(password, passwordColumn.Value);
}
return false;
}
}

Conclusion

We implemented an authentication service using Cassandra as a store for user information. This implementation is a first iteration and chances are that we would like to have a richer schema (enable searching users by email, add a password question etc.) and to add more functionality to the service (control password strength, hash or crypt stored passwords etc.). We might also want to refactor the code that queries and updates the Cassandra store to a separate class. This class will act as a mediator between Cassandra and our application code (aka a repository).

Epilogue

If you are curious on how the MVC controller would consume our authentication service, here is a sample implementation:

using System;
using System.Security.Principal;
using System.Web.Mvc;
using System.Web.Security;
[HandleError]
public class AccountController : Controller
{
private readonly AccountInputValidator validator;
public AccountController()
: this(null)
{
}
public AccountController(IAuthentificationService authentificationService)
{
AuthentificationService = authentificationService
?? new AuthentificationService(CassandraClients.Make());
validator = new AccountInputValidator(ModelState);
}
private IAuthentificationService AuthentificationService { get; set; }
public ActionResult LogOn()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
{
if (!validator.ValidateLogOn(userName, password))
{
return View();
}
if (!AuthentificationService.SignIn(userName, password, rememberMe))
{
ModelState.AddModelError("_FORM", "The username or password provided is incorrect.");
}
if (!string.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Index", "Home");
}
public ActionResult LogOff()
{
AuthentificationService.SignOut();
return RedirectToAction("Index", "Home");
}
public ActionResult Register()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Register(string userName, string email, string password, string confirmPassword)
{
if (validator.ValidateRegistration(userName, email, password, confirmPassword))
{
var status = AuthentificationService.SignUp(userName, password, email);
if (status == MembershipCreateStatus.Success)
{
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("_FORM", AuthentificationStatus.ToString(status));
}
// If we got this far, something failed, redisplay form
return View();
}
[Authorize]
public ActionResult ChangePassword()
{
return View();
}
[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ChangePassword(string currentPassword, string newPassword, string confirmPassword)
{
if (!validator.ValidateChangePassword(currentPassword, newPassword, confirmPassword))
{
return View();
}
try
{
if (AuthentificationService.ChangePassword(User.Identity.Name, currentPassword, newPassword))
{
return View("ChangePasswordSuccess");
}
ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
return View();
}
catch
{
ModelState.AddModelError("_FORM", "The current password is incorrect or the new password is invalid.");
return View();
}
}
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.HttpContext.User.Identity is WindowsIdentity)
{
throw new InvalidOperationException("Windows authentication is not supported.");
}
}
}

Chirper is the first open-source non trivial web application example with .NET/NoSql integration. Chirper implements a simple twitter clone that, unlike twitter :P , uses Cassandra as its only database. It would’ve been probably cooler to code Chirper it in Ruby or in Python but, unfortunately, this is already done.

Chirper’s front-end is written in C# / Asp.net MVC 2.0. The back-end is based on Cassandra using the Aquiles library. The source code is freely available under the terms of the Apache License, Version 2.0.

Installation

Before going into Chirper’s design details in the next sections, you might want to play a bit with it first. For this, you will need to: (1) configure the database store with Chirper’s schema, and (2) setup Chirper in your favorite webserver that supports Asp.net.

Cassandra configuration

Simply edit Cassandra’s storage-conf.xml file and add a Chirper keyspace as follows:

<Keyspaces>
<Keyspace Name='Chirper'>
<ColumnFamily Name='Users' CompareWith='UTF8Type'/>
<ColumnFamily Name='Tweets' CompareWith='UTF8Type'/>
<ColumnFamily Name='Following' CompareWith='UTF8Type'/>
<ColumnFamily Name='Followers' CompareWith='UTF8Type'/>
<ColumnFamily Name='TimeLine' CompareWith='UTF8Type'/>
<ColumnFamily Name='UserLine' CompareWith='UTF8Type'/>
...
</Keyspace>
</Keyspaces>

We will go through the data schema in more details below. If you don’t have already a Cassandra node at hand don’t worry, it’s easy to set up. Here is how I did.

Installing the webapp

Just download the Chirper’s latest binary and unzip it somewhere on your hard drive. From your webserver configuration console create a new webapp based on the unzipped Chirper folder. The exact webapp creation steps depend on your webserver. Here are the instructions for IIS7.

The alternative would be to check-out the source code and run (or debug) Chirper from visual studio, using the development web server.

Design

Front-end

Chirper is still work in progress. However, it has already the most important features: tweeting, following other users, displaying timeline and userline, dispalying followers list etc. The front-end is really simple, nothing much to say here. Here are the main components:

  • Two MVC controllers are handling all the user actions: one controller for authentication and registration (similar to the one presented here) and another controller for everything else. The views are kept very simple too.
  • The model consists essentially of two classes: User and Tweet. Follower and Following are just users with a time-stamp.
  • A repository class abstracts all the web application logic from the back-end operations. This is really helpful in case we might want to mock the db store for testing.

Back-end

Chirper’s schema is really straightforward and very similar to the one implemented in Twissandra. Basically, we have two main families: Users and Tweets. Four other families are introduced to join theses main families in order to implement timelines and followers lists.

Users family

All Chirper users are recorded in this family. Rows are keyed by user name. Each column name/value represents a user’s property: Name, DisplayName, Location, Password etc.

Users Family

Tweets family

This family holds all Chirper tweets (or chirps :) ).  The rows are keyed by tweet id (a UUID). As for users, the columns represent the tweet properties.

Tweets family

Timeline and Userline families

A timeline (resp. userline) is simply a set of time-stamp/tweet id pairs held in rows keyed by user ids. The timestamps correspond to when the tweet was tweeted. In the userline family, the tweets are those tweeted by the user  used as row key. In the timeline family, the tweets are tweeted by the followed users.

User tweets family

Following and Followers families

The following (resp. followers) family joins users with their following (resp. followers) users.

User Following/Followers family

Conclusion

It was surprisingly easy to interface a .NET webapp with Cassandra. I had to write a few helper functions around the Aquiles connector but it did the job very well. Chirper’s schema is NOT designed to scale. It was kept very simple for the purpose of demonstration. I am currently looking for some help on Chirper’s web design, if you feel like contributing, please drop a comment here. It would also be nice to host a running instance of Chirper on the web (as Twissandra and Retwis do). If you can help on this please contact me.

Resource : http://www.javageneration.com/?p=318

Tìm hiểu công nghệ trình chiếu phim 3D

Các đạo diễn dùng loại camera đặc biệt với hai ống kính song song với nhau để lấy hình. Một máy phát có bánh xe quay sẽ gửi tín hiệu đến 2 mắt của người xem với cặp kính đặc biệt để họ hưởng thụ được không gian 3 chiều sống động.

Tim hieu cong nghe trinh chieu phim 3D

Tất cả các hình ảnh 3D nhân tạo đều dựa trên một thiết kế cơ bản: gửi 2 ảnh hơi khác nhau tới từng mắt. Não người sẽ tái tạo lại chiều sâu của hình ảnh như trong thế giới thực.

Hệ thống 3D của hãng Dolby dùng một bộ lọc dạng bánh xe quay tròn để thay đổi nhanh giữa 2 bộ màu cơ bản hơi khác nhau. Các bộ lọc tương ứng trên kính 3D chỉ để ánh sáng thích hợp đi vào mắt trái hoặc mắt phải sau khi tia sáng này khúc xạ khỏi màn hình. Bánh xe được đồng bộ hóa với máy chiếu kỹ thuật số làm nhiệm vụ chuyển tới/lui giữa các hình ảnh cho hai mắt 6 lần/khung hình (144 lần/giây). Giá: 26.000 USD.

Tim hieu cong nghe trinh chieu phim 3D

Thiết bị của hãng Real D và Dolby 3D đều yêu cầu người sử dụng đeo kính để đảm bảo các hình ảnh rời được chiếu trên từng mắt. Một số hy vọng công nghệ tương lai sẽ không cần đến cặp kính đặc biệt này nữa, số khác mong đợi chúng trở nên đơn giản giống như kính râm bình thường.

Tim hieu cong nghe trinh chieu phim 3D

Camera kỹ thuật số 3D của Pace Fusion được đạo diễn James Cameron dùng cho phim Avatar dự định trình chiếu vào năm 2009. Thiết bị có hai ống kính song song với nhau, tín hiệu từ đó phát ra được truyền bằng dây cáp đến hệ thống lưu trữ ở xa. Các ống kính này có thể đặt ở khoảng cách khác nhau để thích hợp với từng điều kiện quay.

Tim hieu cong nghe trinh chieu phim 3D

Công ty Masterimage (Hàn Quốc) dùng một bánh xe quay với tốc độ cao đưa luồng ánh sáng theo một hướng để các ảnh riêng gửi từ máy chiếu đến từng mắt có thể kết hợp tương ứng với kính. Thiết bị trong hình có mã hiệu MI-2100.

Tim hieu cong nghe trinh chieu phim 3D

Beowulf, một tác phẩm điện ảnh của hãng Paramount, hứa hẹn sẽ mang lại khoảnh khắc đẹp trong rạp 3D với hệ thống của Real D và Dolby 3D.

Tim hieu cong nghe trinh chieu phim 3D

Kính dùng một lần của Real D khá rẻ (0,5 USD).

Tim hieu cong nghe trinh chieu phim 3D

Còn kính của Dolby 3D dùng nhiều lớp phủ trên từng mắt. Giá: 50 USD.

Tim hieu cong nghe trinh chieu phim 3D

Hệ thống của Dolby 3D dùng một bánh xe quay 4.800 vòng/phút, đủ nhanh để chuyển đổi giữa 2 mắt 6 cảnh/khung hình. Bánh xe được chia làm 2, mỗi nửa có một bộ lọc chỉ cho qua ánh sáng nhất định, một cho mắt trái, một cho mắt phải.

Tim hieu cong nghe trinh chieu phim 3D

Bộ lọc có thể điều khiển bằng module này với các nút di chuyển bánh vào trong hay ra khỏi luồng sáng.

Cách chọn máy chiếu tại gia đình

Máy chiếu (projector) dễ lấy lòng dân mê điện ảnh vì dễ bố trí và cho hình ảnh lớn, đẹp. Tuy nhiên, cách sử dụng và bảo quản đồ vật hàng nghìn USD này cũng rắc rối hơn TV đôi chút.

“Ngay cả máy chiếu hàng nghìn USD, nếu không được cài đặt tốt thì chất lượng hình ảnh cũng không như ý muốn”, ông Nguyễn Tuấn Thành, Trưởng phòng Kỹ thuật công ty DigiWorld, đơn vị phân phối độc quyền máy chiếu Infocus tại Việt Nam, khẳng định.

Đa phần những người đam mê nghệ thuật thứ bảy đều công nhận projector là đối thủ đáng gờm nhất của dòng TV cỡ lớn hiện nay. Ưu thế của thiết bị thu hình truyền thống nổi bật nhất ở điểm dễ sử dụng và lắp đặt. Nhưng máy chiếu, ngoài kích thước hình ảnh lớn hơn, còn có ưu thế về giá, chất lượng hình ảnh và khả năng bố trí. So sánh các chỉ số kỹ thuật, máy chiếu ấn tượng hơn màn hình LCD hoặc plasma có cùng giá tiền cả về độ phân giải, độ sáng và tương phản. Nhưng sản phẩm “xuất thân” từ phòng họp của các công ty lớn này cũng khó tính hơn các anh em khác trong dòng thiết bị nghe nhìn và đòi hỏi sự quan tâm đặc biệt.

Lựa chọn công nghệ: LCD và DLP

“Hiện tại, một số projector thuộc dòng phổ thông cũng có công nghệ xử lý ánh sáng số DLP vốn chỉ có trong những dòng máy chuyên dụng cỡ lớn ở rạp chiếu phim”, ông Thành nói.

Trong công nghệ LCD (liquid crystal display – màn hình tinh thể lỏng) trước đây, máy chiếu tổng hợp hình ảnh màu dựa trên 3 màu cơ bản là đỏ, lục và xanh dương (RGB). Nguồn sáng trắng ban đầu được tách thành 3 nguồn sáng đơn sắc là đỏ, lục, xanh dương và được dẫn đến 3 tấm LCD độc lập. Nếu điểm ảnh trên LCD ở trạng thái đóng, ánh sáng không thể xuyên qua thì điểm ảnh biểu diễn trên màn hình là đen. Tương tự, độ sáng của điểm ảnh cũng thay đổi tương ứng theo trạng thái mở của điểm ảnh LCD. Điều khiển 3 tấm LCD đóng mở điểm ảnh theo thông tin ảnh số, ta thu được 3 ảnh đơn sắc theo hệ màu RGB. Sau đó, tất cả được tổng hợp một cách tự nhiên trong một lăng kính theo cơ chế ánh sáng trước khi xuất đến màn chiếu. Nhược điểm của máy chiếu LCD thường thể hiện khi chiếu phim là lộ điểm ảnh, màu đen không thật và hình ảnh chuyển động nhanh sẽ bị nhòe.

Cach chon may chieu tai gia dinh
Công nghệ DLP đem lại sự nhỏ gọn của máy chiếu tại gia đình.
Ảnh: Hưng Hải.

Khắc phục nhược điểm này, công nghệ DLP sử dụng gương để phản chiếu ánh sáng. Một chip DMD (Digital Micromirror Device) được tích hợp hàng nghìn vi gương, mỗi vi gương tương ứng một điểm ảnh. Vi gương dao động hàng nghìn lần/giây và thể hiện được 1.024 cấp độ xám. Để thể hiện hình ảnh màu, một bánh quay màu (color wheel) được đặt giữa nguồn sáng và DMD. Phổ biến hiện nay là hệ thống sử dụng bánh quay 4 màu gồm đỏ, lục, xanh dương, trắng để lần lượt tạo và xuất ra 4 ảnh đơn sắc trong một chu kỳ. Thay vì tổng hợp tự nhiên tại thấu kính, 4 hình ảnh đơn sắc lần lượt được ghi nhận và tổng hợp tại não người (tương tự như phương pháp tổng hợp ảnh 3D bằng mắt phổ biến trong điện ảnh). Ưu điểm của DLP là tạo được hình ảnh mượt, không lộ điểm ảnh, độ tương phản cao và không bị hiện tượng lệch hội tụ như công nghệ dùng LCD 3 tấm. Cấu tạo máy chiếu DLP đơn giản hơn LCD 3 tấm nên kích thước máy nhỏ nhẹ. Nhờ đưa thêm màu trắng vào bánh quay màu mà hình ảnh tạo ra bởi máy chiếu DLP sáng hơn và có màu trắng rất thuần khiết. Điểm ảnh trong máy chiếu “khít” hơn, hình ảnh sắc nét hơn so với LCD.

Chỉ số kỹ thuật

Độ sáng, độ tương phản và độ phân giải là ba chỉ số cơ bản ảnh hưởng trực tiếp đến chất lượng hình ảnh của máy chiếu. Thông thường, độ sáng được quan tâm nhiều nhất bởi chỉ số này càng cao thì chất lượng hình ảnh càng độc lập với ánh sáng bên ngoài. Đây cũng là căn cứ thể hiện sự khác biệt giữa 2 dòng máy chiếu gia đình và văn phòng.

Phòng họp tại các công ty thường có ánh sáng phức tạp, người có thể đi lại, cần ánh sáng để ghi chép… nên đòi hỏi projector cho nguồn ánh sáng mạnh. Người sử dụng máy chiếu tại gia đình hay thiết kế phòng riêng để thưởng thức, khi xem phim thường tắt hết đèn nên độ sáng chỉ khoảng từ 1.500 – 2.200 Ansilumen là có đáp ứng được yêu cầu. Gia tăng thêm cường độ ánh sáng chỉ có sự khác biệt về… tiền mua máy và tiền điện.

Ngược lại, độ tương phản và phân giải những máy chiếu cho gia đình lại được gia tăng đặc biệt. Nếu độ tương phản càng cao, màu sắc càng sống động, trung thực. Màn LCD hiện nay có độ tương phản phổ biến ở mức 500 – 700:1, trong khi máy chiếu thông thường có độ tương phản từ 1.700 – 2.200:1. Những biểu đồ, đồ thị trong các buổi thuyết trình tại văn phòng không đòi hỏi quá khắt khe về yếu tố này, nhưng đây lại là điểm làm nên sức hút cho những bộ phim DVD. Mỗi projector có thể tương thích với nhiều độ phân giải, chế độ SVGA (800 x 600 pixel) thích hợp với những phòng rộng và tối vì điểm ảnh khá lớn. Chế độ chuẩn XGA (1024 x 768) phù hợp với đa số phòng chiếu gia đình.

Chỉ số bù góc vuông khá quan trọng nhưng thường ít được người mua để ý. Đây là khả năng định hướng luồng sáng của máy chiếu ánh sáng vuông góc với màn ảnh, cho hình ảnh vuông vắn và trung thực. Số góc có thể bù càng lớn, khả năng bố trí máy càng linh hoạt.

Projector dùng để xem phim tại nhà không cần loại có sẵn loa vì chúng thường có công suất vừa phải, chỉ thích hợp với phòng họp nhỏ. Mặt khác, hệ thống rạp hát gia đình thường đi kèm với đầu ampli, máy chơi DVD và dàn âm thanh chuyên dụng.Do đó, những tính năng hỗ trợ chiếu khuôn hình rộng (16:9), chuẩn kết nối DVI, HDTV,… quan trọng hơn để có được chất lượng hình ảnh tốt nhất.

Bảo quản và sử dụng

Không như màn hình TV, máy chiếu có bóng đèn công suất lớn tỏa nhiều nhiệt nên chúng cần được bố trí vận hành tại nơi thoáng mát, nguồn điện ổn định. Sau mỗi lần xem, người dùng phải đợi một lúc cho máy nguội mới cất vào hộp hoặc che phủ tránh bụi. Một số gia đình thiết kế giá treo projector trên trần nhà để đảm bảo yếu tố này mà lại tiết kiệm được không gian. Bóng đèn cũng là linh kiện cần được “chăm sóc” kỹ càng nhất. Thông thường, toàn bộ thân máy chiếu được bảo hành 1-2 năm, nhưng riêng đèn hình chỉ được bảo hành 1 tháng hoặc 90 giờ chiếu. Người dùng cần thường xuyên quan sát bóng đèn, nếu có hiện tượng nhòe hình thì nên thay ngay.

Để tiết kiệm diện tích, người dùng có thể tận dụng bức tường phẳng sơn nhẵn để chiếu hình. Tuy nhiên, chất lượng hình ảnh không thể bằng tấm phông chiếu chuyên dụng. Tấm màn này được phủ sơn phản quang để ánh sáng phản xạ đến mắt người nhiều nhất. Phần lớn màn chiếu có màu trắng, nhưng cũng có loại màu xám để chống chói và tăng sắc đen cho ảnh. Nếu yêu cầu chất lượng cao hơn, khách hàng có thể yêu cầu loại cao cấp trong sơn có pha hạt kim loại tăng độ nét và độ sáng.

Hiện tại, khách hàng mua máy chiếu thường dựa vào thương hiệu hoặc “tư vấn” của bạn bè vì loại sản phẩm này còn mới đối với nhiều người. Những thương hiệu phổ biến ở Việt Nam có Epson, Canon, Infocus, Optoma, Sony… Sản xuất các loại máy chiếu nhỏ gọn cho văn phòng nhỏ và giải trí tại gia đình ngày càng được các nhà sản xuất chú trọng.

Cassandra up and running on windows in 10 min (or so)

I was surprised how easy it is to set up and run the Apache key-value store Cassandra on Windows. There is no self-contained Windows-based installer, but I got it running from the extracted archive quite easily. All I wanted to do is to get it up and running quickly and do some basic testing. No fancy config, I used the out-of-the-box config to set up a single node on my Windows Vista dev machine. Here is how it went.

Download and unzip the archive

Just go to the Cassandra download page and get the latest binary archive from there. I downloaded the 0.6.1 archive: apache-cassandra-0.6.1-bin.tar.gz and unzipped it to c:\cassandra.

Quick setup

The storage-conf.xml file contains some important config information, including the data schema. Let’s not change the schema for now. All we needed to do is to tell Cassandra where to put the commit logs and the data on the hard disk. I created a new directory cassandra-data and created in it two sub-directories data and commitlog. So let’s modify the config file located in c:\cassandra\conf\storage-conf.xml and modify the corresponding elements:

<CommitLogDirectory>c:\cassandra-data\commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>c:\cassandra-data\data</DataFileDirectory>
</DataFileDirectories>

That’s it! Time to run the server :-)

Running the server

First of all, we need to check that the environment variable JAVA_HOME is correctly set, Cassandra scripts rely on it.

I switched to the bin directory and I launched the cassandra.bat command with -f switch (-f keeps the server in “foreground” mode, on order to have the logs in stdout).

C:\cassandra\bin>cassandra.bat -f
Starting Cassandra Server
Listening for transport dt_socket at address: 8888
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cassandra/thrift/CassandraDaemon
Caused by: java.lang.ClassNotFoundException: org.apache.cassandra.thrift.CassandraDaemon
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Ouch! Something went wrong. After having a quick look at the cassandra.bat script, I figured out that it assumes that the current directory is the Cassandra “home directory”, i.e. c:\cassandra in my case. Let’s give it a second try:

c:\cassandra>bin\cassandra.bat -f
Starting Cassandra Server
Listening for transport dt_socket at address: 8888
INFO 16:27:12,627 Auto DiskAccessMode determined to be standard
INFO 16:27:13,123 Saved Token not found. Using 47823312181423841445299406225505462239
INFO 16:27:13,124 Saved ClusterName not found. Using Test Cluster
INFO 16:27:13,134 Creating new commitlog segment c:\cassandra-data\commitlog\CommitLog-1272205633134.log
INFO 16:27:13,256 Starting up server gossip
INFO 16:27:13,369 Binding thrift service to localhost/127.0.0.1:9160
INFO 16:27:13,418 Cassandra starting up...

Hurray! Seems to be working. It says it’s listening on localhost port 9160, let’s verify this.

Hello World!

Cassandra comes with a nice test utility: Cassandra CLI. It’s an interactive command line that you can use to put/get values in Cassandra. Let’s open a second shell window and run it.

c:\cassandra>bin\cassandra-cli.bat
Starting Cassandra Client
Welcome to cassandra CLI.
Type 'help' or '?' for help. Type 'quit' or 'exit' to quit.

Cool! It even has a friendly help command. First, let’s connect to our server using the connect command.

cassandra> connect localhost/9160
Connected to: "Test Cluster" on localhost/9160

We succeeded to connect to the Cassandra server. Before going further, let’s have a quick look at the schema. Remember, it is defined in the same file we modified earlier in the setup step: storage-conf.xml.

<Keyspace Name="Keyspace1">
<ColumnFamily Name="Standard1" CompareWith="BytesType" />
...
</Keyspace>

Cassandra’s Data model nomenclature is not obvious. In a nutshell: Keyspace1 is the name of the schema, Standard1 is a collection of rows, each row has an ordered set of key-value pairs. Let’s put some data there:

cassandra> set Keyspace1.Standard1['0']['greeting'] = 'Hello World!'
Value inserted.

Cassandra obeyed and stored our data: in Column Family Standard1 at row ’0′ we inserted the key-value pair (‘greeting’, ‘Hello World’). Let’s try to query Cassandra and see if the data is actually there.

cassandra> get Keyspace1.Standard1['0']['greeting']
=> (column=6772656574696e67, value=Hello World!, timestamp=1272208335786000)

It worked :) Notice the timestamp added to the inserted key-value.

Conclusion

That’s it for tonight! It’s surprisingly easy to setup a Cassandra node on Windows. Next step would be to write some code and try the Ruby or C# clients.

Resource : http://www.javageneration.com/?p=19

Tự làm máy chiếu bằng đồ cũ

Dù giá thiết bị đã hạ nhiều nhưng dân “độ” vẫn thích tự chế máy chiếu từ đầu DVD rẻ tiền, bộ chuyển đổi hiệu điện thế to kềnh, mạch điện ở những thiết bị nghe nhìn AV cũ cùng hàng trăm bóng đèn LED để tạo ra ánh sáng mạnh. > Cách chọn máy chiếu tại gia đình

Một cách chế projector.
Tu lam may chieu bang do cu

Lấy màn hình LCD ra khỏi đầu DVD xách tay.

Độ phân giải sẽ tùy thuộc vào màn hình LCD nhưng một số hệ thống có thể hiển thị được 720p mà không gặp trở ngại nào.

Tu lam may chieu bang do cu
Tu lam may chieu bang do cu

Đặt màn hình vào hệ thống máy chiếu tự chế, bao gồm các thấu kính phóng đại hình ảnh, nguồn sáng, bảng mạch điều khiển…

Tu lam may chieu bang do cu
Tu lam may chieu bang do cu

Để có hệ thống đèn chiếu sau màn hình, người ta dùng khá nhiều bóng sáng chói. Bảng đèn tự chế này bao gồm hàng trăm đèn diode phát quang LED, vừa cho ánh sáng lớn, vừa tiêu thụ ít điện hơn bóng thông thường dùng trong máy chiếu.

Tu lam may chieu bang do cu
Tìm hiểu công nghệ trình chiếu phim 3D

Điều gây ngạc nhiên là một số người không chỉ chế máy chiếu thông thường mà còn tạo ra máy chiếu 3D để trình diễn các không gian 3 chiều sống động. Cỗ máy đồng thời chiếu các hình hơi khác nhau của cùng một khung hình bằng cách dùng bộ lọc phân cực trực giao. Người xem khi đeo kính đặc biệt sẽ thấy không gian 3 chiều này.

Tu lam may chieu bang do cu
Tu lam may chieu bang do cu

Những hình ảnh 3D tự làm được thực hiện bằng cách kết hợp 2 chiếc webcam rẻ tiền để hình thành nên một máy quay kỹ thuật số 3 chiều.

Tu lam may chieu bang do cu

Thiết kế của máy chiếu tự chế khá đa dạng. Đây là một trong những mẫu có dáng dấp cổ điển vì được làm từ chiếc radio cũ.

Tần suất viếng thăm cao của bọ tìm kiếm trên Website của bạn là dấu hiệu tốt của việc chỉ số hóa Website của máy tìm kiếm. Đây là bước đầu tiên quan trọng trong việc tối ưu hóa Website cho máy tìm kiếm. Bài viết này sẽ cung cấp cho bạn 10 thủ thuật SEO nhằm tăng tần suất bọ tìm kiếm trên Website của bạn.

Việc bọ tìm kiếm của Google viếng thăm Website là dấu hiệu tốt cho việc Website được máy tìm kiếm đánh chỉ số đều đặn, đây là bước đầu tiên trong việc đứng hạng cao trên trang kết quả tìm kiếm. Tuy nhiên, bọ tìm kiếm chỉ viếng thăm thường xuyên và sâu trên Website của bạn khi nó coi Website đó là quan trọng và có giá trị.
Chú ý rằng bạn không thể ép buộc Googlebot viếng thăm Website của bạn thường xuyên, nhưng bạn có thể mời bọ tìm kiếmq viếng thăm. Sau đây là 10 thủ thuật bạn có thể áp dụng để tăng tần suất truy cập của bọ tìm kiếm (ví dụ : Googlebot hay Slurp Yahoo)

10 thủ thuật SEO cải thiện tần suất bọ tìm kiếm

Sau đầy là 10 thủ thuật SEO để bạn có thể cải thiện tần suất viếng thăm Website của bọ tìm kiếm :

  1. Cập nhật thường xuyên nội dung (và ping cho Google sau mỗi lần cập nhật). Hãy cố gắng tạo ra các nội dung duy nhất thường xuyên và đều đặn (3 lần một tuần nếu có thể nếu như bạn không thể cập nhật hàng ngày và tìm ra tần suất cập nhật tối ưu hóa);
  2. Đảm bảo rằng máy chủ hoạt động tốt : Xem thống kê Google Webmaster tools để biết được những trang lỗi. Ngoài ra còn có 2 công cụ bạn có thể thử để tìm lỗi : Pingdom and Mon.itor.us;
  3. Cải thiện thời gian tải trang (page load time) : Chú ý rằng, bọ tìm kiếm hoạt đông với một quĩ thời gian nhất định. Nếu nó phải sử dụng thời gian để đánh chỉ số một số lượng lớn hình ảnh hoặc tài liệu PDFs thì nó sẽ dành ít thời gian để thăm các trang khác;
  4. Kiểm tra cấu trúc Website : Chắc rằng không có nội dung trùng lặp nào trên Website thông qua một liên kết URL khác. một lần nữa, nếu như Googlebot mất thời gian đánh chỉ số các trang trùng lặp nội dung này thì chắc chắn nó sẽ không có thời gian ghé thăm trang khác;
  5. Có thêm nhiều liên kết trỏ đến (backlink) từ các Website được bọ tìm kiếm ghé thăm thường xuyên;
  6. Điều chỉnh tần suất đánh chỉ số của bọ tìm kiếm trong Google Webmaster Tools – Công cụ Google cho quản trị Web;
  7. Thêm sơ đồ Website Sitemap. Về lý thuyết sơ đồ Website sẽ giúp bọ tìm kiếm xác định nhanh chóng cấu trúc, nội dung Website và từ đó nó có thể đánh chỉ số tốt toàn bộ Website. Tuy nhiên cũng có một số Webmaster để ý thấy rằng tần suất của bọ tìm kiếm giảm hẳn sau khi thêm Sitemap và họ khuyến cáo không nên sử dụng Sitemap. Đây là vấn đề đang được tranh luận khá sôi nổi trên các diễn đàn Webmaster;
  8. Đảm bảo rằng máy chủ Web trả về các HTTP Header Status chính xác. Và bạn đã tạo ra một trang error 404 riêng trong trường hợp không tìm được tệp tin hay thư mục trên Website. Việc các Http Header được trả về chính xác giúp bọ tìm kiếm hiểu được chuyện gì đang xảy ra và đó là cách giải thích rõ ràng nhất cho máy tìm kiếm trong trường hợp có lỗi;
  9. Hãy sử dụng thẻ tiêu đề và thẻ Meta tags (ví dụ description hay keywords) duy nhất cho từng URL của Website.
  10. Theo dõi tần suất của bọ tìm kiếm Googlebot để xác định xem nội dung nó quan tâm và những vấn đề xảy ra nếu có (Xem tiếp phần sau).

Công cụ thống kê hoạt động của bọ tìm kiếm

Việc sử dụng các thủ thuật SEO trên chắc chắn sẽ làm tăng tần suất viếng thăm của bọ tìm kiếm. Tuy nhiên sau đó, bạn phải có một công cụ thống kế tính hiệu quả của các thủ thuật trên. Và đặc biệt hiểu được các thức hoạt động của bọ tìm kiếm, các phần được đánh chỉ số tốt và các phần lỗi, để sửa chữa kịp thời. Sau đây là một số công cụ hữu ích, bạn nên tham khảo.

  • Sử dụng công cụ cho Webmaster của Google : Google Webmaster tools;
  • Hình 1 : Tần suất bọ tìm kiếm từ Google Webmaster Tools
  • Để quản lý hoạt động của Googlebot trên Website, các Webmaster có thể sử dụng scripts rất hay CrawlTrack để thống kê và phân tích các hoạt động của rất nhiều bọ tìm kiếm trên Website.
  • Hình 2 : Tần suất bọ tìm kiếm của thủ thuật SEO sử dụng Crawler Track
  • Đối với người sử dụng WordPress, bạn có thể sử dụng Plugin WordPress Plugin that tracks crawl rate cho phép giám sát hoạt động của bọ tìm kiếm của Google, Yahoo, MSN và nhiều Search Engine khác.
  • Hình 3 : Tần suất bọ tìm kiếm sử dụng Crawl rate WordPress plugin
(Nguyễn Hoài Nam – vietSEO.net)
Powered by WordPress | Theme: by 85ideas. Editor by Khoanguyen