Dec 12, 2012

GAE- Generate Child Entity key

Here the simple way to make.

ParentEntity.getKey().getChild(ChildKind, keyname);

GAE- The method addFilter(String, Query.FilterOperator, Object) from the type Query is deprecated

In this situation, we can fixed this by changing out code.


Import the Libraries
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.CompositeFilterOperator;
import com.google.appengine.api.datastore.Query.FilterOperator;

Sample:
Query query = new Query(Kind);
query.addFilter("active", FilterOperator.EQUAL, 1l);
query.addFilter("user", FilterOperator.EQUAL, _user);

Solution1:
Filter activeFilter =
  new FilterPredicate("active",FilterOperator.EQUAL,1l);
Filter userFilter =
  new FilterPredicate("user",FilterOperator.EQUAL,_user);

// Combine the Two filter
Filter queryFilter =
  CompositeFilterOperator.and(activeFilter, userFilter);

// Use class Query to assemble a query
Query q = new Query("Person").setFilter(queryFilter);

Solution 2
query = new Query(Kind);
query.setFilter(CompositeFilterOperator.and(
  FilterOperator.EQUAL.of("active", 1l),
  FilterOperator.EQUAL.of("user", _user)
  )
);

If you want look more info you cant find Datastore Queries and GAE Query

Happy Reading

Nov 13, 2012

GAE - How to download your code in appengine server.

Here the simple way to do.

PATH_OF_YOUR_APPENGINE_SDK/bin/appcfg.sh --application=YOUR_APP_ID --email=xxxx@gmail.com download_app war

GAE - Setting mimetype manually in Web Apps

Google Appengine Static Files

In some static files. Google Appengine send a wrong mimetype and mostly set application/octet-stream.

To be fixed the minetype, we need to configure the mapping on your web.xml. See sample below how to declare the mapping.

  <mime-mapping>
        <extension>wsdl</extension>
        <mime-type>text/xml</mime-type>
  </mime-mapping>

Happy reading

Oct 18, 2012

Magento: How to add static block in your layout file?

Here we need to do, create static block, and assume we set the "my_test_static_block" as our name/identifier.

As we already created the static block. Place the code below in you layout (xml) file

<block type="cms/block" name="test_main_block">
 <action method="setBlockId">
   <block_id>my_test_static_block</block_id>
 </action>
</block>


See attached image for the sample.

Magento: How to add static block in your template file?

Here we need to do, create static block, and assume we set the "my_test_static_block" as our name/identifier.

As we already created the static block. Place the code below in you template (phtml) file.

<?php
echo $this->getLayout()
  ->createBlock('cms/block')
  ->setBlockId('my_test_static_block')
  ->toHTML();
?>

In you looking how to add static in your layout file you found in this link.


Happy reading.

Oct 12, 2012

How to create Live Fedora on USB in Opensuse?

Try to follow this one.

* Find you USB Drive.
# grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)
Creating the partition

For me my USB was only design as Live Bootable Disk, in create the new partition I decide to delete current parting and create new one. * Selecting the Disk

# /sbin/fdisk /dev/sdb
* Atfer selected, issue m option to display the help
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
* Delete the partition:
Command (m for help): d
Selected partition 1
* Create Partition
Command (m for help): n Press n and hit enter
Command action
   e   extended
   p   primary partition (1-4)
p Press p and hit enter
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3948543, default 2048):  Just hit enter here
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3948543, default 3948543): Just hit enter here
Using default value 3948543
* Tag the Partition as bootable.
Command (m for help): a Press n and hit enter
Partition number (1-4): 1 As you create only partition press 1
* Verify the partition you create.
Command (m for help): p

Disk /dev/sdb: 2021 MB, 2021654528 bytes
42 heads, 4 sectors/track, 23503 cylinders, total 3948544 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001f52c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     3948543     1973248   83  Linux
INFO: As you notice Boot colunm has start(*) * Finally you done creating partition, now write the partition in the disk.
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
Now, write the Live ISO to your USB
# dd if=/home/syntax3rror/Downloads/Fedora-17-i686-Live-KDE.iso of=/dev/sdb
1423360+0 records in
1423360+0 records out
728760320 bytes (729 MB) copied, 286.532 s, 2.5 MB/s
YEHEY, Your done, you can now able to boot Fedora17 live in your USB. just be sure to change the boot priority of your system bios.

