RSS

Category Archives: General

More Khmer fonts in Google Web Fonts API directory

By Danh Hong

http://www.google.com/webfonts?subset=khmer

 
Leave a comment

Posted by on May 21, 2012 in General

 

Create a Settings Page For Your WordPress Theme

Creating your own theme for WordPress is a great way to give your blog or other WordPress powered web site an original touch. But even the nicest looking theme is not that nice if you have to get under the hood and edit the theme’s HTML or PHP code whenever it’s time change some aspects of it. Especially, when it’s not you but a paying customer using your theme. Luckily, creating a settings page for your theme in WordPress is not very hard, and after reading this tutorial, you will be able to create one in no time!

 


Step 1 Deciding What Settings Are Needed

It all starts from the need: to create a clear and useful settings page, you have to figure out the things that will need to be changed and leave out everything else. Every new setting you add to the admin menus adds complexity to the user interface and risks making the theme harder to use. That’s why it’s better to be careful and handpick the options that are going to be changed often and leave out one time customizations that can easily be done changing one file inside the theme.

Another question to keep in mind is “Who is going to be changing these settings?” If the user is familiar with PHP and WordPress, it might be reasonable to expect that she is OK with embedding her Google Analytics code in the code herself, but you shouldn’t require that from a graphic designer, not to mention a writer who doesn’t even need to know anything about HTML and CSS.

Common ideas for things to define in theme settings include:

  • The site’s Google Analytics tracking code
  • The number of sidebars and their positioning (left, right, maybe even up and down)
  • Page width
  • The contents of your footer
  • Options for features that are specific to the theme, such as custom teaser formats.

Once you have collected the list of theme features that you’d like to control through a settings page, you are almost ready to start the implementation. Before you move on and create your settings page, you can save time by making sure that there isn’t a WordPress feature already available for the customization you have in mind. Widgets, custom menus, custom backgrounds and header images are all useful tools for making your theme customizable with a lot less work than required for creating your own settings. They are, however, topics for a different tutorial.

Settings Created in This Tutorial

For this tutorial, I dreamed up a theme front page that consists of a grid with a varying number of featured posts that can be picked, edited and reordered by the admin using a custom settings page.

In the editor, the front page elements will be presented as a list of elements to which new ones can be added using JavaScript and jQuery.

I like to be able to preview the admin page in the WordPress admin as I design the HTML, so I usually start by linking a settings page to WordPress, and only then move to designing the contents of the page. That’s why, our next step is creating a placeholder settings page and hooking it to WordPress.


Step 2 Hooking the Settings Page to WordPress

Creating a settings page starts by creating a function that sets up the menu and hooking it to the WordPress action admin_menu. This tells WordPress to call your function when its time to create the menus so that everything is done at its proper time. Add this code to your theme’s functions.php file:

  1. function setup_theme_admin_menus() {
  2.     // We will write the function contents very soon.
  3. }
  4. // This tells WordPress to call the function named ”setup_theme_admin_menus”
  5. // when it’s time to create the menu pages.
  6. add_action(“admin_menu”, ”setup_theme_admin_menus”);

We’ll now put the code for creating the settings pages inside the function we just created.

When creating your settings page, you have the choice of either adding the page as a submenu to one of the existing settings groups or of creating your own top level menu.

