Thursday, April 25, 2013

Share folder between Windows and Ubuntu 12.04 by mean of Samba

The best way to share folder between different Windows and Linux is to share it on Linux and let Windows explore it in network. Sharing on Windows and exploring from computer and folder from Ubuntu is never stable (Linux guru could do this, but it is not for ordinary user).

Follow pretty good illustrated instructions, works fine for 12.04:
http://www.liberiangeek.net/2010/06/how-to-quickly-change-workgroup-name-in-ubuntu-10-04-lucid-lynx/

Restart samba service after each sharing( just in case :) ), in Ubuntu 12.04 as:

sudo restart smbd

If smth does not work, restart Linux PC, this will help windows to see your Linux :). 

Tuesday, April 23, 2013

Cleaning cache for Apache by htcacheclean


Detecting apache cache problem, cleaning cache for apache by htcacheclean.
good pages: page1, page2, page3.

My case:
in apache config /www/etc/apache/adm/virt.serv/10_my-service.cfg:

CacheRoot /www/cache/my-service
CacheDirLevels 2
CacheDirLength 1
CacheDefaultExpire 3600
CacheIgnoreCacheControl On
CacheEnable disk /my-service/

I get different content:
wget https://server.com/my-service/css/layout.css
wget https://test-server.com/my-service/css/layout.css

as HTTP Header have value:
Cache-Control: max-age=31556926, must-revalidate 
How to get this in Firebug addon of Firefox:

Or you can do this from terminal :
06:20 PM ~ $ curl -I https://server.com/my-service/css/layout.css
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 01:20:08 GMT
Server: Apache/2.2.19 (FreeBSD)
Expires: Thu, 24 Apr 2014 07:08:54 GMT
Cache-Control: max-age=31556926, must-revalidate
Last-Modified: Mon, 22 Apr 2013 17:32:10 GMT
Content-Length: 36490
Connection: close
Content-Type: text/css
Set-Cookie: Coyote-2-4a7446e9=c0a89971:0; path=/

So caching could be adjusted on Tomcat side, after then on Apache side(CacheDefaultExpire and "CacheEnable disk /my-service/"), and then kept by user's Browser(Cache-Control: max-age). 

Cache could be adjusted in tomcat side in Spring config (28800 = 8 hour):
<mvc:resources mapping="/css/**" location="/css/" cache-period="28800" />

So after each Tomcat rollout we have to do:
htcacheclean -p/www/cache/my-service -l1K -v

if you have problem on apache clear cache like "An error occurred, cache cleaning aborted."
be sure you  /www/cache/my-service/ is created and "chown apache /www/cache/my-service/", "apache" username is taken from "ps -ef| grep http" as on Freebsd it is "www". Also be sure you launch htcacheclean under right user.

Saturday, April 20, 2013

SevNTU Checkstyle version 1.8.0


We finished new version of our extension for Checkstyle - release 1.8.0, new and noteworthy.

new NestedTernaryCheck.
Main idea of check to forbid to use nested ternary conditions, as it hard to read and debug them then
if(){}else{},  example:
int smth = (a == b) ? -1 : (c == d) ? 0 : 1;
this code is very compact, but it is disaster for other developer to understand and debug this code. In this case we could say logic is archived, and need spend extra time to extract logic over over again during debug, and that compact view does not contribute to performance.

Expected code is substitution by function:
int smth = calculateSmth(a, b, c, d);
or:
int smth = -1;
if (a!=b) {
  if (c ==d) {
      smth = 0;
  } else {
      smth = 1;
  }
}
The only benefits to use such statement is to declare "final" variable, so this is available as option in check, but it is not selected by default.


new ForbidReturnInFinalBlockCheck.
Return statement in final block is allowed by compilation. But it is highly non-recommended to use it, as it change return of main logic.
Example:
try { 
   return true; 
} finally { 
   return false; 
}
More info and discussion is here.


Bug fixing for existing checks:
 - Message improvement in ChildBlockLengthCheck,
 - bug fixing in AvoidHidingCauseExceptionCheck and OverridableMethodInConstructorCheck,
 - ignore methods now support RegExp at ReturnCountCheckExtended.


Note:
Available as EclipseCS extension and as extension for maven-checkstyle-plugin. Install instructions.

Friday, April 19, 2013

List of Open Source Organizations that are rejected for GSoC 2013

Logs of conversation in IRC @freenode #gsoc at April 19th 2013.

List of Organizations that did not pass GSOC 2013:
It not full list ! gathered from channel queue of "#gsoc" at April 19th 2013.


