Monthly Archives: October 2011

how To sort a hashmap using its keys and/or values

To sort a hashmap using its keys :- Dump the HashMap into a TreeMap: Map yourMap= new HashMap(); // put some tuples in yourMap … Map sortedMap = new TreeMap(yourMap); To sort a hashmap using its values :- public HashMap getSortedMap(HashMap hmap) … Continue reading

Posted in collections | Comments Off on how To sort a hashmap using its keys and/or values

[Java] Reverse ordering a TreeMap

TreeMap is a Map that keep the element in the natural order of the key. The order can be changed providing to the contructor of the TreeMap a Comparable. So you can implement your custom one for more specific tasks. However if you only … Continue reading

Posted in collections | Comments Off on [Java] Reverse ordering a TreeMap

get post by title

function get_post_by_title($page_title) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s “, $page_title )); if ( $post ) { $post= get_post($post, $output); //print_r($post); $language=get_bloginfo(‘language’); if($post->post_type==”research”){ $research_language= get_post_meta($post->ID, ‘language’, true); // print $research_language. ” “.$language;print … Continue reading

Posted in wordpress | Comments Off on get post by title

junit music box on eclipse

  http://www.brettdaniel.com/archives/2009/05/23/232945/

Posted in junit | Comments Off on junit music box on eclipse

Introduction to jUnit

Posted in junit | Comments Off on Introduction to jUnit

copy over network at linux

scp admin@192.168.30.31:/home/admin/amazon_price_checker_uk-25.csv amazon_price_checker_uk-25.csv with different port scp -P 15000 /u001/sso_software/Single_sign_on/oam_11.1.1.5.tar.gz  oracle@10.20.100.1:/u01/software/oam_11.1.1.5.tar.gz

Posted in linux | Tagged , , | Comments Off on copy over network at linux

SqlExecuter vs JDBC

public class CmdExec { public static void main(String argv[]) { executeSql(); } private static void executeSql() { final class SqlExecuter extends SQLExec { public SqlExecuter() { Project project = new Project(); project.init(); setProject(project); // setTaskType(“sql”); setTaskName(“sql”); } } SqlExecuter executer … Continue reading

Posted in java, jdbc, mysql | Comments Off on SqlExecuter vs JDBC

Methods Common to All Objects :effective java ch3

Item 7: Obey the general contract when overriding equals Item 8: Always override hashCode when you override equals Item 9: Always override toString Item 10: Override clone judiciously Item 11: Consider implementing Comparable ———————————————————————————————————————————————————————– Item 7: Obey the general contract … Continue reading

Posted in effective java | Comments Off on Methods Common to All Objects :effective java ch3

how to get last insert id by java

public static int getLastInsertID(Connection conn, String statment)throws SQLException { int lastInsertedId = -1; PreparedStatement ps = conn.prepareStatement(statment,PreparedStatement.RETURN_GENERATED_KEYS); ps.executeUpdate(); ResultSet rskey = ps.getGeneratedKeys(); if (rskey != null && rskey.next()) { lastInsertedId = rskey.getInt(1); } return lastInsertedId; }

Posted in java, jdbc, mysql | Tagged , , , | Comments Off on how to get last insert id by java

rtl support at wordpress

http://codex.wordpress.org/Right_to_Left_Language_Support

Posted in wordpress | Comments Off on rtl support at wordpress