2016年6月17日星期五

[Solr] Why setting maxBooleanClauses does not take effect?

If you have multiple cores, setting one of them to different value won't work. You need to set maxBooleanClauses to the same value across all the scores in solrconfig.xml.

It will automatically become the default value (1024) if they are not consistent.

The reason of all this shit is that, maxBooleanClauses is actually a global value for solr instance. It is not an independent value for each core.


Fuck solr! And big thanks to: http://qindongliang.iteye.com/blog/2261099

2016年6月14日星期二

When the disk space left does not match space used...

When the disk space left does not match space used, it usually means some process is still using files that are already deleted.

Use

lsof +L1
to find out which process is opening a deleted file.

Restart the process to release the disk space.

2016年3月9日星期三

Solr: how to set hard commit, soft commit and openSearcher

https://lucidworks.com/blog/2013/08/23/understanding-transaction-logs-softcommit-and-commit-in-sorlcloud/

A hard commit is to write the data to disk and rotate the transaction log. You can optionally open a new searcher after a hard commit. Open a new searcher after a hard commit is slow.

A soft commit will always open a new searcher, but the cost is much less than a hard commit. A soft commit will not rotate the transaction log. In case of a server crash, if the transaction log is large, a long recovery time is needed when restart the server.


In a near-realtime environment, set autoSoftCommit as long as you can tolerate. Hard commits with openSearcher set to false, as soft commit will open new searcher. The period for hard commit should be determined by the indexing load. The heavier the indexing of new docs, the shorter the period for autoCommit.

2016年1月13日星期三

Javascript best practice and optimization

https://github.com/petkaantonov/bluebird/wiki/Optimization-killers

https://github.com/airbnb/javascript

2015年10月22日星期四

Eclipse 開唔到,stuck左喺loading

https://www.ibm.com/developerworks/community/blogs/f37f6f3c-d39f-49c9-884b-a1665b7e2ca3/entry/tutorial_how_to_investigate_startup_issues_of_eclipse_based_products_where_the_java_process_hangs_during_the_start_up?lang=en

問題:
Eclipse開o既時候停左喺度唔郁,但冇error
睇workspace入面個.log file會見到話timeout deadlock之類:

!MESSAGE While loading class "org.eclipse.jdt.internal.launching.JREContainerInitializer", thread "Thread[main,6,main]" timed out waiting (5034ms) for thread "Thread[org.eclipse.jdt.internal.ui.text.JavaReconciler,1,main]" to finish starting bundle "org.eclipse.jdt.launching_3.6.1.v20111006_r372 [366]". To avoid deadlock, thread "Thread[main,6,main]" is proceeding but "org.eclipse.jdt.internal.launching.JREContainerInitializer" may not be fully initialized.

我自己經驗,冇跟足條link
1. -clean 唔work
2. restart 部機唔work
3. -debug +.options file 無喱頭成功開到eclipse,但啲野爛晒。閂左佢重開,problem solved

2014年8月22日星期五

如何分辨in-app browser







I developed an app for iOS and Android which accesses an HTML file from my webserver using the in-app browser (Webview).
I don't want that a user can access this file without using the app. Is there a possibility to detect, if the user is accessing the file with the app or directly via a browser on this smartphone / tablet / computer? I think that a solution with PHP is much better, because Javascript can be switched off. At least Google Analytics can differentiate between Safari and Safari (in-app). It should work with every version of iOS and Android.
Thanks for your help.

Solution
After many attempts I finally found a working solution for me!
iOS: You can detect the difference between Safari and the in-app browser using the user agent. Probably there's a nicer solution, but it works.
// Safari (in-app)
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false) {
    echo 'Safari (in-app)';
}
Android: The package name from the app is stored in the PHP variable $_SERVER['HTTP_X_REQUESTED_WITH'].
// Android (in-app)
if($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app") {
    echo 'Android (in-app)';
}

 喺iOS,chrome同opera都會有Safari寫喺user agent度

Ref: http://stackoverflow.com/questions/16383776/detect-in-app-browser-webview-with-php-javascript

2014年8月19日星期二

jclouds Guice creation error

用jclouds舊lib會有Error,如果java version 大過1.7.0_45,用java 1.8一樣會有

解決方法:一係downgrade java, 一係upgrade jcloud,但jclouds搬左去apache,同埋個interface 唔同晒…

com.google.inject.CreationException: Guice creation errors:

1) org.jclouds.rest.RestContext cannot be used as a key; It is not fully specified.

1 error
    at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
    at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
    at com.google.inject.Guice.createInjector(Guice.java:95)
    at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:401)





ref: http://stackoverflow.com/questions/21536498/error-creating-blobcontext-using-jclouds-in-a-spring-mvc-application

2014年7月2日星期三

IIS FTP passive mode not obeying the defined port range issue

After setting the port range for passive mode, IIS keep telling the client to use random ports. The port range setting does not take effect.

Solution:
Open "Services", "restart Microsoft FTP Service".
 http://forums.iis.net/t/1157414.aspx?IIS7+FTP7+Passive+Mode+Problem+Ignoring+Data+Channel+Port+Range+


Other reason:
Some said that windows firewall will modify the passive mode port send by the ftp server. Solution is to use ports other than port 21 or close windows firewall.

2012年11月16日星期五

chkconfig in Ubuntu 12.04

#Install
apt-get chkconfig

#Cannot find insserv in given path, create a soft link for it

ln -s /usr/lib/insserv/insserv /sbin/insserv


#The following error message will appear when running chkconfig, but it is fine.##The script you are attempting to invoke has been converted to an Upstart #job, but lsb-header is not supported for Upstart jobs. #insserv: warning: script 'friendly-recovery' missing LSB tags and overrides #insserv: Default-Start undefined, assuming empty start runlevel(s) for script `friendly-recovery' 
#.....
#.....

Reference: http://www.linuxeden.com/html/sysadmin/20120622/126182.html

2012年10月29日星期一

Mysql

How is Primary Key added to the index for InnoDB:
http://www.penglixun.com/tech/database/will_innodb_store_pk_in_index.html

1. Add ONLY the missing primary key column to the end of the index
eg.
pk (a, b)
key1 (c, a) => key1(c, a, b)
key2 (b, c) => key2(b, c, a)


2. Query does not know the key existence of index (c, a, b), (b, c, a), so the wrong index may be choosen.

2012年10月28日星期日

Running Java

To include all the jar in a dir:
java -cp /path/to/dir/*

2012年10月26日星期五

Nginx

Warning: worker_connections exceed open file resource limit
-> add ulimit -n 10240 to /etc/init.d/nginx

Java Server Sticky Session
-> http://code.google.com/p/nginx-upstream-jvm-route/

File Upload Size Limit
client_max_body_size
Default is 1m

2012年10月19日星期五

Command line image processing

JMagick vs IM4J and ImageMagick vs GraphicsMagick
http://blog.csdn.net/cmg666/article/details/6139601

2012年10月18日星期四

InnoDB vs MyISAM

InnoDB vs MyISAM
http://tag1consulting.com/MySQL_Engines_MyISAM_vs_InnoDB

Lucene

Lucene Eurocon 2011
http://2011.lucene-eurocon.org/pages/120874

Twitter Real-time Search Experience
http://2011.lucene-eurocon.org/attachments/0002/8787/Busch_twitter_realtime_search_eurocon_11.pdf

Lucene/Solr bug with JDK7

http://blog.thetaphi.de/2011/07/real-story-behind-java-7-ga-bugs.html

http://java.dzone.com/videos/java-7-lucene-bug-controversy