Sep 30, 2012

How to setup alternative on redhat(fedora)/Opensuse?

To view the help and we get more info.
alternatives version 1.3.59 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: alternatives --install <link> <name> <path> <priority>
                    [--initscript <service>]
                    [--slave <link> <name> <path>]*
       alternatives --remove <name> <path>
       alternatives --auto <name>
       alternatives --config <name>
       alternatives --display <name>
       alternatives --set <name> <path>

common options: --verbose --test --help --usage --version
                --altdir <directory> --admindir <directory>

Here's the exmaple
root@syntax3rror ~]# /sbin/alternatives --install /usr/bin/java java /opt/jdk1.6.0_23/bin/java 1
[root@syntax3rror ~]# /sbin/alternatives --config java

There are 4 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk/bin/java
   2           /opt/jdk1.6.0_23/bin/java

Enter to keep the current selection[+], or type selection number: 2

INFO: In openSuse the command was update-alternatives

How to install chrome in openSuse?

Here simple flow I found.

1. Add the google repository.
* For 64 bit
zypper ar http://dl.google.com/linux/chrome/rpm/stable/x86_64 Google-Chrome
* For 32 bit
zypper ar http://dl.google.com/linux/chrome/rpm/stable/i386 Google-Chrome

2. Now install
zypper ref
zypper in google-chrome-stable

Now you have your chrome.

NOTE: Command needs a root access.

Sep 27, 2012

Magento - How to create multiple fields to sort?

Find the class and made modification on the class.
Mage_Catalog_Block_Product_List_Toolbar

Find the getAvailableOrders() and made some modification.
     public function getAvailableOrders()
    {
        $orders = array(
            'news_from_date,entity_id'         => 'Newest',
            'name,brand'              => 'Brand Name',
            'rating'        => 'Top Rated',
        );

        $this->_availableOrder = $orders;
        
        return $orders;
    }