Adding a submenu is done with the function add_submenu_page:

  1. <?php add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function) ?>
  • $parent_slug is a unique identifier for the top menu page to which this submenu is added as a child.
  • $page_title is the title of the page to be added
  • $menu_title is the title shown in the menu (often a shorter version of $page_title
  • $capability is the minimum capability required from a user in order to have access to this menu.
  • $menu_slug is a unique identifier for the menu being created
  • $function is the name of a function that is called to handle (and render) this menu page

If you choose to add the menu page as a submenu to one of the WordPress groups, you can use the following values as the $parent_slug parameter:

  • Dashboard: index.php
  • Posts: edit.php
  • Media: upload.php
  • Links: link-manager.php
  • Pages: edit.php?post_type=page
  • Comments: edit-comments.php
  • Appearance: themes.php
  • Plugins: plugins.php
  • Users: users.php
  • Tools: tools.php
  • Settings: options-general.php

The Appearance group looks like a good candidate for placing our settings page. Let’s try that, and create our first settings page. Here’s an updated version of our menu setup function:

  1. function setup_theme_admin_menus() {
  2.     add_submenu_page(‘themes.php’,
  3.         ’Front Page Elements’, ’Front Page’, ’manage_options’,
  4.         ’front-page-elements’, ’theme_front_page_settings’);
  5. }

We still need to create the function theme_front_page_settings for this to work. Here it is in its simplest form:

  1. function theme_front_page_settings() {
  2.     echo ”Hello, world!”;
  3. }

And this is how it looks in action:

We also need to check that the user has the rights required for editing the settings page. To do that, add the following code at the beginning of the settings page function:

  1. // Check that the user is allowed to update options
  2. if (!current_user_can(‘manage_options’)) {
  3.     wp_die(‘You do not have sufficient permissions to access this page.’);
  4. }

Now, if a user who isn’t allowed to manage options comes to the settings page, she will see nothing but the message, “You do not have sufficient permissions to access this page.”

If your theme needs multiple settings pages, it can be confusing for the user to look for them scattered all around the menu structure. In that case, creating your own settings group makes it easier for the theme user to find all the menu pages for the theme.

To add your own settings group, you need to create a top level menu page and link the submenu pages to it. Here is a new version of our menu setup function. The add_menu_page function used to create the top level menu is similar to add_submenu_page except that it doesn’t take the $parent_slug parameter.

  1. function setup_theme_admin_menus() {
  2.     add_menu_page(‘Theme settings’, ’Example theme’, ’manage_options’,
  3.         ’tut_theme_settings’, ’theme_settings_page’);
  4.     add_submenu_page(‘tut_theme_settings’,
  5.         ’Front Page Elements’, ’Front Page’, ’manage_options’,
  6.         ’front-page-elements’, ’theme_front_page_settings’);
  7. }
  8. // We also need to add the handler function for the top level menu
  9. function theme_settings_page() {
  10.     echo ”Settings page”;
  11. }

If you test the code and refresh the WordPress admin, you’ll see your new menu group appear at the bottom of the menu list:

But something doesn’t look quite right yet. Clicking the top menu element doesn’t lead you to the “Front Page” menu but a menu page called “Example theme.” This is not consistent with how the other WordPress menus function, so let’s do one more thing: by changing the $menu_slug attribute in theadd_submenu_page call to the same value as in the top level menu, we can link the two menus so that selecting the top menu selects the front page menu:

  1. function setup_theme_admin_menus() {
  2.     add_menu_page(‘Theme settings’, ’Example theme’, ’manage_options’,
  3.         ’tut_theme_settings’, ’theme_settings_page’);
  4.     add_submenu_page(‘tut_theme_settings’,
  5.         ’Front Page Elements’, ’Front Page’, ’manage_options’,
  6.         ’tut_theme_settings’, ’theme_front_page_settings’);
  7. }
  8. function theme_settings_page() {
  9. }

Looks better. If you want to still improve the looks of your menu group, there are two optional fields in theadd_menu_page function that you will find useful. Just add the values after the function name in the method call:

  • $icon_url specifies the URL of an icon for the top level menu.
  • $position specifies the position of your menu group in the menu list. The higher the value, the lower the position in the menu.

Step 3 Creating the HTML Form For the Settings Pages

Now that we have created the settings page, and it shows up nicely in the side menu, it’s time to start adding some content. So, let’s go back to the list of settings we had in mind, and draft a page for editing them.

In this tutorial, we need a field for defining how many elements should be listed on one row, and a list for defining the actual elements. To start from the easier, let’s create a text field for the number of elements on one row. Edit your settings page function:

  1. function theme_front_page_settings() {
  2. ?>
  3.     <label for=”num_elements”>
  4.         Number of elements on a row:
  5.     </label>
  6.     <input type=”text” name=”num_elements” />
  7. <?php
  8. }

When you reload your settings page, you’ll see the first settings field appear:

To make the settings page fit seamlessly in the WordPress experience and to give your plugin a professional touch, it’s a best practice to use the CSS classes and styles that WordPress uses in its own settings pages. A good way to learn the tricks is to just go ahead and analyze the WordPress source code.

The most important thing is to wrap your setting page with a div with the class "wrap". Within that divelement, you can use many predefined styles such as headings, buttons, and form fields. Let’s start by styling the title of our settings page:

  • We will create a h2 heading for the page (You can use the heading tags from h2 to h6 to create headings with different sizes.)
  • We will show the theme settings page icon before the heading. (You can use the predefined WordPress icons with the screen_icon function. The function can take one of the following parameters: indexedituploadlink-managerpagescommentsthemespluginsusers,tools or options-general.)
  • We will put the input element inside a form and a table with the class form-table.
  1. function theme_front_page_settings() {
  2. ?>
  3.     <div class=”wrap”>
  4.         <?php screen_icon(‘themes’); ?> <h2>Front page elements</h2>
  5.         <form method=”POST” action=”">
  6.             <table class=”form-table”>
  7.                 <tr valign=”top”>
  8.                     <th scope=”row”>
  9.                         <label for=”num_elements”>
  10.                             Number of elements on a row:
  11.                         </label>
  12.                     </th>
  13.                     <td>
  14.                         <input type=”text” name=”num_elements” size=”25″ />
  15.                     </td>
  16.                 </tr>
  17.             </table>
  18.         </form>
  19.     </div>
  20. <?php
  21. }

Next, it’s time to start adding the elements.

To do this, we’ll use jQuery as it makes things much easier than writing JavaScript by from scratch, and comes bundled with WordPress. If you have used jQuery before, there is just one thing to keep in mind: the$ notation that you would normally use with jQuery doesn’t work in WordPress — you have to type the whole word, jQuery instead.

First, we’ll create the element for editing the settings for one main page block to serve as a template for the elements that are added by the user. Add this code right between the closing table tag and the closing form tag right after it.

  1. <?php $posts = get_posts(); ?>
  2. <li class=”front-page-element” id=”front-page-element-placeholder”>
  3.     <label for=”element-page-id”>Featured post:</label>
  4.     <select name=”element-page-id”>
  5.         <?php foreach ($posts as $post) : ?>
  6.             <option value=”<?php echo $post-<ID; ?>”>
  7.                 <?php echo $post-<post_title; ?>
  8.             </option>
  9.         <?php endforeach; ?>
  10.     </select>
  11.     <a href=”#”>Remove</a>
  12. </li>

Now, it looks like this:

Now that we have our template, it’s time to hide it and create the JavaScript for using it to create new featured post rows to the settings page. Set the style for the li element above to display:none;

  1. <li class=”front-page-element” id=”front-page-element-placeholder” style=”display:none”>

Then, we’ll create a list for holding the front page elements as they are added, and a link that the user will click to add the new elements. I’m repeating the entire HTML so that you can clearly see where the changes go:

  1. <div class=”wrap”>
  2.     <?php screen_icon(‘themes’); ?> <h2>Front page elements</h2>
  3.     <form method=”POST” action=”">
  4.         <table class=”form-table”>
  5.             <tr valign=”top”>
  6.                 <th scope=”row”>
  7.                     <label for=”num_elements”>
  8.                         Number of elements on a row:
  9.                     </label>
  10.                 </th>
  11.                 <td>
  12.                     <input type=”text” name=”num_elements” size=”25″ />
  13.                 </td>
  14.             </tr>
  15.         </table>
  16.         <h3>Featured posts</h3>
  17.         <ul id=”featured-posts-list”>
  18.         </ul>
  19.         <input type=”hidden” name=”element-max-id” />
  20.         <a href=”#” id=”add-featured-post”>Add featured post</a>
  21.     </form>
  22.     <li class=”front-page-element” id=”front-page-element-placeholder”
  23.         style=”display:none;”>
  24.         <label for=”element-page-id”>Featured post:</label>
  25.         <select name=”element-page-id”>
  26.             <?php foreach ($posts as $post) : ?>
  27.                 <option value=”<?php echo $post->ID; ?>”>
  28.                     <?php echo $post->post_title; ?>
  29.                 </option>
  30.             <?php endforeach; ?>
  31.         </select>
  32.         <a href=”#”>Remove</a>
  33.     </li>
  34. </div>

In a real-life theme it’s a good practice to put your JavaScript code in a separate file, but to make this tutorial a bit easier to follow, I am now adding the JavaScript in the same function with the HTML above, right before the wrap div:

  1. <script type=”text/javascript”>
  2.     var elementCounter = 0;
  3.     jQuery(document).ready(function() {
  4.         jQuery(“#add-featured-post”).click(function() {
  5.             var elementRow = jQuery(“#front-page-element-placeholder”).clone();
  6.             var newId = ”front-page-element-” + elementCounter;
  7.             elementRow.attr(“id”, newId);
  8.             elementRow.show();
  9.             var inputField = jQuery(“select”, elementRow);
  10.             inputField.attr(“name”, ”element-page-id-” + elementCounter);
  11.             var labelField = jQuery(“label”, elementRow);
  12.             labelField.attr(“for”, ”element-page-id-” + elementCounter);
  13.             elementCounter++;
  14.             jQuery(“input[name=element-max-id]“).val(elementCounter);
  15.             jQuery(“#featured-posts-list”).append(elementRow);
  16.             return false;
  17.         });
  18.     });
  19. </script>

The JavaScript code above creates a function that is called when the user clicks the link with id add-featured-post. This function clones the template list item we created earlier and updates its fields to have unique ids and names. This way they will all be properly sent with the form when the user clicks submit. The variable elementCounter contains the next id to add. It is also saved in a hidden field so that when the form is submitted, we know how many front page elements to expect.

If you click the “Add featured post” link a couple of times, you’ll see hownew elements are added to the list:

But when you click on the remove link, you’ll notice that nothing happens. Let’s add a function for removing elements from the list:

  1. function removeElement(element) {
  2.     jQuery(element).remove();
  3. }

We also need to call to the function. Add the following code right before incrementing elementCounter.

  1. var removeLink = jQuery(“a”, elementRow).click(function() {
  2.     removeElement(elementRow);
  3.     return false;
  4. });

Before moving on to saving the form, there is one more thing to do. We’ll use the ui.sortable jQuery plugin to make the front page elements sortable by dragging them on the page. To enable the sorting functionality, we’ll need to include the proper JavaScript file (which also comes bundled with WordPress). This can be done by adding the following line of code at the end of functions.php:

  1. if (is_admin()) {
  2.     wp_enqueue_script(‘jquery-ui-sortable’);
  3. }

Then, we’ll add the following JavaScript right before (or after) the jQuery("#add-featured-post").click function defined above.

  1. jQuery(“#featured-posts-list”).sortable( {
  2.     stop: function(event, ui) {
  3.         var i = 0;
  4.         jQuery(“li”, this).each(function() {
  5.             setElementId(this, i);
  6.             i++;
  7.         });
  8.         elementCounter = i;
  9.         jQuery(“input[name=element-max-id]“).val(elementCounter);
  10.     }
  11. });

This snippet makes the list sortable and adds an event that is called whenever the user finishes sorting. The event handler updates all the ids in the elements so that the new order is preserved also when saving the form (this will become clearer once we implement the saving). When writing this stop handler, I noticed that the code for setting the id for the contents of the template was duplicated in two places so I refactored it into its own function, which I placed right before theline with jQuery(document).ready():

  1. function setElementId(element, id) {
  2.     var newId = ”front-page-element-” + id;
  3.     jQuery(element).attr(“id”, newId);
  4.     var inputField = jQuery(“select”, element);
  5.     inputField.attr(“name”, ”element-page-id-” + id);
  6.     var labelField = jQuery(“label”, element);
  7.     labelField.attr(“for”, ”element-page-id-” + id);
  8. }

With adding new elements, sorting them, and removing them working, it’s time to move on to saving the data. But before that, add a submit button right before the form’s closing tag.

  1. <p>
  2.     <input type=”submit” value=”Save settings” class=”button-primary”/>
  3. </p>

Step 4 Saving the Form

The settings page looks good, but there is something missing: it doesn’t do anything yet. It’s time to save some data. WordPress provides an easy system for saving theme and plugin settings as key value pairs to the database using two functions: get_option and update_option. The data stored using the functions can be as simple as a number value or as complex as an array nested multiple times.

The handling of the form is done in the same function that renders the form. To know whether a form was submitted or not, we add a hidden field, update_settings to the form and then check whether that field was sent or not in the handling function.

  1. if (isset($_POST["update_settings"])) {
  2.     // Do the saving
  3. }

The hidden field that goes inside the form looks like this:

  1. <input type=”hidden” name=”update_settings” value=”Y” />

Let’s start by saving the easier setting, num_elements. We’ll escape the attribute to make sure the user isn’t sending malicious content in the from of HTML tags and then save it to the WordPress settings storage. When using update_option, we don’t need to worry about whether the setting has already been saved or not.

  1. $num_elements = esc_attr($_POST["num_elements"]);
  2. update_option(“theme_name_num_elements”, $num_elements);

Before we move to saving the list, let’s add the current value of num_elements to the settings form so that the user always sees what value she has entered in before deciding the next value. This will also help us test that the value was actually saved.

  1. <input type=”text” name=”num_elements” value=”<?php echo $num_elements;?>” size=”25″ />

And for cases where we haven’t saved anything yet, we’ll need to load the current value from options, so let’s add this piece of code to be executed when there is no form submitted.

  1. $num_elements = get_option(“theme_name_num_elements”);

When a form is saved, it’s important to notify the user so that she isn’t left wondering whether something happened or not. So, let’s render a simple notice saying “Settings saved.” right after the update_option:

  1. ?>
  2.     <div id=”message” class=”updated”>Settings saved</div>
  3. <?php

Then, let’s save the front page elements. The highest id value in the front page elements is passed in aselement-max-id, so we can take that value and loop through elements up to that id, saving their data into an array in the correct order:

  1. $front_page_elements = array();
  2. $max_id = esc_attr($_POST["element-max-id"]);
  3. for ($i = 0; $i < $max_id; $i ++) {
  4.     $field_name = ”element-page-id-” . $i;
  5.     if (isset($_POST[$field_name])) {
  6.         $front_page_elements[] = esc_attr($_POST[$field_name]);
  7.     }
  8. }
  9. update_option(“theme_name_front_page_elements”, $front_page_elements);

This saves the data, but we still need to present the values on the settings page. So, let’s do the same as with the num_elements field and load the default options in the beginning of the function:

  1. $front_page_elements = get_option(“theme_name_front_page_elements”);

And then, render the existing elements when doing the form:

  1. <?php $element_counter = 0; foreach ($front_page_elements as $element) : ?>
  2.     <li class=”front-page-element” id=”front-page-element-<?php echo $element_counter; ?>”>
  3.         <label for=”element-page-id-<?php $element_counter; ?>”>Featured post:</label>
  4.         <select name=”element-page-id-<?php $element_counter; ?>”>
  5.         <?php foreach ($posts as $post) : ?>
  6.             <?php $selected = ($post->ID == $element) ? ”selected” : ”"; ?>
  7.             <option value=”<?php echo $post->ID; ?>” <?php echo $selected; ?>>
  8.                 <?php echo $post->post_title; ?>
  9.             </option>
  10.         <?php endforeach; ?>
  11.         </select>
  12.         <a href=”#” onclick=”removeElement(jQuery(this).closest(‘.front-page-element’));”>Remove</a>
  13.     </li>
  14. <?php $element_counter++; endforeach; ?>

We also need to set the initial value for the elementCounter variable used in JavaScript by setting the hidden field’s initial value in PHP and reading it in when initializing the JavaScript variable:

  1. <input type=”hidden” name=”element-max-id” value=”<?php echo $element_counter; ?>” />

And the JavaScript part:

  1. var elementCounter = jQuery(“input[name=element-max-id]“).val();

Step 5 Using the Settings Inside the Theme

Saving and showing settings values within the admin area is great, but what really counts is how you use them to customize your theme, so now, we have come to the point where it’s time to take our settings and do something cool with them.

From here on, changes go to index.php instead of functions.php. First, we’ll read the options to variables:

  1. <?php
  2.     $num_elements = get_option(“theme_name_num_elements”);
  3.     $elements = get_option(“theme_name_front_page_elements”);
  4. ?>

Let’s loop through the $elements list, grouping them into rows with $num_elements blocks on each.

  1. <div id=”front-page-element-container”>
  2.     <div class=”front-page-element-row”>
  3.         <?php foreach($elements as $post_id) : ?>
  4.             <?php if ($num == $num_elements) : ?>
  5.                 </div>
  6.                 <div class=”front-page-element-row”>
  7.             <?php endif; ?>
  8.             <!– Render element here –>
  9.         <?php endforeach; ?>
  10.     </div>
  11. </div>

And then, using the data saved for each element, we’ll fill in the element rendering part above:

  1. <?php $element_post = get_post($post_id); ?>
  2. <div class=”front-page-element”>
  3.     <div class=”thumbnail-image”>
  4.         <?php if (has_post_thumbnail($post_id)) : ?>
  5.             <?php echo get_the_post_thumbnail($post_id, ’tutorial-thumb-size’); ?>
  6.         <?php endif; ?>
  7.         <a class=”title” href=”<?php echo get_permalink($post_id); ?>”><?php echo $element_post->post_title;?></a>
  8.     </div>
  9. </div>

With a couple elements, it looks like this:

Still quite boring. The posts don’t have thumbnail images and there is no styling for them. To make them look better, let’s first add support for post thumbnail images. This is done by hooking a new function that sets up theme features to be called right after the theme has been loaded

  1. function setup_theme_features() {
  2.     if (function_exists(‘add_theme_support’)) {
  3.         add_theme_support(‘post-thumbnails’);
  4.     }
  5.     if (function_exists(“add_image_size”)) {
  6.         add_image_size(‘tutorial-thumb-size’, 200, 200, true);
  7.     }
  8. }
  9. add_action(‘after_setup_theme’, ’setup_theme_features’);

The function, setup_theme_features turns on the post thumbnails using WordPress functionadd_theme_support so that WordPress adds this functionality to the post saving page. On the post’s page, we can now add one image as thumbnail by clicking on “Use as featured image” on the image upload page after uploading the photo.

The function also defines a new image size type, tutorial-thumb-size which is used when getting the post thumbnail in the rendering code.

After selecting the featured image, save the changes and reload the front page. Looks more interesting already:

Finally, we’ll add a few styles to style.css, and there we go, the theme has a configurable featured posts display:

  1. .front-page-element-row {
  2.     overflow: auto;
  3. }
  4. .front-page-element {
  5.     float: left;
  6.     margin: 10px 10px 10px 10px;
  7.     padding: 0px;
  8.     width: 200px;
  9.     height: 200px;
  10. }
  11. .thumbnail-image {
  12.     width: 200px;
  13.     height: 200px;
  14.     background: #eee;
  15.     position: relative;
  16. }
  17. .thumbnail-image .title {
  18.     position: absolute;
  19.     bottombottom: 20px;
  20.     display: block;
  21.     background: #000;
  22.     color: #fff;
  23.     padding: 10px;
  24.     font-family: Arial;
  25.     font-size: 12pt;
  26.     text-decoration: none;
  27. }

Conclusion

Now, we have created a settings page for a custom theme. The theme is far from complete, but I hope this introduction got you started with adding settings and customizable elements to your next WordPress theme.

 
1 Comment

Posted by on May 16, 2012 in General

 

Not able to run ASP.NET web app using Development Server

Changing “localhost” to “127.0.0.1″ worked well for me, as well.

Browse to “C:\Windows\System32\Drivers\etc” -> open file’s called [hosts] with texteditor

Go to last line of the page and make sure like that:

# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost

 

 
Leave a comment

Posted by on May 7, 2012 in General

 

លេងហ្គេមរបស់ម៉ាស៊ីន PS2 នៅលើកុំព្យូទ័រ ជាមួយនិង Best Configuration

មិត្តអ្នកអានមួយចំនួន បានស្គាល់ពីម៉ាស៊ីនហ្គេម PS2 ហើយថាវាជាម៉ាស៊ីនហ្គេមដែលមានប្រជាប្រិយភាព ក្នុងពេលបច្ចុប្បន្ននេះ ទោះបីជាម៉ាស៊ីនហ្គេមនេះស្ថិតនៅសេរីចាស់ មិនដូចម៉ាស៊ីនហ្គេមជំនាន់ថ្មីដូចជា XBOX 360, Wii, PS3 ក៏ដោយ ប៉ុន្តែហ្គេមរបស់វានូវតែត្រូវបានមនុស្សជាច្រើនលាននាក់នៅលើពិភពលោកលេងកម្សាន្ត ហើយថែមទាំងត្រូវបានគេកោតសរសើថាល្អ ពិតជាសប្បាយលេងថែមទៀត។

ដូច្នេះថ្ងៃនេះ CM បានយកកម្មវិធីមួយដែលត្រូវបានគេស្គាល់ថាជាកម្មវិធីលេងហ្គេម PS2 លើកុំព្យូទ័រ ល្អជាងគេនិងឈានមុខគេមកបង្ហាញប្រាប់មិត្តអ្នកអាន។ កម្មវិធីនេះឈ្មោះថា PCSX2 ជំនាន់ទី0.98 r4600ហើយ CM យើងបានរៀបចំនូវ Plug-in with Biosដើម្បីឱ្យហ្គេមរបស់យើងលេងហ្គេមបានស្រួល និង សម្លេងគ្មានភាពរអាក់រអួលផងដែរ។

Download :  Visual C++ 2010 (x86) runtime package  (ចាំបាច់សម្រាប់ដំណើរការកម្មវិធី)

Download : PCSX2

តម្រូវការកម្មវីធី

សម្រាប់ម៉ាស៊ីនទាបបំផុត ល្បឿនហ្គេម (90-95%)

    • CPU : Intel Dual Core 1.7Ghz
    • Ram : 1GB
    • VGA: 128MB

សម្រាប់ម៉ាស៊ីនដែលដំណើរការស្រួល ល្បឿនហ្គេម (95-100%)

    • CPU : Intel Core 2 Duo 2.0Ghz
    • Ram : 1GB
    • VGA: 512 MB

វិធី Configuration ទីតាំងរបស់ Plug-in និង Biosដំបូង

នៅពេលដំណើរការដំបូងវាទាមទារឱ្យយើងជ្រើសរើសទីតាំង Plug-in, Bios និង Memory Card ជាដើម។

តែយើងក៏អាច Configuration ទីតាំងនេះសារជាថ្មីម្តងទៀតដោយចូលទៅកាន់

Config => Plugin/Bios Selector រួចកំណត់ដូចខាងក្រោមៈ

វិធីសាស្រ្ត Configuration ដើម្បីឱ្យហ្គេមលេងបានស្រួលនិងមានល្បឿនលឿន

  • ភាពខុសគ្នារវាង Disc ឬ ISO ប្រភេទ NTSC និង PAL

NTSC មានល្បឿនលឿនជាង PAL ព្រោះ speed របស់ វាដល់ទៅ 60fps, ប៉ុន្តែរូបភាព និង សម្លេងអន់បន្តិច តែយើងគួរប្រើប្រាស់Disc ឬ ISO ប្រភេទ NTSC នេះព្រោះវាអាចជួយឱ្យយើងលេង ហ្គេមបានលឿន ជាមួយរូបភាពដែលអាចទទួលយកបាន។

PAL មានល្បឿនយឺត speed របស់វាត្រឹមតែ 50fps ប៉ុន្តែរូបភាពស្អាត និង សម្លេងច្បាស់ល្អ ។ យើងអាចលេងហ្គេមវាបានលុះត្រាតែម៉ាស៊ីនកុំព្យូទ័ររបស់យើងខ្ពស់។

  • ភាពខុសគ្នារវាង Gsdx9 Hardware និង Software :   (ចូលទៅកាន់ Config => Video GS => Plugin setting)
  • ប្រសិនបើយើងជ្រើសរើសយក Gsdx9: Direct3D9 Hardware វាមានល្បឿនលឿនក្នុងការលេង ប៉ុន្តែវា មិន Support ល្អទេចំពោះ Disc ឬ ISO ប្រភេទ NTSC។ ប្រសិនបើដំណើរការហ្គេមមិនឃើញរូបជាមួយ Disc ឬ ISO ប្រភេទ NTSC សូមចុច F5។
  • តែបើយើងជ្រើសរើសយក Gsdx9: Direct3D9 Software វិញ វាបច្ចេញរូបភាពដូច PS2 តែម្តង ហើយ Support គ្រប់ប្រភេទ Disc ឬ ISO ប្រភេទ NTSC តែវាមានល្បឿនយឺតបន្តិច តែបើ PC យើងកម្រិតខ្ពស់គឺគ្មានបញ្ហាទេ។
    • ការកែរប្រែមួយចំនួនដើម្បីឱ្យហ្គេម PS2 ដើរលឿន:
    • ប្រើប្រាស់ Disc ឬ ISO ប្រភេទ NTCS :
    • ប្រើប្រាស់ Gsdx9 : Direct3D9 Hardware ជាមួយនិងការ Tick យក Native
    • កែរសម្រួលជម្រើសមួយចំនួនដូចខាងក្រោមៈចូលទៅកាន់ Config => Emulation settings

របៀបដាក់ ISO ទៅក្នុង Emulator

CDVD => Iso Selector => Browsers រួចរកទីតាំងរបស់ ISO File ជាការស្រេច។

របៀបដាក់ ដំណើរការហ្គេម

System => Boot CDVD Full

x ប្រសិនបើយើងជ្រើសរើសយក Gsdx9: Direct3D9 Hardware វាមានល្បឿនលឿនក្នុងការលេង ប៉ុន្តែវា មិន Support ល្អទេចំពោះ Disc ឬ ISO ប្រភេទ NTSC។ ប្រសិនបើដំណើរការហ្គេមមិនឃើញរូបជាមួយ Disc ឬ ISO ប្រភេទ NTSC សូមចុច F5។

Referenced by: http://cm.com.kh/2012/03/emulator-ps2-pcsx2/?fb_ref=AL2FB&fb_source=tickerdialog_oneline

 
Leave a comment

Posted by on March 12, 2012 in General

 

Windows Service Application

How to create a setup project for a window service application in Visual Studio C#

Requirement

  • Microsoft Windows 200/XP/Server 2003/Vista/Seven with .NET Framework installed.
  • Microsoft Visual Studio .NET 2005/2008

Create a Windows Service Project

  1. Start Microsoft Visual Studio
  2. On the File menu, point to New, and Click on Project.
  3. Click Visual C# Projects under Project Types, and then click Windows Service under Templates.

Use a Compiled Setup Project to Install the Windows Service

 
Leave a comment

Posted by on October 15, 2011 in General

 

Share Root Drive(\\RemoteMachine\C$) in Windows 7

User Account Control (UAC) is a new security component of Windows Vista. UAC enables users to perform common day-to-day tasks as non-administrators. These users are called “standard users” in Windows Vista. User accounts that are members of the local Administrators group will run most applications by using the principle of “least privilege.” In this scenario, least-privileged users have rights that resemble the rights of a standard user account. However, when a member of the local Administrators group has to perform a task that requires administrator rights, Windows Vista automatically prompts the user for approval.

To disable UAC remote restrictions, follow these steps:

  1. Click Start, click Run, type regedit, and then press ENTER.
  2. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. If the LocalAccountTokenFilterPolicy registry entry does not exist, follow these steps:
    1. On the Edit menu, point to New, and then click DWORD Value.
    2. Type LocalAccountTokenFilterPolicy, and then press ENTER.
  4. Right-click LocalAccountTokenFilterPolicy, and then click Modify.
  5. In the Value data box, type 1, and then click OK.
  6. Exit Registry Editor.
There is a registry key which will be able to utilize to alter this performance to work the similar as Windows XP. This will create your PC less safe, and I can’t suggest that you do this but it’s also fine to appreciate how Windows executes.

Manual Registry Hack

Explore regedit.exe during the start menu search or run box, and after that navigate down to the below key, making another key if it doesn’t be present.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Policies\System

 
Leave a comment

Posted by on September 1, 2011 in General

 

HOWTO: Bare-Metal Restores from Windows Server 2008 Backup

Using the Windows Recovery Environment on Windows Server 2008 you can perform a bare-metal restore to recover your server operating system or the entire server itself. An operating system restore will only recover critical drive volumes that contain system components. If you would like to restore all volumes, you will need to conduct a full server recovery.

Before attempting to complete an operating system or full server restoration from a drive image backup created with BackupAssist, make sure of the following:

  • You have a Windows Server 2008 setup/installation disc.
  • If you are recovering to a new hard disk, make sure the disk is at least as big as the disk that contained the volumes that were backed up, regardless of the size of those volumes. For example, if there was only one volume that was 100 GB on a 1 TB disk during backup, you should use a disk that is at least 1 TB when restoring.
  • If you are recovering just the operating system, make sure that you have a backup available that contains at least the critical volumes of the server. If you are recovering the full server, make sure that you have a backup available that contains all volumes of the server.
Performing a bare metal recovery – step by step
  1. Windows Imaging RestoreBoot the Windows Server 2008 from the installation media and select the appropriate settings for:
    1. Language to install
    2. Time and currency format
    3. Keyboard or input format.

    When you’ve selected your settings, click on the Next button.

  2. Windows Imaging RestoreIn the next window, select the Repair your Computer option from the lower left corner of the console.
  3. Windows Imaging RestoreFrom the System Recovery Options window, you can choose to load any drivers required by your hard disk at this stage.  After loading any necessary drivers, such as RAID drivers, click on the Next button.

    Note that if you are performing a bare-metal restore to a brand new hard-disk, you will not see any Operating Systems listed as shown on the right. 

    If you are restoring a backup to a machine that already has Windows 2008, then it will be listed under Operating Systems. 

  4. Windows Imaging RestoreUnder the System Recovery Options window, select theWindows Complete PC Restoreoption. This will invoke theWindows Recovery Environment.
  5. Windows will then scan your machine for available backups. Please ensure that the media with your backup is connected to the machine. If Windows Complete PC Restore is unable to find the backup, please try un-connecting and re-connecting the backup device.
  6. Restore from a backupOnce your backup disk has been detected, you may choose to restore the latest backup or another backup. Windows 2008 will automatically choose your latest backup by default.

    Select the backup you want to restore from and click on the Nextbutton.

  7. In the Choose how to restore your backupwindow, you have the following options:
    1. Install any drivers for the disk you are restoring to by clicking on the Install Drivers button.
    2. Exclude disks that you don’t want formatted by clicking on the Exclude disks button.
    3. Choose to restart the computer after the restore process and to automatically check and update error information by clicking on the Advanced button.

    Once you have added the extra options, click on the Next button.

  8. Backup LocationSelect the location of your backup and click on the Next button.
  9. Confirm restore settingsConfirm your settings and click on the Finish button.
  10. Windows Recovery Environment will ask you whether you want to let Windows Complete PC Restore format the disks and restore the backups you have chosen. Click on the OK button.
  11. Your bare-metal restore of Windows Server 2008 should begin. Once done, your system should reboot and Windows will load. Congratulations – the procedure is complete!
 
Leave a comment

Posted by on August 22, 2011 in General

 

How to create your own private cloud

We used Ubuntu’s Enterprise Server, which is a freely downloadble solution to let you build your own IaaS based private cloud in your data center

BANGALORE, INDIA: Most discussions around Cloud Computing nowadays are either focused on the security issues associated with it, or providing basic definitions of the three different types of Cloud based services i.e SaaS, PaaS and IaaS. A third thing is of course the loud noise created by all the vendors around their own cloud based offerings.There’s hardly anybody talking about actual usage of cloud computing. Which public cloud service should you choose? What’s a private cloud and how to get started on it? What are the tools that would let me create my own private cloud? There are very few discussions on these aspects.

So while the public cloud based services have been covered elsewhere in our cover story, in this story we’ll focus on how to build your own private IaaS (Infrastructure as a Service) based private cloud. For this, we’ve used Ubuntu’s 10.04 Server Edition, which is completely free. We’ve given it on this month’s DVD, else you can download it from ubuntu.com/cloud/private.

The benefits of setting this up are many. It has the elasticity to grow or shrink your compute capacity based on your application’s needs. You can rapidly deploy new applications whenever required on your existing IT infrastructure. This way, you don’t end up investing in additional hardware resources. The Ubuntu Enterprise Cloud provides the same APIs as the popular EC2 cloud from Amazon, so if you’ve worked with that, this should be a piece of cake. What you create and run on Ubuntu, you can also run on EC2.

Let’s Implement
You need at least two servers for deploying the Ubuntu Cloud. One (Machine A) would act as the cloud, cluster, warehouse, and storage controller; while the other (Machine B) would be the node controller. One thing to keep in mind is that the node controller should support virtualization as virtual machines would be running on it.

By default a single virtual machine would run per core, therefore having a multi-core node controller is highly recommended. We configured Machine A on a Core2duo X6800 processor based machine with 2 GB DDR 2 RAM and 80 GB HDD. Machine B was running on an AMD Phenome II X4 965 processor with 4 GB DDR 3 RAM and 250 GB HDD.

To install the Ubuntu based Cloud, select ‘Install Ubuntu Enterprise Cloud’ from the first screen for installation on both Machines A and B.

http://www.ciol.com/Developer/Enterprise-Tools/Feature/How-to-create-your-own-private-cloud/140551/0/

 
Leave a comment

Posted by on June 29, 2011 in General

 

Metallic Chrome Text

In this tutorial, i’ll show you some simple steps in creating a chrome text effect= by applying just a few styles..

Start a new document and fill the background with white.

Press “D” to reset your colors to black and white

Use the type tool to create your text. Make it fairly large.

 

Then go to Layers » Layer Style » Satin

Then go to Layers » Layer Style » Bevel & Emboss (just check the bevel & emboss box since you already got the layer style box open)

Then go to Layers » Layer Style » Drop Shadow. (just check the drop shadow box since you already got the layer style box open)

Referenced by: http://www.tutorialwiz.com/chrome/

 
Leave a comment

Posted by on March 7, 2011 in General

 

How to design social network database

 

The Tables

Want to hear the best part about all of this? The core idea of myspace, and indeed all of the social networking sites, is the ability to connect to friends or colleagues and have them listed on your page. This can be accomplished with a total of two, yes, you heard it, two database tables. Figure shows an example of what these tables might look like. Please note that the Accounts table should have a lot more information

Querying The Data

In this section you will find common queries that you can use to pull data out of the database. For example, Listing 1 shows how you would get a list of your friends.

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.friendID
WHERE f.AccountID = @ID

Listing 1: Selecting all of your friends

If you want to see everyone that has assigned you as a friend, use the query in Listing 2 .

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.AccountID
WHERE f.FriendID = @ID

Listing 2: Selecting everyone that has you as a friend

And depending on your implementation, if you want to simply see everyone you are friends with (whether you added them, or they added you), you can use the UNION keyword to combine the results of both queries shown above (Listing 3).

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.friendID
WHERE f.AccountID = @ID

UNION

SELECT DISTINCT a.*
FROM Accounts a
INNER JOIN Friends f ON a.ID = f.AccountID
WHERE f.FriendID = @ID

Listing 3: Query for everyone you are friends with (Mutually Inclusive).

Listing 4 will tell you if someone is the current user’s friend. The current user’s ID will be in the @ID parameter, whereas the person whom you are trying to determine is a friend or not will be in the @Friend parameter. When the count value is returned, if it is greater than zero, the person is a friend.

SELECT count(*)
FROM Friends f
WHERE
(f.AccountID = @ID AND f.FriendID = @Friend)
OR
(f.AccountID = @Friend AND f.FriendID = @ID)

Listing 4: Figure out if someone is your Friend.

 

Referenced by: http://dbdesign-sn.blogspot.com/2008/11/how-to-design-social-network-database.html

 
Leave a comment

Posted by on February 10, 2011 in General

 
 
Follow

Get every new post delivered to your Inbox.