Ant - Ant Installation

JDK is the software development kit for creating Java programs. Instructions below show you step-by-step how to install and set it up.

  1. Download Java Development Kit(JDK). Install it and follow the instructions shown on the screen.
  2. Create an environment variable JAVA_HOME and set its value to the folder path of you JDK installation(e.g. C:\Program Files\Java\jdk1.6.0_06).

    Java - Multithreaded Programming

    /**
     * Manager.java
     * Multithreaded example:
     * Give a job to each worker. As soon as a worker finishes his job, assign a new 
     *  job to the free worker.
     * @author Xuan Ngo
     */
    import java.util.ArrayList;
     
    public class Manager
    {
      public static void main(String[] args)
      {
        // Variables
        int iNumOfWorkers = 3;// Number of workers.
        int iNumOfJobs = 11;  // Number of jobs.
        long lWaitTime = 1000;// Time lapse before asking who workers are free.
     
        // Create jobs list.
        ArrayList<String> aJobsList = new ArrayList<String>();

    Selenium - Type characters

    /**
     * Type characters.
     * Assume that you have Internet Explorer and Selenium Server is running on your
     *  computer on default port 4444. Otherwise, change accordingly in the constructor.
     *  You need to change the encoding of your editor to support the Chinese characters below.
     * @Author: Xuan Ngo
     */
    import com.thoughtworks.selenium.DefaultSelenium;
     
    public class WritingExample
    {
      private DefaultSelenium m_oBrowser = null;
     
      public static void main(String[] args)
      {
        Writing oWriting = new Writing();
     
        // Type characters.

    Selenium - Select single/multiple options

    /**
     * Select single/multiple options.
     * Assume that you have Internet Explorer and Selenium Server is running on your
     *  computer on default port 4444. Otherwise, change accordingly in the constructor.
     * @Author: Xuan Ngo
     */
    import com.thoughtworks.selenium.DefaultSelenium;
     
    public class Select
    {
      private DefaultSelenium m_oBrowser = null;
     
      public static void main(String[] args)
      {
        Select oSelect = new Select();
     
        // Select single/multiple options.
        oSelect.runExamples();
      }
     
      // Constructor
      public Select()
      {

    Selenium - Check radio buttons and checkboxes

    /**
     * Un/Check radio buttons and checkboxes.
     * Assume that you have Internet Explorer and Selenium Server is running on your
     * computer on default port 4444. Otherwise, change accordingly in the constructor.
     * @Author: Xuan Ngo
     */
    import com.thoughtworks.selenium.DefaultSelenium;
     
    public class Check
    {
      private DefaultSelenium m_oBrowser = null;
     
      public static void main(String[] args)
      {
        Check oCheck = new Check();
     
        // Un/Check radio buttons and checkboxes.
        oCheck.runExamples();
      }
     
      // Constructor
      public Check()
      {

    Selenium - Click on any html element using different locators

    /**
     * Click on any html element in the webpage as long as you can use the locators to identify them.
     * Assume that you have Internet Explorer and Selenium Server is running on your
     *  computer on default port 4444. Otherwise, change accordingly in the constructor.
     * @Author: Xuan Ngo
     */
    import com.thoughtworks.selenium.DefaultSelenium;
     
    public class ClickAny
    {
      private DefaultSelenium m_oBrowser = null;
     
      public static void main(String[] args)
      {
        ClickAny oClickAny = new ClickAny();
     
        // Click on any html element in the webpage.

    Selenium - Click on link

    /**
     * Click on a simple link(e.g Next)
     * Assume that you have Internet Explorer and Selenium Server is running on your
     *  computer on default port 4444. Otherwise, change accordingly in the constructor.
     * @Author: Xuan Ngo
     */
    import com.thoughtworks.selenium.DefaultSelenium;
     
    public class ClickSimple
    {
      private DefaultSelenium m_oBrowser = null;
     
      public static void main(String[] args)
      {
        ClickSimple oClickSimple = new ClickSimple();
     
        // Click on Next link.
        oClickSimple.runExamples();
      }
     
      // Constructor

    Drupal - Difference between date, datetime and datestamp fields

    The difference resides in the way each field is stored in the database.
    date
    The date field is an ISO 8601 standard date. It is useful if you want to store incomplete dates, like year and month only. It is stored in the database as varchar field.
    datetime
    It is use for complete dates. It is stored in regular datetime field of the database.
    datestamp
    datestamp is the unix timestamp. It is discouraged to use this in favor of datetime.

    Reference:

    Drupal - Hide CCK field from input form

    The simplest way to do this is to enable Content Permissions module and then don't allow the intended user group to view or edit that particular field.

    Drupal - Create an empty module

    The following shows you step-by-step how to create an empty module.

    1. Create a directory for your module(e.g. my_empty_module/). The module directory name should be in lowercase and should not contain spaces. To avoid headaches, please restrict yourself to letters, numbers and underscores.

    Pages

    Subscribe to OpenWritings.net RSS