IMPORTANT NOTE

* Besure the device NOT mounted. If ever mounted you can umount /dev/sdb * Besure to backups all you important data in you USB. * Besure to use /dev/sdb as device name and NOT /dev/sdb1

Happy Reading and Post if works for you

Oct 4, 2012

Magento - How to access Toolbar property from your list template.

Here's the solution.
In you Catalog List Block add new method.
class Mage_Catalog_Block_Product_List extends ...{

    ....

    // I want to access the get pager in my list.phtml template.
    public function getPagerHtml(){
        return $page = $this->getToolbarBlock()->getPagerHtml();
    }
}

In you list.phtml template has now able to display the pager html.
<?php echo $this->getPagerHtml() ?>

If this help you, dont forget to comment. Enjoooy reading.

Oct 2, 2012

How to enable/install apache mod_rewrite?

From my long time using Redhat. I familiarize how yum work for it. But sadly I switch to Suse cousing teh fedora 17 can't work to change the brightness on my HP Laptop. :((

But now, in the help of google I found it as simple, just need as root access in your terminal and type the command.
a2enmod rewrite

Besure also to to change your apache setting.
From
AllowOverride None
To
AllowOverride All

Happy reading and hope will work to you too.

Oct 1, 2012

How to change HOSTNAME in openSUSE?

you can do this in two step.

* Via you terminal type:
# hostname

Example:
# hostname winzter.syntax3rror.co.cc

* Modify the hostname file
# vi /etc/HOSTNAME