Also try to look setCollection($collection)
    public function setCollection($collection)
    {
        $this->_collection = $collection;

        $this->_collection->setCurPage($this->getCurrentPage());

        // we need to set pagination only if passed value integer and more that 0
        $limit = (int)$this->getLimit();
        if ($limit) {
            $this->_collection->setPageSize($limit);
        }
        
        if ($this->getCurrentOrder()) {
            // parse the attribute
            $orders = explode(',', $this->getCurrentOrder());
            foreach($orders as $order){
                // Add the other statement for to sort
                $this->_collection->setOrder($order, $this->getCurrentDirection());
            }
        return $this;
    }

Thanks just simple code to made multiple sorting. But i not suggest you to modify the magento core as is. if you can able to override class it better.

class Globe_Catalog_Block_Product_List_Toolbar 
  extends Mage_Catalog_Block_Product_List_Toolbar{

 // Your method you want here and method you want to override, some example.

    public function setCollection($collection)
    {
        $this->_collection = $collection;

        $this->_collection->setCurPage($this->getCurrentPage());

        // we need to set pagination only if passed value integer and more that 0
        $limit = (int)$this->getLimit();
        if ($limit) {
            $this->_collection->setPageSize($limit);
        }
        
        if ($this->getCurrentOrder()) {
            // parse the attribute
            $orders = explode(',', $this->getCurrentOrder());
            foreach($orders as $order){
                // Add the other statement for to sort
                $this->_collection->setOrder($order, $this->getCurrentDirection());
            }
        return $this;
    }
  

   // ... You other method.
}

Sep 26, 2012

How to enable Telnet in Windows7 or Windows Vista

In my XP before. telnet was enabled by default. However Windows 7 and Vista is not. :(

Here's how.
-> Start
-> Control Panel
-> Programs And Features
-> Turn Windows features on or off
-> Check Telnet Client

-> Hit OK

Happy reading

Sep 25, 2012

Fedora - How to changes brightness?

Just compile the possible solution on how to fix the issued in changes the brightness on your laptop.
Fedora 17
Add acpi_backlight=vendor in your kernel parameter.
* Edit /boot/grub2/grub.cfg and the the data below
linux   /vmlinuz-3.3.4-5.fc17.i686.PAE root=UUID=92d834db-f8d4-4075-9b3e-4d4c79ca8dfa ro nomodeset rd.md=0 rd.lvm=0 rd.dm=0 SYSFONT=True  KEYTABLE=us rd.luks=0 LANG=en_US.UTF-8 rhgb quiet 
acpi_backlight=vendor

* Edit the /etc/X11/xorg.conf and add Option "RegistryDwords" "EnableBrightnessControl=1" in the "Device" section.
Section "Device"
        Identifier "Videocard0"
        Driver "vesa"

       Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection

* Last thing reboot your system to take the changes.


* Or if the two process will not work. try also.
echo 3 > /sys/class/backlight/WHAT_EVER_THE_DIR/brightness

Fedora 15
1. Edit /etc/Xorg/xorg.conf to add the following line under Section "Device":
Option "RegistryDwords" "EnableBrightnessControl=1"

2. Edit /etc/default/grub and addacpi_osi=Linuxto theGRUB_CMDLINE_LINUX` setting, i.e.

GRUB_CMDLINE_LINUX="acpi_osi=Linux"

Finally is to update the grub and reboot
# sudo update-grub
# reboot.


Fedora 14
Find here fedora-14-how-to-make-samsung-fn

Some info about the issue here.
http://forums.fedoraforum.org/showthread.php?t=283868
http://www.coffeepowered.net/2011/11/13/enabling-brightness-controls-on-an-hp-envy-17-under-fedora-16/

Sep 19, 2012

How to prevent KIDNEY stone.

Kidneys are filtering the blood by removing salt, poison and any unwanted entering our body. And need to protect it.


How To prepare:
* First take a bunch of parsley or Cilantro (Coriander Leaves) or kinsay(Pilipino term) and wash it clean.
* Then cut it in small pieces and put it in a pot and pour clean water and boil it for ten minutes and let it cool down and then filter it and pour in a clean bottle and keep it inside refrigerator to cool.

Parsley (Cilantro) is known as best cleaning treatment for kidneys and it is natural!


As acknowledge to the first Author for sharing his/her thought. Find it here.

Java - Convert Staring to Date

Here's simple example how to do.
import java.util.*;
import java.text.*;
public class StringToDate {
  public static void main(String[] args) {
    try {
      String myDate="11-Sept-07";
      DateFormat formatter ; 
      Date date ; 
      // NOTE: myDate value must be same format so that 
      //     it will not get exception error
      formatter = new SimpleDateFormat("dd-MMM-yy");
      date = (Date)formatter.parse(str_date);  
      System.out.println("Today is " +date );
    } catch (ParseException e){
      System.out.println("Exception :"+e);
    }
  }
}

Sep 17, 2012

Fedora - Old version.

As seems sounds like fedora 17 has lot of bug and problem to some development kits/tools. Now I listing this old version for me to easy to find it.

Fedora 15
Fedora 14

Sep 14, 2012

How to setup alternative on redhat(fedora)/Opensuse?

To view the help and we get more info.
alternatives version 1.3.59 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: alternatives --install <link> <name> <path> <priority>
                    [--initscript <service>]
                    [--slave <link> <name> <path>]*
       alternatives --remove <name> <path>
       alternatives --auto <name>
       alternatives --config <name>
       alternatives --display <name>
       alternatives --set <name> <path>

common options: --verbose --test --help --usage --version
                --altdir <directory> --admindir <directory>

Here's the exmaple
root@syntax3rror ~]# /sbin/alternatives --install /usr/bin/java java /opt/jdk1.6.0_23/bin/java 1
[root@syntax3rror ~]# /sbin/alternatives --config java

There are 4 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk/bin/java
   2           /opt/jdk1.6.0_23/bin/java

Enter to keep the current selection[+], or type selection number: 2

INFO: In openSuse the command was update-alternatives

Sep 11, 2012

Struts2 - Iterating List of Map in struts jsp.

Java Object Declaration

Assume that the declaration was on servlet class that the getListMapmethod can access on your JSP file.
public List<Map<String, String>> getListMap(String pRatingCriteria){

  List<Map<String, String>> myList = new ArrayList<Map<String,String>>();
  Map<String, String> myMap = null;

  myMap = new HashMap<String, String>();
  myMap.put("fname", "Winzter");
  myMap.put("lname", "Corpuz");
  myList.add(myMap);


  myMap = new HashMap<String, String>();
  myMap.put("fname", "Winzter");
  myMap.put("lname", "Corpuz");
  myList.add(myMap);


  myMap = new HashMap<String, String>();
  myMap.put("fname", "Juan");
  myMap.put("lname", "Dela Cruz");
  myList.add(myMap);

  return myList;
}

Here your JSP code to iteration the List Map

<s:iterator var="myMap" value="getListMap()" status="rowStatus">
<tr>
  <td><s:property value="key" /></td>
  <td><s:property value="value" />%</td>
</tr>
</s:iterator>

Sep 4, 2012

Struts - Iteration Map in jsp using Struts

This just one example from.

<logic:iterate id="mapEntry" name="yourHashMap">
  <bean:define id="gift" name="mapEntry" property="value">
  <tr>
    <td><bean:write name="mapEntry" property="key"></td>
    <td><bean:write name="gift" property="productName"></td>
    <td><bean:write name="gift" property="price"></td>
  </tr>
</logic:iterate>
Or maybe like this one.
<s:iterator value="YourListMap" status="stat">
  <tr>
    <th><s:property value="#stat.index"/></th>
    <td><s:property value="key"/></td>
    <td><s:property value="value"/></td>
  </tr>
</s:iterator>
For more example:
  • Rich Snippets Testing Tool

    Warning: At least one field must be set for Hcard.

    hcard
      Warning: At least one field must be set for Hcard.
      Warning: Missing required field "name (fn)".
    
    Solution: Just check the Posted By.
    For some other info find here. this will help your too. Snippets warning

    Sep 1, 2012

    GAE - Truncating Datastore Data

    At this time there were no quick truncate for the Entities. Solution: Create data script in your servlet to delete.
    import com.google.appengine.api.datastore.DatastoreService;
    import com.google.appengine.api.datastore.DatastoreServiceFactory;
    import com.google.appengine.api.datastore.Entity;
    import com.google.appengine.api.datastore.PreparedQuery;
    import com.google.appengine.api.datastore.Query;
    ....
    @SuppressWarnings("serial")
    public class GreetingServiceImpl extends RemoteServiceServlet implements
      GreetingService {
    
      protected void doGet(HttpServletRequest req,
        HttpServletResponse resp)
        throws ServletException, IOException
      {
    
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
          Query query = new Query("YourKind");
          PreparedQuery pq = datastore.prepare(query);
          // Iterate the date
          for (Entity result : pq.asIterable()) {
          Transaction txn = datastore.beginTransaction();
          try {
            datastore.delete(result.getKey());
            txn.commit();
          } finally {
            if (txn.isActive()) {
              txn.rollback();
            }
          } 
        }
    
        }// doGet
    
    }// Class