helenos http://trac.helenos.org/report/19
Ninux.org http://wiki.ninux.org/GSoCIdeas2013
gc3 http://code.google.com/p/gc3pie/wiki/GSoCIdeas
Xpra https://www.xpra.org/trac/wiki/ProjectIdeas
wxWidgets http://www.wxwidgets.org/gsoc/2013/
VideoLAN http://wiki.videolan.org/SoC_2013
darcs http://darcs.net/GSoC
lemora http://lemora.wiki.tum.de/ideas
Broadleaf https://github.com/BroadleafCommerce/BroadleafCommerce/wiki/Google-Summer-of-Code-2013
fairmat http://fairmat.com/developers/projects-ideas/
FFmpeg http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_of_Code_2013
octave http://wiki.octave.org/Summer_of_Code_Project_Ideas
Tatoeba http://en.wiki.tatoeba.org/articles/show/gsoc_ideas
Inktank http://ceph.com/gsoc2013/gsoc-ideas/
Soot http://sites.google.com/a/boisestate.edu/soot-gsoc-idea-list/
X2Go http://wiki.x2go.org/doku.php/events:gsoc2013?rev=1363091158
gstreamer https://live.gnome.org/GStreamer/SoC2013
Haiku http://www.haiku-os.org/community/gsoc/2013/ideas
libav http://wiki.multimedia.cx/index.php?title=Libav_Summer_Of_Code_2013
mailman http://wiki.list.org/display/DEV/Google+Summer+of+Code+2013
balabit https://github.com/balabit/GSoC2013/wiki/Idea-&-Project-list
rohc http://rohc-lib.org/wiki/doku.php?id=ideas-list
LISPmob http://www.lispmob.org/gsoc2013
AtomicBlue http://planeshift.top-ix.org/pswiki/index.php?title=GSoC_2013
Scilab http://wiki.scilab.org/GSoC_project_proposal
libgdx https://code.google.com/p/libgdx/wiki/GoogleSummerOfCode2013
Stud.IP http://docs.studip.de/gsoc2013/index.php/Main/IdeaList
VTK http://vtk.org/Wiki/VTK/GSoC_2013
Dr.Memory http://code.google.com/p/drmemory/wiki/Projects
TuttleOFX https://sites.google.com/site/tuttleofx/gsoc-2013/ideas-list
bitfighter http://bitfighter.org/wiki/index.php/GSOC_ideas
SunPy https://github.com/sunpy/sunpy/wiki/GSoC-2013-Ideas
AdhearsionFoundation http://adhearsion.com/gsoc
buddycloud https://buddycloud.org/wiki/Google_Summer_of_Code_2013
Drupal http://groups.drupal.org/google-summer-code-2013
CGoGN http://cgogn.unistra.fr/GSoC2013/
teammates https://docs.google.com/document/d/1fAvYvQr0E93OsZgyneaXGX0jaMA-zptTIxqLn83xwN0/pub
sevntucheckstyle http://sevntu-checkstyle.github.com/sevntu.checkstyle/gsoc-2013-ideas.html
tradelink.org https://docs.google.com/a/pracplay.com/spreadsheet/ccc?key=0AtDVxYA-85_4dF9INHlZQVNCMUVPdXlsc3R2dF9SRlE#gid=0
reviewboard https://hackpad.com/Student-Project-Ideas-vK8BOo8eOpe
codebender https://docs.google.com/document/d/1JQllHqz7Iocu-lTVBPVkDEc6pL_3VuxZgu8ewZiCT88/edit?usp=sharing
ITK http://www.itk.org/Wiki/ITK_Google_Summer_of_Code/2013
comunes http://kune.cc/#!comunes.wiki.318.529
copyleftgames http://gsoc.copyleftgames.org/
PyDy https://pydy.org/gsoc_2013_ideas
CellCollective http://www.thecellcollective.org:8080/cc.web/spring/gsoc-flow
MATE_DE http://wiki.mate-desktop.org/gsoc:2013#ideas
Brackets https://github.com/adobe/brackets/wiki/Google-Summer-of-Code-2013-Project-Ideas
OpenIntents http://code.google.com/p/openintents/wiki/GSoC2013Ideas
Geeklog http://wiki.geeklog.net/index.php/Google_Summer_of_Code
Simbios http://wiki.simtk.org/dissemination/SWIdeas
Luxunda http://www.luxunda.es/gsoc-2013
ClimatePrediction.net http://climateprediction.net/GSOC/
comunes http://kune.cc/#!comunes.wiki.318.529
CloudNets https://projects.net.t-labs.tu-berlin.de/projects/cloudnets-framework/wiki/Ideas
BuddyPress codex.buddypress.org/gsoc2013/
Xapian http://trac.xapian.org/wiki/GSoCProjectIdeas
ging http://ging.github.io/projects.html
Shoes https://github.com/shoes/shoes4/wiki/GSOC-2013-idea-list
OBF http://www.open-bio.org/wiki/Google_Summer_of_Code

