Skip to main content

Posts

Showing posts from 2011

Special keywords in Java

"Final" keyword http://renaud.waldura.com/doc/java/final-keyword.shtml http://www.javamex.com/tutorials/synchronization_final.shtml Note that storing a reference to an object in a final field only makes the reference immutable, not the actual object public final List<String> myList = new  ArrayList<String>( ); you can still modify "myList" as follows. myList.add("good"); But the following code is not possible myList = new ArrayList<String>( ); myList = some other list;   "Volatile" keyword http://javarevisited.blogspot.com/2011/06/volatile-keyword-java-example-tutorial.html http://www.javabeat.net/tips/169-volatile-keyword-in-java.html http://www.javamex.com/tutorials/synchronization_volatile.shtml

Insert/update into multiple rows (collections) in table MyBatis

Method 1 (only for insert) :  To add multiple record into "product" table The XML file is as follows <insert id="insertList" parameterType="HashMap" useGeneratedKeys="true"> INSERT INTO product (vendor_id, name ,description) VALUES <foreach collection="paramList" item="param" separator=","> (#{param.vendorId}, #{param.name}, #{param.description}) </foreach> </insert> The invoking Java code is as follows List products = new ArrayList(); HashMap<String, Object>  para = new HashMap<String, Object>(); Product product1 = new Product("vendor_id1,"pen","good pen"); Proudct product2 = new Product("vendor_id1,"book","good book"); products.add(product1); products.add(product2); para.put ("paramList",products); Integer status = mapper.insertList(para); Method 2: (work both for insert and update) You also

Java thread

Thread scheduling http://www.java2s.com/Code/JavaAPI/java.util.concurrent/ExecutorsnewSingleThreadScheduledExecutor.htm http://www.javapractices.com/topic/TopicAction.do?Id=247 http://kamleshkr.wordpress.com/2009/10/02/java-threads-callable-and-future/ Thread signaling http://tutorials.jenkov.com/java-concurrency/thread-signaling.html http://www.javamex.com/tutorials/synchronization_producer_consumer.shtml Interrupt threads http://www.techrepublic.com/article/interrupting-java-threads/5144546 http://blog.donews.com/maverick/archive/2005/08/10/502286.aspx http://agapple.iteye.com/blog/916837 Tutorials http://www.baptiste-wicht.com/series/java-concurrency-tutorial/

Serialization and subclassing in Java

http://www.javapractices.com/topic/TopicAction.do?Id=70 http://www.jguru.com/faq/view.jsp?EID=251942 http://mindprod.com/jgloss/serialization.html#SERIALVERSIONUID Object Construction in Serialization http://javapapers.com/core-java/object-construction-in-serialization/ http://extreme-java.com/serialization-super-class-and-constructors/

Test package cannot find Source package class JUnit Netbeans

Remove the "index" directory in cache of NetBeans For Window X and NetBeans version 6.9 the directory is at c:\\Documents and Settings\\ "username" \\.netbeans\\" 6.9" \var\\cache\\index Update: In netbeans 7.2 on windows 7 the cache is located in c:\Users\username\AppData\Local\NetBeans\Cache\ Open MS Explorer and type   %appdata% to get AppData directory Refence: http://developmentality.wordpress.com/2010/05/26/clear-your-cache-in-netbeans/ PS: this clear cache action can also solve other problems, such as : "cannot load pages in Web Pages Folder in Netbean project"; "cannot to find class name in Test package".

SQL IN operator in MyBatis

"student" table with two columns "id" and "name". The following is an example query in XML file. <select id="select" parametertype="HashMap" resulttype="String"> SELECT name FROM student WHERE id IN <foreach item="item" index="index" collection="studentIds" open="(" separator="," close=")"> #{item} </foreach> </select> "studentIds" is the name of input list

Design patterns in Java

Course http://userpages.umbc.edu/~tarr/dp/spr06/cs446.html http://www.go4expert.com/forums/showthread.php?t=5127 Blogs http://snehaprashant.blogspot.com/2009/01/bridge-pattern-in-java.html http://javapapers.com/category/design-patterns/ Tutorials http://www.cnblogs.com/xinz/archive/2011/11/27/2265425.html http://allapplabs.com/java_design_patterns/abstract_factory_pattern.htm

Tools for Java

Design Tools ArgoUML :  Draw UML diagram The following is the link for UML tutorial http://www.visualcase.com/tutorials/uml-tutorial.htm http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/ Graphviz :  Draw flow chart tutorial http://www.graphviz.org/pdf/dotguide.pdf SDEdit :  Draw sequence diagram Bug Checking Tools PMD( pmd.sourceforge.net ) Checks code for errors Management Tools http://weiye.info/blog/tag/trac/

Stanford University Courses, Online and Free: Spring 2012

Stanford University Courses, Online and Free: Spring 2012 Computer science courses: * Computer Science 101 http://www.cs101-class.org/ * Machine Learning (one of the offerings this past fall) http://jan2012.ml-class.org/ * Software as a Service http://www.saas-class.org/ * Human-Computer Interaction http://www.hci-class.org/ * Natural Language Processing http://www.nlp-class.org/ * Game Theory http://www.game-theory-class.org/ * Probabilistic Graphical Models http://www.pgm-class.org/ * Cryptography http://www.crypto-class.org/

Web mining topics

1.海量数据的主题模型(Topic-model on large scale data) 2.推荐系统(recommender system) 3.高效训练样本获取(Label Complexity Reduction) 4.基于大规模机器学习的排序算法(Machine Learning to Rank) 5.点击模型(Click Model) 6.网页多分类学习 7.基于海量网页的结构化信息自动抽取研究 8.观点挖掘、情感分析(opinion mining and sentiment analysis) 9.规则系统与机器学习系统的整合(integrating rule-based system and learning-based system) 10.海量特征设计(large scale feature engineering) 11.基于机器学习的反作弊研究(fraud detection based on machine learning)

Chinese social media websites

Boost MySQL performance (not my writing)

Tune those queries . Biggest bang for your buck. Enable the slow query log and watch it. Once you've found a heavy resource intensive query, optimize it! Tune what receives real-world traffic. Employ Master-Master Replication . Immediately have a read-only slave for your application to hit as well. Use Your Memory . Set innodb_buffer_pool_size, key_buffer_size and other key options. RAID Your Disk I/O . Use RAID 10 mirroring and striping. On EC2 striping across a number of EBS volumes using the Linux md software raid. Tune Key Parameters . speeds up inserts & updates with innodb_flush_log_at_trx_commit=2; create a tablespace and underlying datafile for each table with innodb_file_per_table.

不要让你孤单

这首歌觉得陈奕迅比陈升 唱的好听 现场版

整理一些Markov Random Field以及Graph Model的基础学习资料 (转)

最近对于Markov Random Field等Graph Model有点兴趣,想系统学习一下这方面的知识。但是发现网上搜索的很多论文都是比较深入,不知道从何下手。下面是我收集到的一些不错的资料。 1. 首先是video lecture上的Prof. Charles Elkan在CIKM08 tutorial (http://videolectures.net/cikm08_elkan_llmacrf)的video。他从最最最基本的probability, maximum likelihood开始讲,十分清晰。这应该是作为第一个入门的学习资料,不过他这个talk里面居然只有4个听众。。。同时,这位prof把关于这个talk的note也放在了网上(http://cseweb.ucsd.edu/~elkan/250B/cikmtutorial.pdf)。 2. 接下来可以看一些conditional random field在image和language方面的应用。这篇文章(http://www.whatdafact.com/kittipat/?p=476)里面介绍了两篇citation很高的paper。同时,它也把Prof. Chales Elkan在CIKM08上的video lecture放在了首位。还有一篇比较通俗全面的intro在这里(http://www.inference.phy.cam.ac.uk/hmw26/papers/crf_intro.pdf)。注意,这里说的通俗,也是指你看完了1之后。如果你不熟悉log-linear model去看这篇intro,还是很难懂的。 3. 关于Markov Random Field以及Statistical Graph Model的课程材料,同学推荐我看看他们在哥大的Machine Learning的教案(http://www.cs.columbia.edu/~jebara/4771/handouts.html)。这个课程在网上也有video。

GET or POST in AJAX?

GET or POST? GET is simpler and faster than POST, and can be used in most cases. However, always use POST requests when: (1) A cached file is not an option (update a file or database on the server) (2) Sending a large amount of data to the server (POST has no size limitations) (3) Sending user input (which can contain unknown characters), POST is more robust and secure than GET

c:out jstl does not contain such component ?

You can not find the c:out in JSTL? because The c:out JSTL tag is NOT supported by facelets. Read following posts: http://mail-archives.apache.org/mod_mbox/myfaces-users/200608.mbox/%3C93D4BCE34C8C1A4E8D92E1A9E8738D6502D8786E@EVS2.ad.greenspuncorp.com%3E http://jdevelopment.nl/facelets-legacy-jsp/

Frequently used NetBeans Hotkey Shortcuts

Ctrl + G (jump to line) Ctrl + F (search) Ctrl + H (replace) Ctrl + E (delete line) Ctrl + F12 (outline of current file) Ctrl + [ (find matching bracket) Ctrl + / (comment) Ctrl + Shift + I (fix class imports) Ctrl + Shift + F (find in projects) Ctrl + Shift + [ (select contents in brackets) Ctrl + Shift + Up/Down arrow (copy current line Up/Down) Ctrl + Shift + M (bookmark; use Ctrl+ Shift+ '.' and Ctrl Shift + ',' to move) Alt + Shift + F (format code) Alt + Shift + W (surround with try-catch) Alt + Shift + O (go to file quickly) Alt + F7 (find usage) Alt + F12 (class hierarchy of current class) Alt + Insert (quick functions) The complete hotkeys and code template for NB 7.0: http://netbeans.org/project_downloads/www/shortcuts.pdf Other references: http://netbeansblog.com/tutorial/best-netbeans-keyboard-shortcuts/ http://netbeansblog.com/wp-content/uploads/2010/12/NetBeans-Keyboard-Shortcuts.pdf

Johann Pachelbel 被忽略的大师?

贴一首 Johann Pachelbel 最有名的曲子

Interesting personal blogs about machine learning / data mining / NLP / information retrieval

Jun Wu's blog http://sites.google.com/site/junwu02/home Mathieu's blog http://www.mblondel.org/journal/ Chen http://hi.baidu.com/chen_1st/ Hal http://nlpers.blogspot.com/ Chen http://blog.echen.me/ Glee http://www.glenmccl.com/ JSP, Web service, MySQL, MyBatis http://blog.idleworx.com/ N/A http://aimotion.blogspot.com heaad http://www.cnblogs.com/heaad/

芝加哥周边一日游好去处(转)

小镇子, 公园, 建筑, 餐饮之类的 1. county line orchard http://countylineorchard.com/ 2.一家德国农家餐馆 http://www.bayernstube.com/ 3. Matthiessen State Park http://dnr.state.il.us/lands/Landmgt/PARKS/R1/mttindex.htm 4. Indiana Dunes, Natioanl Lakeshore http://www.nps.gov/indu/index.htm 5. Chicago Botanic Garden http://www.chicagobotanic.org/ 6. Anderson Japnese Garden http://andersongardens.org/plan-your-visit/ 7.Long Grove http://www.longgroveonline.com/ 8. Starved Rock State Park http://www.destination360.com/north-america/us/illinois/starved 9. Rockford Sock Monkey Museum, Time Museum, etc 10. Lake Geneva, tons to do. http://www.lakegenevawi.com/ 11. Goebberts Farm in Barrington or Hampshire, great for Fall activities http://www.pumpkinfarms.com/BarA.html 12. Apple picking: http://www.allaboutapples.com/orchard/il01.htm 13. House on the Rock (个人建议一定要去一次) http://www.thehouseontherock.com/index.htm 转自 "UIC自驾游小组: http://xiaozu.renren.com/xiaozu/212618 "

实用 Eclipse 插件 Plug-in (转)

clipse插件原来喜欢用WTP,后来在eclipse网站上有了整合了WTP的Eclipse IDE for Java EE Developers,就一直用到现在,还挺顺手的,现在版本是Helios(3.6.1),翻译过来就是太阳神,名字还不错。 以下为现在还在用的插件: Subclipse 地址:http://subclipse.tigris.org/ 整合SVN客户端到Eclipse中,在IDE中方便地进行各种SVN操作。如果是Linux系统,记得要顺便装上 JNA Library,点击查看安装方法。 EasyExplorer 地址:http://sourceforge.net/projects/easystruts/ 这是个十分简单的插件,但功能非常实用:将当前文件在Windows Explorer中打开,省去了你很多的重复操作。 使用ubuntu的同学可以选择OpenExplorer,在ubuntu10.10上我测试有些小问题(nautilus提示找不到打开的文件夹路径),修改了部分源代码后ok了,如果有遇到相同问题的同学可以给我留言。 Jadclipse 地址:http://sourceforge.net/projects/jadclipse/ 这是个Java的反编译插件,需要将jad.exe路径添加至$PATH,或者在eclipse中自己配置jad的路径。 使用ubuntu的同学可以用JodeEclipse,也是很不错的反编译插件,安装很简单,就是一个jar包。 Properties Editor 地址:http://sourceforge.jp/projects/propedit/ 以前在做国际化或者写properties文件时,总是要使用sun的提供的工具native2ascii.exe,转来转去很麻烦,现在有了Properties Editor,一口气转10个,不费劲。 FindBugs 地址:http://findbugs.sourceforge.net 静态代码检查工具三剑客之一,不纠结于代码的样式,而是试图只寻找真正的缺陷

equals and hashcode function in Java (not my writing)

It is not always necessary to override hashcode and equals. But if you think you need to override one, then you need to override both of them. Let's analyze what whould happen if we override one but not the other and we attempt to use a Map . Say we have a class like this and that two objects of MyClass are equal if their importantField is equal (with hashCode and equals generated by eclipse) public class MyClass { private final String importantField ; private final String anotherField ; public MyClass ( final String equalField , final String anotherField ) { this . importantField = equalField ; this . anotherField = anotherField ; } public String getEqualField () { return importantField ; } public String getAnotherField () { return anotherField ; } @Override public int hashCode () { final int prime = 31 ; int result = 1 ; result = prime * result + (( importantField == null ) ? 0 : importantField . hashCode (

Read xlsx file by Java (not my writing)

Required jar files, which you can download from Internet. xmlbeans-2.3.0.jar dom4j-1.1.jar poi-ooxml-schemas-3.6.jar poi-ooxml-3.6.jar poi-3.6.jar import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import java.util.Iterator; import java.io.*; public class ExcelFileReader { public void ReadSheet() throws Exception { String filename = "c:\\test.xlsx"; FileInputStream fis = null; try { fis = new FileInputStream(filename); XSSFWorkbook workbook = new XSSFWorkbook(fis); XSSFSheet sheet = workbook.getSheetAt(0); Iterator rows = sheet.rowIterator(); int number = sheet.getLastRowNum(); System.out.println(" number of rows" + number); while (rows.hasNext()) { XSSFRow row = ((XSSFRow) rows.next()); Iterator cells = row.cellIterator(); while (cells.hasNext()) { XSSFCel

芝加哥附近好玩的地方(转)

-家庭型游玩去处,多考虑小朋友的话,当数six flag。 -想去更刺激点的游乐圆,稍微远点,在ohio 的cedar point 有更多超级项目, 还在湖边可以玩水。 -cherry picking. michigan 是著名产地啊,现摘的明显更好吃。每年学生会都会组织. -采摘苹果 密西根也产苹果.几个著名品种如honey crisp, golden delicious.新鲜的 就是更好吃些,而且苹果耐存放. -采摘pumpkin 农家收获季节。大农村,没办法,采摘项目多点。 -采摘西洋参。这个项目不是凑数了吧。wisconsin的西洋参种植基地,在warsaw 附近.产品可是正宗花旗参,性温良,滋补佳品.中药相关科研中,人参效果明确显著, wisconsin 花旗参则有效活性成分更高.需注意,人参要沸水煮一段时间,活性物 质才会到参汤里。 -corn field maize 走迷宫,记得穿套鞋防水。收获季节的活动。 -湖边看日出。每个刚从国内来正在到时差的亲戚朋友都对我说湖边日出很漂亮 。还有哥们边看边和国内的家人视频,现场转播。 -湖的那边看日落。初春,还没有调时间。开车到湖的对岸,沙滩上还有厚厚的积雪。 -湖对岸的荷兰镇holland,每年春天有郁金香节。4月底5月初。 -环湖。往东环lake michigan.芝加哥标志性旅游项目,冬天和夏天风光完全不 同。详细说说路上经过些什么地方。逆时针方向。从芝大开始往南,走 I94-80,避开I90的高额过路费。gary,过了州界就是,税低,有些人跑到这里购物。 indiana dunes national lakeshore。这个national名不副实。michigan city outlet mall.店多税低铺的开。holland。然后是重点,sleeping bear national lakeshore.先是22号路,湖边观光台,路面起伏曲折但是幅度不大,绿树成荫, 开车特爽。买票去大沙丘,我每次都借口爬完开不动车。那里的数个半岛湖 湾都有好几个周立公园,好几条scenic drive。旅游城市traverse city, 是原来底特律人度假的地方。mackinaw city 连接 michigan上下半岛的大桥, 3块过桥费。和加

Cohen's kappa

For supervised learning, We need to label some training data. If two raters have conflicts on some labelling, Cohen's kappa can be used to measure agreement. http://en.wikipedia.org/wiki/Cohen's_kappa

My home town - Wuhan, China

New Age music

"In the mirror" "Song from a secret garden" "Summer" "远方的寂静"

Wine/water mixing problem

It is a brain-teaser problem. You can replace any liquid name (e.g. coffer, alcohol) with wine or water in the title. The original problem is explained as follows: http://en.wikipedia.org/wiki/Wine/water_mixing_problem "In the wine/water mixing problem, one starts with two jars, one holding wine and the other an equal volume of water. A spoon of water is taken from the water jar and added to the wine. A spoon of the wine/water mixture is then returned to the water jar, so that the volumes in the jars are again equal. The question is then posed—which is more, the wine volume in the water jar or the water volumn in the wine jar?" Here is my solution. We assume: Originally, the volume of water in jar of water (jar W): Vw Originally, The volume of wine in jar of wine (jar A): Va The volume of spoon: Vs We first a get a spoon of water from jar W and put it into jar A. Then we get a spoon of liquid from jar A and put it back into jar W. p is percentage of