hAppy reading. :)

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
    
    

    Aug 30, 2012

    Google mail(gmail) search tips.

    Looking for an email from user with image(s) attach.
    from:test@test.com.ph filename:(jpg OR jpeg OR png)

    Linux - Solution for Numpad not working.

    One morning I got crazy on my numpad coz its not working, even do it was ON. I dont even know what is the combination of keys I press. But when I googled it I found that more user encounter too. Solution:
    Ctrl+Shift+Numlock
    In that solution I found the supposed to press Ctrl+Shift+Numlock to copy text was press Ctrl+Shift+Numlock :(

    Aug 28, 2012

    Tomcat: Change timezone setting.

    As default tomcat use GMT timezone. To set this one, modify your catalina.sh or starup.sh a the location before the execution of the tomcat boostrap and add data below.
    $JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Asia/Manila"
    Please find the timezone By Continent or in Asia

    Aug 24, 2012

    Credit Card testing

    Testing Card
    VISA, 4716081467305766, 03/15
    Diners Club, 38520000023237, 11/14
    Discover, 6011000990139424, 02/14
    MasterCard, 5135299256640694, 06/14
    enRoute, 214999060738825, 03/13
    VISA, 4111111111111111, 03/15
    American Express, 347836551942260, 07/14
    Diners Club, 30569309025904, 02/13
    VISA, 4024007135532710, 05/14
    Diners Club, 38767186195160, 12/12
    Discover, 6011963280099774, 10/12
    VISA, 4111111111111111, 03/15
    
    Master Card (16 Digits) 5105105105105100
    Master Card (16 Digits) 5555555555554444
    Visa (13 Digits) 4222222222222
    Visa (16 Digits) 4111111111111111
    Visa (16 Digits) 4012888888881881
    American Express (15 Digits) 378282246310005
    American Express (15 Digits) 371449635398431
    Amex Corporate (15 Digits) 378734493671000
    Dinners Club (14 Digits) 38520000023237
    Dinners Club (14 Digits) 30569309025904
    Discover (16 Digits) 6011111111111117
    Discover (16 Digits) 6011000990139424
    JCB (16 Digits) 3530111333300000
    JCB (16 Digits) 3566002020360505
    
    MasterCard:5431111111111111
    Amex:341111111111111
    Discover:6011601160116611
    American Express (15 digits):378282246310005
    American Express (15 digits):371449635398431
    American Express Corporate (15 digits):378734493671000
    Diners Club (14 digits):30569309025904
    Diners Club (14 digits):38520000023237
    Discover (16 digits):6011111111111117
    Discover (16 digits):6011000990139424
    JCB (16 digits):3530111333300000
    JCB (16 digits):3566002020360505
    Mastercard (16 digits):5555555555554444
    Mastercard (16 digits):5105105105105100
    Visa (16 digits):4111111111111111
    Visa (16 digits):4012888888881881
    Visa (13 digits):4222222222222
    
    I list this one server to as testing or simulate for error payment. I some place our payment gateway give as testing credit card which all is valid. To simulate payment error, Try to use above.

    Aug 17, 2012

    Java - Iterating Java HashMap Oject

    Let create the Object. HashMap<String, Object> map = new HashMap<String, Object>();
    for (String key : map.keySet()) {
        System.our.println("My HashMap Key"+key);
    }
    If you only need the values, use values():
    for (Object value : map.values()) {
        System.our.println("My HashMap Vaslue"+value.toString()); // I issue toString to convert the object into String value
    }
    Finally, if you want both the key and value, use entrySet():
    for (HashMap.Entry<String, Object> entry : map.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        // ... Print here if you want or do something
    }

    Aug 14, 2012

    Struts 2 - IF tag

    IF tag with OR

    <s:if test="%{x==1 || z==2}">
       <!--Your data goes here... -->
    </fi>

    Aug 12, 2012

    Blogspot - List of Keywords

    * data:blog.pageType
    Type of the page, pasible value are. [index, item]
    Some Usage like creating condition:
    <b:if cond='data:blog.pageType == "index"'>
    
    * data:blog.url
    The URL con the current pages
    
    * data:blog.pageName
    Page name or the post name
    <meta expr:content='data:blog.pageName' property='og:site_name'/>
    
    * data:blog.title
    Page Title
    Usage:
    <meta expr:content='data:blog.title' property='og:title'/>
    OR
    <title><data:blog.pageTitle/></title>
    

    Blogspot - Setting dynamic meta tags.

    Atfer a few day looking for the solution of this. Finally I already find it. 1. Log in to your Blogger Dashboard > Design > Edit HTML and find the tags section below.
    <title><data:blog.pageTitle/></title>
    
    2. Finally, replace the data in upper section with the code below.
    <b:if cond='data:blog.pageType == &quot;index&quot;'>
    <title><data:blog.pageTitle/></title>
    <meta content='Winzter Blog - This page contain more on the solution of our problem encounter in development time.' name='description'/>
    <meta content='Web Development, PHP, Java, Magento, Airg, Syntax3rror, Linux Command, Zend, Symfony, Google Appengine, Google Web Toolkit'
    name='keywords'/>
    <b:else/>
    <title><data:blog.pageName/> - <data:blog.title/></title>
    <meta expr:content='data:blog.pageName + &quot; by &quot; +
    data:blog.title' name='Description'/>
    <meta expr:content='data:blog.pageName + &quot;, &quot; +
    data:blog.title' name='Keywords'/>
    </b:if>
    

    Happy reading

    Aug 11, 2012

    GAE - Querying on the Datastore Entity with limit

    Just share this simple statement in querying the Entity With limit. Assume the we want only specific number of report to be retrieve from our entity.
    Query query = new Query(dataStoreKind);
    PreparedQuery pq = datastore.prepare(query);
    Iterable<Entity> users  = pq.asIterable(FetchOptions.Builder.withLimit(30));
    for (Entity user : users) { // Scroll the data
      // user.getKey().getName(); // this how to get the Entity key
       // (Long)user.getProperty("EntityName"); // Get Entity value 
    
    }

    Aug 9, 2012

    GAE - How to view the Datastore using eclipse

    Thanks to. onpositive.com

    GAE - How to filter on Datastore viewer using the Entity key or Primary

    Search in you kind base record key
    SELECT * FROM Kind WHERE __key__ = KEY('Kind', 'TheKeyValue')

    Search on a kind base on the Parent key
    SELECT * FROM Kind WHERE ANCESTOR IS KEY('ParentKind', 'ParentKeyWord')
    

    Search all Entity base on Parent key what ever the Kind(See From Kind not exist)
    SELECT * WHERE ANCESTOR IS KEY('ParentKind', 'ParentKeyWord')
    

    More info hereGQL Syntax

    Aug 2, 2012

    Java - Parameter Passing By-Value and By-Reference

    This post will explain on how to manipulate Java pass-by-reference and java pass by value.

    ByReference.java

    package com.fluxion.mrcos.test;
    
    public class ByReference {
     private int x=100;
     public void setX(int pX){
      this.x=pX;
     }
     public int getX(){
      return this.x;
     }
    }
    

    ByValue.java

    package com.fluxion.mrcos.test;
    public class ByValue {
    
     public static void main(String[] args){
      int a=2,b=7;
      ByValue bValue = new ByValue();
      ByReference bRef = new ByReference();
      
      System.out.println("a="+a+"; b="+b);
      bValue.swapMe(a, b);
      System.out.println("a="+a+"; b="+b);
      
      System.out.println("================================");
      bRef.setX(500);
      System.out.println("By Reference X:"+bRef.getX());
      bValue.chanceObject(bRef);
      
      System.out.println("By Reference X:"+bRef.getX());
      
     }
    
     private void chanceObject(ByReference pByRef)
     {
      pByRef.setX(300); // change the value 
     }
     
     private void swapMe(int x, int y){
      int temp = x;
      y=x;
      x=temp;
     }
    }
    

    Output When Running ByValue.java

    a=2; b=7
    a=2; b=7
    ========
    By Reference X:500
    By Reference X:300

    Coclusion/Observation

    Java is works on both By-Value and By-Reference however this will defends on the use. Is you pass a data, Java will tricks the paramater as Pass By-Value(See swapMe function), however if you pass a Object, it will treat the parameter as pass By-Reference(See chanceObject function)

    Jul 27, 2012

    Skype Static - error while loading shared libraries: libtiff.so.4

    error while loading shared libraries: libtiff.so.4: cannot open shared object file: No such file or directory

    Most of the time this kind of error its too generic. So I try to look libtiff library into my system and I found /usr/lib/libtiff.so.3

    Fixed:
    ln -s /usr/lib/libtiff.so.3 /usr/lib/libtiff.so.4
    NOTE: To execute the command you must have root permission.

    Jul 25, 2012

    Symfony - Logger Setting and Enable

    Enable File apps/YOUR_APP/config/factories.yml
    prod:
      logger:
       class: sfNoLogger     param:
         level: err
         loggers: ~
    to
    prod:
      logger:
       class: sfFileLogger
        param:
         level: debug
         loggers: ~
         file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
    Enable symfony debugging apps/YOUR_APP/config/setting.yml
    prod:
      .settings:
       no_script_name: true
       logging_enabled: false # Please change to "true"

    Reference: Ticket
    Application-Management-Tools

    Jul 17, 2012

    Free Domain Name Registration

    • co.cc - One Best Domain Registration, but this already Block by Google.. sad :(
    • dot.tk - Im not sure if this was block by google already, coz I try to register via Google Apps but sad its generate Error...
    • cu.cc - Im not sure if this is another version of co.cc but the good thing is Google Apps Accept this domain.

    Jun 29, 2012

    Best torrent site

    1. www.scenetime.com
    Initially you will get 3GB as initial UPLOAD credit. One this good here, you can create request for the torrent you can find. :) * THis is now invite sign up.

    If you are willing to join to this site, please like their ST facebook page and join to ST facebook community group to get an invite. Just participate, the admin made the community alive and made lot of funs. Good Luck

    2. torrenting.com
    *Initially you will get 3GB as initial UPLOAD credit. * Still open for sign-up. Hurry
    3. blues-brothers.biz Initially you will get 5GB as initial UPLOAD credit. The bad thing here if you go out, maybe get leave your account will be deleted. :(

    4. torrentbytes.net
    Still Open for new User.
    No Initial upload quata, however you can earn upload credit by downloading freeleech torrent and seeds and when you uploading thats the time you are earning UL credit

    5. tinym.eu
    1Gb Initial Upload Quata

    Jun 28, 2012

    Struts - How to access Method from your action class to you JSP file.

    From you action class
    public class YourAction extends ActionSupport{ // NOTE to public this data so you can access in JSP public String name="Winzter"; public String getName() { return this.name; } } // class
    From you JSP file.
    <c:out value="${action.getName()}" escapeXml="false"></c:out>
    If the property name was declare public, you can access by this one.
    <c:out value="${name}" escapeXml="false"></c:out>
    NOTE:${action.getName()} in only working on Tomcat7.x.x.

    Jun 18, 2012

    GAE - Handing Custom Error Page

    Java

    <static-error-handlers>
      <handlerfile="default_error.html" />
      <handlerfile="over_quota.html"error-code="over_quota" />
    </static-error-handlers>
    

    Python

    error_handlers:
     -file:default_error.html
     -error_code:over_quota
      file:over_quota.html
    

    Jun 14, 2012

    YesPayment - Direct Connection Implemtation

    Query

    Inquire for the transaction Sample code in PHP
    $client = new SoapClient('YOUR-WSQL_HERE');
    //Query(string,string,int );
    $resp = $client->Query(
              "YOUR-MERCHANT-CODE", // STR
              "MERCHANT-REFERENCE", //STR
              YOUR-TRANSACTION-TYPE); //INT
    var_dump($resp->QueryResult->any  );
    

    Jun 13, 2012

    GAE - JSON implementation

    Most of us also looking how to implement JSON on GAE. In one blog, posted how and he made it by create a POJO or maybe this was also called entity. Here's the impementation:
    Class Response{
     public enum Status {
      ERROR, OK, WARNING
     }
     private Status status;
     private String message;
    
     public Response(Status status, String message)
     {
      this.status = status;
      this.message = message;
     }
     public String toJson() {
      Gson gson = new Gson();
      String json = gson.toJson(this);
      return json;
     }
     public static Response constructFromJson(String json)
     {
      Gson gson = new Gson();
      return gson.fromJson(json, Response.class);
     }
    }
    Here's how he implement:
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException
    {
     resp.setContentType("text/plain");
     //do your work here
     ...
     PrintWriter out = resp.getWriter();
     Response response = new Response(Response.Status.OK, "A success!");
     out.print(response.toJson());
    }
    
    Here's response looks:
    {“status”:”OK”,”message”:”A success”}

    TODO: Maybe someone ask. What if I want a array. Maybe try to looks at it and see how the implementation. This maybe we create a ArrayList properity or array it self. :) Give credit to nadacode.com

    Jun 4, 2012

    Symfony: Get Module Name and Action Name

    Get Module or Action name all over the code

    sfContext::getInstance()->getModuleName()
    sfContext::getInstance()->getActionName()
    

    Get Module or Action name in you action file

    $this->getModuleName()
    $this->getActionName()
    

    Get Module or Action name in template file

    $sf_context->getModuleName()
    $sf_context->getModuleName()
    

    May 24, 2012

    Symfony - Disable sf_web_debug in your web page

    In our development environment, there some way we need to programmaticall disable the Web Debug. In some instance like we are retrieving text data on out controller.
      public function executeGetText(sfWebRequest $request)
      {
         sfConfig::set('sf_web_debug', false); // Here to disable web debug only and hase html response
         // Some code here.. Good luck =)
      }
    
    You can also do this one, this will return you the plain text.
      public function executeGetText(sfWebRequest $request)
      {
         $this->getResponse()->setHttpHeader('Content-type', 'text/plain', true);
         // Some code here.. Good luck =)
      }
    

    May 14, 2012

    Struts - Calculating on struts tags

    We need to initilaize variable.
    <s:set var="total" value="%{0.00}"/>
    
    Calculation
    <s:set var="total" value="%{amount + #attr.total}" />
    

    May 11, 2012

    Swapping Algorithm without extra variable.

    One way to this is by using the Exclusive OR (XOR)

    Sample Code

    $x = $x ^ $y;
    $y = $y ^ $x;
    $x = $x ^ $y;
    

    Explanation

    Lets try to use X=5 and Y=15; Now let convert the value of X and Y to each Binary data. Here's is, X=0101 and Y=1111

    • Lets see first statement.
      $x = $x ^ $y; Binary: 1010 ^ 1111 ------ 0101 ( X now has value of 10)
    • Second Statement
    • Last statement

    Paging Algorithm

    Paging Algorithm
    int topage = maxRecords * currentPage;
    int offset = topage - (maxRecords);
    

    May 9, 2012

    Struts - Formating Text, Date or Number


    Formating Pattern

    format.time = {0,time}
    format.number = {0,number,#0.0##}
    format.percent = {0,number,##0.00'%'}
    format.money = {0,number,\u00A4##0.00}

    Formatting a number

    <s:property value="getText('{0,number,#,##0.00}',{product.price})" />

    May 8, 2012

    JAVA - Reading file relatively

    This will all getting the base path of you application to know how/where to read the file

    Eclipse

    Java Application


    * File function
    File fXmlFile = new File("test.xml");
    The will look on the PROJECT_DIR path.
    /YOUR/PROJECT_DIR/test.xml
    * FileInputStream
    FileInputStream is = new FileInputStream("test.cfg.xml");

    The will look on the ECLIPSE path.
    /YOUR/ECLIPSE_DIR/test.cfg.xml

    *
    Loader context
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    classLoader.getResource(".").getPath()
    This will return: PROJECT_DIRt/build/classes/

    Web Application(Running in Tomcat)


    *
    Loader context
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    classLoader.getResource(".").getPath()
    This will return the path TOMCAT_DIR/lib/

    * File function
    File fXmlFile = new File("test.xml");
    The will look on the ECLIPSE_DIR path.
    /YOUR/ECLIPSE_DIR/test.xml

    Deployed


    * Java Application

    * Web Application(Running in Tomcat)
    * Loader context
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    classLoader.getResource(".").getPath()
    This will return the path TOMCAT_DIR/lib/

    * File function
    File fXmlFile = new File("test.xml");
    The will look on the
    TOMCAT_DIR path.
    /TOMCAT_DIR/test.xml

    May 2, 2012

    Java: org.hibernate.ObjectNotFoundException: No row with the given identifier exists:

    None-annotated

    <many-to-one name="employee" class="Employee"
    column="CITY_ID" not-null="false" lazy="false" not-found="ignore">
    </many-to-one>
    

    Annotated

    @NotFound(action=NotFoundAction.IGNORE)
    @OneToOne
    @JoinColumn(name="CITY_ID")
    private City city;
    // your getter and setter here
    

    Apr 23, 2012

    SVN: HOOK Monitoring the commit.

    Before, some of my co-develop commit their changes without commit information. In that case we cant easy track the purpose of the committed changes until we we make rule to follow comment template. By the help of svn hook we strictly follow the comment template issued. If you want to check the commit information if satisfy the needed data? Try to look pre-commit.tmpl * copy the hook template pre-commit.tmpl and set the permission to executable.
    $ cp pre-commit.tmpl pre-commit
    $ chmod 755 pre-commit
    
    For other hooks try to check your <REPOSTORY-PATH>/hooks/

    Mar 26, 2012

    Mobile: Html meta data and headers

    Sample Mobile Meta and headers

    <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
    <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no' name='viewport'/>

    Magento: Hack - Nested addAttributeToFilter.

    I already waste my one whole working day to look on this problem but still can file the solution. So I decide to modify the the magento core.

    Here's the condition I want to do in addAttributeToFilter function.

    (condition1) OR ((condition2) and (condition3) ..... )


    To solve this Fucking problem I modify this class Mage_Eav_Model_Entity_Collection_Abstract.

    public function addAttributeToFilter($attribute, $condition=null, $joinType='inner')
    {
    ....Some Code here
    if (is_array($attribute)) {
    $sqlArr = array();
    foreach ($attribute as $condition) {
    $sqlArr[] = $this->_getAttributeConditionSql($condition['attribute'], $condition, $joinType);
    }
    $conditionSql = '('.join(') OR (', $sqlArr).')';
    }else{
    ... your other code here.
    }


    Here my modify version.

    public function addAttributeToFilter($attribute, $condition=null, $joinType='inner')
    {
    ....Some Code here
    if (is_array($attribute)) {
    $sqlArr = array();
    $myAND = array();
    $andSqlArr = array();
    /*
    * @ win mode to support (x=a) or (y=1 and z=0)
    * array(
    * array(condition)
    * 'and' =>
    * array(
    * array(condition)
    * array(condition)
    * ),
    * )
    *
    * Output expected
    * cond1 OR (cond2 and cond3)
    */
    foreach ($attribute as $key => $condition) {
    if ($key === "and"){
    $myAND = $condition;
    continue;
    }
    $sqlArr[] = $this->_getAttributeConditionSql($condition['attribute'], $condition, $joinType);
    }
    foreach ($myAND as $key => $andCond ){
    $andSqlArr[] = $this->_getAttributeConditionSql(
    $andCond['attribute'],
    $andCond,
    $joinType);
    }
    $conditionSql = '('.join(') AND (', $andSqlArr).')';
    if ($andSqlArr){
    $sqlArr[] = $conditionSql;
    }

    $conditionSql = '('.join(') OR (', $sqlArr).')';
    }
    ... your other code here.
    }


    In your product collection.

    $collection->addFieldToFilter(
    array(
    array("attribute"=>"your_attribute1", "in"=>array(1,2,3,)),
    "and" => array(
    array("attribute"=>"your_attribute2", "eq"=>1,),
    array("attribute"=>"your_attribute3", "eq"=>1,),
    ),
    )
    );


    Happy Coding. :)

    Mar 22, 2012

    SVN: SSL handshake failed: Secure connection truncated

    I experience this error in my fedora 14 with svn version

    svn --version
    svn, version 1.6.17 (r1128011)
    compiled Jun 2 2011, 15:23:50

    Copyright (C) 2000-2009 CollabNet.
    Subversion is open source software, see http://subversion.apache.org/
    This product includes software developed by CollabNet (http://www.Collab.Net/).

    The following repository access (RA) modules are available:

    * ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
    - handles 'http' scheme
    - handles 'https' scheme
    * ra_svn : Module for accessing a repository using the svn network protocol.
    - with Cyrus SASL authentication
    - handles 'svn' scheme
    * ra_local : Module for accessing a repository on local disk.
    - handles 'file' scheme



    Here my command

    $ svn export https://mycode.googlecode.com/svn/trunk/ mycode --username admin@syntax3rror.co.cc


    Response

    svn: OPTIONS of 'https://mycode.googlecode.com/svn/trunk': SSL handshake failed: Secure connection truncated (https://mycode.googlecode.com)


    From Jan's Blog instructed to install libneon27 However before in install I check /usr/lib/libneon.so.27 and exist to my filesystem so I just issue.

    sudo ln -s /usr/lib/libneon.so.27 /usr/lib/libneon-gnutls.so.27


    Cheers.. :)

    Magento: Deleting Product

    A simple way to delete product is:
    $productId = 1;
    Mage::getSingleton('catalog/product')
      ->load($productId)
      ->delete();
    
    If you want to delete product by category
    $collection = Mage::getSingleton('catalog/category')
      ->load(YOUR_CATEGORY_ID)
      ->getproductCollection();
    
    // If you want to filter by attribute
    $collection->addAttributeToFilter('YOUR_ATTRIBUTE_CODE', 'ATTRIBUTE_VALUE')
    foreach($collection as $product){
       $product =Mage::getSingleton('catalog/product')
         ->load($product->getId())
       try {
       // Im not sure what is the use of this part
       Mage::dispatchEvent(
         'catalog_controller_product_delete',
         array('product' => $product));
       
       // Finally we not able to delete the product
       $product->delete();
       }catch (Exception $e) {
         echo "Can't delete product w/ id: $product";
       }
    }
    
    Reference: Delete magento Product

    Mar 15, 2012

    Android: Handling of Content-Disposition header on the android browser.

    As part web development, something we need to create one script file to handle all download request from your server but, suddenly I try to work on android browser and get an issue on download name.

    Scripname download.php
    Download name: download.apk which not correct

    To fix the issue:

    header("Content-Disposition: attachment; filename=\"fast-and-the-furios.apk\"");
    header("Content-Type: application/vnd.android.package-archive");






    NOTE:
    * Besure to put SPACE between attachment; and filename
    * Also be sure to quote the filename with double-quote

    Content-Disposition: attachment; filename="fast-and-the-furios.apk"



    If you want to upload on android try to read this one multipart form upload on android. PS. I did now test his code yet, check in you own either. :)


    Happy reading. :)

    Mar 13, 2012

    Mar 12, 2012

    Mysql: How to recover mysql table.

    One time I get real problem about mysql table. It was crashed and I don't have any back up on it.

    After I get on an internet connected pc I googled it and this helpfull resources.
    how-to-repair-corrupted-mysql-tables-using-myisamchk

    My Pick pickup line and emo sentence

    Pag namatay ako wag ka pupunta, bka pag nakita kita, tumibok uli puso ko. :)


    Wla lang gusto ko lang itago. Most data from monster program (The Morning Rush)

    Mar 5, 2012

    Mar 4, 2012

    AppEngine - Guestbook sample

    https://developers.google.com/cloud-sql/docs/developers_guide_java#using_the_java_development_server

    GWT - Php support

    For PHP developer want to use appengine, try this out.

    http://www.webdigi.co.uk/blog/2009/run-php-on-the-google-app-engine/

    Mar 2, 2012

    GWT - Login Manager

    Just a recording refernce yet. Sorry I cant get one yet. :(

    http://code.google.com/webtoolkit/tools/gwtdesigner/tutorials/loginmanager.html
    http://www.dariusz-borowski.com/wp/?p=20
    http://www.vogella.de/articles/GWT/article.html

    Mar 1, 2012

    GWT - How to build multiple or another page.

    As a beginner in playing GWT. I don't know to create another page after I done the Getting Stated on GWT documention.
    GWT Getting start

    While looking on the to this stuff, I found that there was no mutiple page on GWT instead it use widget to display another view on you page.

    Read the Alen Post here GWT Concepts No Multiple Pages

    Reference:
    Here another reference http://colchambers.blogspot.com/2010/08/creating-multiple-page-gwt-app.html

    Feb 29, 2012

    GWT - Getting Started

    As developer, I want something different too. Knowing other stuff As I can. :)

    In getting started I use this URL: http://code.google.com/webtoolkit/usingeclipse.html

    Step 1: Create a GWT Project

    Step 8: Compiling a GWT Application
    Deploying to Google App Engine

    Issue:
    * When you run your browser it ask to to install GWT Plugin this this case I use Firefox 3.6.9 and after the plugin install still prompting me to install again.
    Resolution:
    I update my firefox to 10.xx.x WOW, AT this time I only found the my firefox is too too old man.. :(


    winzter143.appspot.com

    Hope you can do it too.

    Learning is no ending.

    Feb 27, 2012

    How to Create Your Own Web Proxy

    In long time looking on how to do this stuff. Now, I think I already get the idea by this authors.

    Best Proxy
    http://www.labnol.org/internet/setup-proxy-server/12890/

    http://www.darkpolitricks.com/2009/12/create-your-own-web-proxy-server/

    I think this not really what I looking for but I know I get some idea on doing other stuff
    http://codescribes.blogspot.com/2007/01/how-to-make-your-own-web-proxy-parts-i.html

    Feb 23, 2012

    Linux: Find old files

    This important to remove unused logs.

    Examples
    Find files more than or equal to 3 days
    find . -name '*.log' -mtime +3

    Feb 14, 2012

    Linux: Getting Directory size.

    du --max-depth=1 /home/ | sort -n -r
    du -sh *

    Reference:
    http://www.labtestproject.com/linuxcmd/du_command.html

    Feb 13, 2012

    My Dictonary

    This is a collection of New words to me.
    ju·ve·nile
    Young/immaturify/beta/now develop well

    Feb 9, 2012

    Linux: Convert AVI to 3GP

    ffmpeg -i file.avi -strict experimental -s qcif -vcodec libxvid -acodec aac -ac 2 -ar 8000 -r 25 -ab 65535 -y file.avi.3gp

    Jan 24, 2012

    Linux: Date calculation

    Yesterday



    winzter]$ date --date='1 day ago' +%Y%m%d
    winzter]$ date --date='-1 day' +%Y%m%d
    winzter]$ date -d "yesterday" +%Y%m%d

    Jan 10, 2012

    Java - JSON Tutorials

    New updated JSON API for java can be found here.
    https://github.com/douglascrockford/JSON-java/blob/master/

    I put this a my reference coz I was use this api before and I was encounter problem on delete record on JSON Array. As googling my problem I found a method remove but not include in my library so I try to find the source again.

    For next time Found problem may be it solve again by updating my API.. :)

    Jan 5, 2012

    AIRG Urls

    http://airg.com/nam-en/UserConfig/NamEn/nam-en/vipStatus?R=40z&srvrd=SRVRD&sesID=SESID
    http://airg.com/nam-en/Deck/NamEn/nam-en/learnMore?R=40P