Saturday, April 13, 2013

Why Screenshots pages are required on UI applications web sites

Here will be summary or draft thoughts about description pages for UI applications:

When somebody search for application he do it by textual search in google/bing/.... that approach direct him to your project/application page with description. And from that step investigation approach become different.

Your project will never be alone in goolge search results - but you have to persuade new user examine list of features and to download and try your application.

Both that targets could be done only if content that you provide on web site is easy to read (small chunks of text that describe key feature), and PICTURES for most cool features!

Pictures are vital and indispensable ! by means of good picture you can describe more that you can describe in big text paragraph. Nobody will read your description ! Text descriptions are for search engine bots only!
By means of cast of screenshot you can force user to fall in love with your application - from first sight!
Or by judging of screens user could understand that that this application is not for him - but he will not spend his time on testing your application so user's attitude will not be negative, it will stay neutral - IT IS BETTER THEN NEGATIVE.

Absence of Screeshots pages at your site - will make your project to be reviewed the last.

Even shell applications/scripts need screeshots !!  see example for zsh-git-prompt below.

Good example examples:
any Firefox or Thunderbirs addon description page, example1, example2.
Meld - http://meldmerge.org/features.html
Shutter - http://shutter-project.org/preview/screenshots/
Eclipse plugins - example
Xchat - http://xchat.org/
Git shell prompt - https://github.com/olivierverdier/zsh-git-prompt.

Bad example:
DSM library -  http://jdsm.sourceforge.net/index.html
Xchat-gnome - https://live.gnome.org/Xchat-Gnome
JMeter - http://jmeter.apache.org/index.html 
...
i will keep posting as smth come to my attention.

Visual merge tools to resolve conflicts

Git visual merge in conflict:
http://www.gitguys.com/topics/merging-with-a-gui/

Meld - Works fine, but not intuitive.


sudo apt-get install meld
git mergetool -t meld
Main idea is to merge left and right versions to middle version and press Cntl+s.


kdiff3 - more intuitive and more settings.

sudo apt-get install kdiff3
git mergetool -t kdiff3


After that launch "git clean -f" to remove all un-tracked files.
It also possible to adjust git to avoid temp files creation
"git config --global mergetool.keepBackup false"

of adjust  your merge tool:
- Meld - does not have that feature
- kdiff3's settings are set to not create a backup:
Configure/Options => Directory Merge => Backup Files (*.orig)

Friday, April 12, 2013

Force Oracle to recalculate execution plan for a table

Steps to force Oracle to recalculate execution plan for tables:

EXEC DBMS_STATS.GATHER_TABLE_STATS('<Schema_name>','<Table_name>'); 



-- deprecated approach
ANALYZE table <SCHEMA_NAME>.<TABLE_NAME> compute statistics;

and, DBMS_STATS.GATHER_TABLE_STATS is preferable (source: link, oracle-link)

Sunday, April 7, 2013

Java DecimalFormat example


Sites to launch java code online:
http://www.compileonline.com/compile_java_online.php
http://www.javalaunch.com/JavaLaunch.jsp (no restrictions)
http://rextester.com/runcode (attention: it restrict class to be named as Rextester) list of all, here .

Task: Print 0.1278 as 12.8%. java doc.

 Code:
import java.text.DecimalFormat;

public class Test {

 static public void customFormat(String pattern, double value) {
  DecimalFormat myFormatter = new DecimalFormat(pattern);
  String output = myFormatter.format(value);
  System.out.println(value + "  " + pattern + "  " + output);
 }

 static public void main(String[] args) {
  customFormat("000.0%", 0.1278);
  customFormat("#0.00%", 0.1278);
  customFormat("###.##%", 0.1278);
  customFormat("##0.0%", 0.1278); ////!!!!!
  customFormat("#.####%", 0.1278);
 }

}

Wednesday, April 3, 2013

Connect from to Oracle DB from Groovy

http://www.javaworld.com/community/node/2886

For Ubuntu 12.04:

groovy -cp /u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar toOracle.groovy

content of toOracle.groovy:

import groovy.sql.Sql

sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:xe", "user_schema", "password",
"oracle.jdbc.pool.OracleDataSource")
sql.eachRow("SELECT id FROM user_schema.table_name")
{
println "The employee's name is ${it.id}."
}