ParentEntity.getKey().getChild(ChildKind, keyname);
Dec 12, 2012
GAE- Generate Child Entity key
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.
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?
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?
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?
* Find you USB Drive.
Creating the partition# grep -Ff <(hwinfo --disk --short) <(hwinfo --usb --short)
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
* Atfer selected, issue m option to display the help# /sbin/fdisk /dev/sdb
* Delete the partition: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)
* Create PartitionCommand (m for help): d Selected partition 1
* Tag the Partition as bootable.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
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 LinuxINFO: As you notice Boot colunm has start(*) * Finally you done creating partition, now write the partition in the disk.
Now, write the Live ISO to your USBCommand (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
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.# 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
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.
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?
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
ToAllowOverride None
AllowOverride All
Happy reading and hope will work to you too.
Oct 1, 2012
How to change HOSTNAME in openSUSE?
* 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?
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 setup alternative in fedora?
How to setup alternative in openSuse?
How to install chrome in openSuse?
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 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
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?
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 quietacpi_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
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.
Sep 14, 2012
How to setup alternative on redhat(fedora)/Opensuse?
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 setup alternative in fedora?
How to setup alternative in openSuse?
Sep 11, 2012
Struts2 - Iterating List of Map in struts jsp.
Java Object Declaration
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; }
<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 5, 2012
Sep 4, 2012
Struts - Iteration Map in jsp using Struts
This just one example from.
Or maybe like this one.<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>
<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>
Rich Snippets Testing Tool
Warning: At least one field must be set for Hcard.
Solution: Just check the Posted By.hcard Warning: At least one field must be set for Hcard. Warning: Missing required field "name (fn)".
Sep 1, 2012
GAE - Truncating Datastore Data
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.
from:test@test.com.ph filename:(jpg OR jpeg OR png)
Linux - Solution for Numpad not working.
In that solution I found the supposed to press Ctrl+Shift+Numlock to copy text was press Ctrl+Shift+Numlock :(Ctrl+Shift+Numlock
Aug 28, 2012
Tomcat: Change timezone setting.
Please find the timezone By Continent or in Asia$JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Asia/Manila"
Aug 24, 2012
Credit Card testing
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.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
Aug 17, 2012
Java - Iterating Java HashMap Oject
If you only need the values, use values():for (String key : map.keySet()) { System.our.println("My HashMap Key"+key); }
Finally, if you want both the key and value, use entrySet():for (Object value : map.values()) { System.our.println("My HashMap Vaslue"+value.toString()); // I issue toString to convert the object into String value }
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
Aug 12, 2012
Blogspot - List of Keywords
* data:blog.urlType of the page, pasible value are. [index, item] Some Usage like creating condition: <b:if cond='data:blog.pageType == "index"'>
* data:blog.pageNameThe URL con the current pages
* data:blog.titlePage name or the post name <meta expr:content='data:blog.pageName' property='og:site_name'/>
Page Title Usage: <meta expr:content='data:blog.title' property='og:title'/> OR <title><data:blog.pageTitle/></title>
Blogspot - Setting dynamic meta tags.
2. Finally, replace the data in upper section with the code below.<title><data:blog.pageTitle/></title>
<b:if cond='data:blog.pageType == "index"'> <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 + " by " + data:blog.title' name='Description'/> <meta expr:content='data:blog.pageName + ", " + data:blog.title' name='Keywords'/> </b:if>
Happy reading
Aug 11, 2012
GAE - Querying on the Datastore Entity with limit
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 filter on Datastore viewer using the Entity key or Primary
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 3, 2012
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.4NOTE: To execute the command you must have root permission.
Jul 25, 2012
Symfony - Logger Setting and Enable
prod:to
logger:
class: sfNoLogger param:
level: err
loggers: ~
prod:Enable symfony debugging apps/YOUR_APP/config/setting.yml
logger:
class: sfFileLogger
param:
level: debug
loggers: ~
file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
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
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. Hurry3. 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 JSP file.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
NOTE:${action.getName()} in only working on Tomcat7.x.x.<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>
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
Here's how he implement: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 response looks: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()); }
{“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
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 17, 2012
May 14, 2012
Struts - Calculating on struts tags
<s:set var="total" value="%{0.00}"/>Calculation
<s:set var="total" value="%{amount + #attr.total}" />
May 11, 2012
Swapping Algorithm without extra variable.
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
int topage = maxRecords * currentPage; int offset = topage - (maxRecords);
May 9, 2012
Struts - Formating Text, Date or Number
Formating Pattern
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
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();This will return: PROJECT_DIRt/build/classes/
classLoader.getResource(".").getPath()
Web Application(Running in Tomcat)
* Loader context
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();This will return the path TOMCAT_DIR/lib/
classLoader.getResource(".").getPath()
* 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 contextClassLoader classLoader = Thread.currentThread().getContextClassLoader();This will return the path TOMCAT_DIR/lib/
classLoader.getResource(".").getPath()
* File functionFile 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.
$ cp pre-commit.tmpl pre-commit $ chmod 755 pre-commitFor other hooks try to check your <REPOSTORY-PATH>/hooks/
Apr 22, 2012
Apr 16, 2012
Creating a Facebook App with Google App Engine and Google Web Toolkit
Mar 26, 2012
Mobile: Html meta data 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.
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
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
If you want to delete product by category$productId = 1; Mage::getSingleton('catalog/product') ->load($productId) ->delete();
Reference: Delete magento Product$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"; } }
Mar 15, 2012
Android: Handling of Content-Disposition header on the android browser.
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
Tips: PH Globe Telecom Promos
* P15 - Unlimited text + 30 min calls to Globe/TM (Valid for 1 day)
Mar 12, 2012
Mysql: How to recover mysql table.
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
Wla lang gusto ko lang itago. Most data from monster program (The Morning Rush)
Mar 5, 2012
AppEngine - Samples
Mar 4, 2012
AppEngine - Guestbook sample
GWT - Php support
http://www.webdigi.co.uk/blog/2009/run-php-on-the-google-app-engine/
Mar 2, 2012
GWT - Login Manager
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.
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
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
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 26, 2012
Feb 23, 2012
Linux: Find old files
Examples
Find files more than or equal to 3 days
find . -name '*.log' -mtime +3
Feb 19, 2012
Start Working with Mobile Web Development
Feb 14, 2012
Linux: Getting Directory size.
du -sh *
Reference:
http://www.labtestproject.com/linuxcmd/du_command.html
Feb 13, 2012
My Dictonary
ju·ve·nile
Young/immaturify/beta/now develop well
Feb 9, 2012
Linux: Convert AVI to 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
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/Deck/NamEn/nam-en/learnMore?R=40P