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)