Sunday, July 6, 2014

怀念妈妈

      已是午夜,我又想起妈妈。这些天来,恍惚中妈妈似乎从来没有离开我。跟妈妈的最后一次电话正巧录音了,一个多小时的电话里,妈妈牵挂着哥哥姐姐和我的身体,妈妈欣慰我在加拿大买房子了。妈妈说,她要从襄樊回去弄红薯苗、西红柿苗......始终难以接受,妈妈永远的走了。我永远失去了最爱我、最关心我、给了我一切的妈妈。

      多希望时光倒流,能多陪些妈妈。接到哥姐电话急匆匆赶回去的路上,我一再祈祷,祈祷上帝能再给妈妈10年的寿命,我希望能用自己10年、20年的寿命换回妈妈的寿命。赶到医院后,我见到了妈妈最后一面,但妈妈没能苏醒过来,妈妈自从上救护车后,就再也没苏醒过来。以后送妈妈去火葬场、,捧着妈妈的骨灰回家、晚上给妈妈守灵,好像躯壳已经麻木了,只想追随妈妈。也许,妈妈突然离去,对一生饱受病痛,没有享受太多生活乐趣的妈妈而言,真的是一种解脱。听村里人说,妈妈之前念叨,希望像村人一样,突然间就没了,不给子女累赘,不给自己痛苦。

      妈妈袁桂芝,生于1947年农历8月27日,逝于2014年阳历4月24日。妈妈年轻时很美丽,眉心正中还有一颗红色的痣,一直到老,妈妈的头发都乌黑发亮。妈妈曾提起,记得以前在杨集合作社买东西的时候,一个小孩看到妈妈,一边指一边喊“观音菩萨!观音菩萨!”。妈妈很小的时候就经常头痛,容易晕车,年纪大了之后,又落下腰痛、胃痛的毛病。妈妈走之前,最关心的也是哥哥、姐姐和我的身体。假如我当初学医,该有多好,说不定能治好妈妈和姐姐的头痛。

      妈妈与人无争,不管是和邻居,还是和陌生人,都是随和大度。在山里承包水库养鱼塘多年,妈妈对南来北往的熟人也好,陌生人也好,过来讨水喝的都热情接待。和邻居家的地界有纠纷了,妈妈也主动退让。和亲家母相处,连保姆都伸大拇指。妈妈到北京,虽然不会说普通话,但很快和小区的人打成一片,后来经常有人过来邀请打牌。妈妈打牌其实只是凑份子,有人在旁边观看时,妈妈往往会让给别人打一会儿。妈妈喜欢和人聊天,因为身体不好,不能起早熬夜。但这些年来跟着爸爸承包养鱼塘,经常一个人窝在山沟里,缺朋少友,担惊受怕。时不时得洗一大堆的衣服,做一大群人的饭菜,而且弄鱼的衣服往往分外脏,还得忍着头晕给爸爸找东西。妈妈做的菜很好吃,去我们家做过客的都印象深刻。syh过来看望时,还提起syp来我家做客后一直说,从来没吃过这么好吃的鱼。,妈妈做的花生米、炒仔鸡也是一绝,可惜我再也吃不到妈妈炒的菜了。之前学了几个菜,一直想赶春节回家,让妈妈也尝尝我炒的菜,妈妈你为何不等等呢?妈妈始终以最深厚的母爱关心爱护她的子女,没有丝毫的私心,全然不图分毫的回报。

      奶奶这些年来,由于眼睛看不见,年龄又大,人人嫌弃和厌烦。但妈妈对奶奶嘘寒问暖,照顾备至。妈妈说,是奶奶给了她幸福的时光,一直到30多岁分家前,妈妈都不会做饭,奶奶始终照顾多病的妈妈。妈妈说,奶奶不能动了,是自己回报奶奶的时候了。妈妈受病痛折磨,希望像村人一样突然离去的时候,最放不下心的就是奶奶。妈妈你放心,就算所有人都不照顾奶奶了,我会照顾奶奶的。虽然我不能陪在奶奶身边,但我会找人伺候奶奶的。

        爸妈经常吵架,爸爸经常喝酒,每次都喝醉,醉了就耍酒疯,赶全家人滚。有一年都快腊月三十了,爸爸又醉了发酒疯,赶全家人滚,可怜妈妈冒着漫山大雪,领着我和姐姐去山下借宿。甚至到一年前,妈妈还因为护着姐姐被爸爸赶的半夜离开家门。妈妈为了子女,为了家,受尽委屈和艰辛,妈妈始终苦苦撑着这个家。妈妈走了,那个家就散了,我的魂也没了,我的根也没了,我的依托没了。

      也许我,哥哥和姐姐希望妈妈别离开,是我们太自私了。妈妈在,大家都感觉在一起,我时时想着回家。妈妈在的时候,我们没有能给予妈妈什么,一直是妈妈无私的爱护帮助我们。妈妈以自己希望的方式走了,希望天堂里没有病痛折磨,愿妈妈永安。

Wednesday, June 25, 2014

Make the table smaller for test and restore it back

Scenario:
There's a huge table with 40 million records or more and now for test purpose need limit the records to the latest 5 days records. After the test, need
restore the table.
Resolution:
Delete would be very, very slow. It may need 24 hours or even longer. The best way is to rename the table and create the new table.

Thursday, June 12, 2014

gradle note

1.
The left shift operator << is a shortcut for the action doLast.
task helloWorld {
doLast {
println 'Hello world!'
}
}
equals to
task helloWorld << {
println 'Hello world!'
}

2.
gradle -q tasks
gradle -q tasks --all
gradle -q helloWorld -> gradle -q hW
gradle -b ... Use this option to execute a build script with a different name other then build.gradle

3.
http://www.gradle.org/docs/current/dsl/index.html
jar{
exclude('**/*.properties')
}

4.
mavenLocal()
mavenCentral()
From http://www.gradle.org/docs/current/javadoc/index.html
DependencyHandler
   //declaring arbitrary files as dependencies
   compile files('hibernate.jar', 'libs/spring.jar')

   //putting all jars from 'libs' onto compile classpath
   compile fileTree('libs')
maven { url "http://cptrasv01:8081/nexus/content/groups/public/" }
    compile group: 'com.tdsecurities.stars.mdm', name: 'midas_common', version:'1.0.1-SNAPSHOT'

5. gradle plugin application does not work for inteactive console application even the below is added into the build.gradle
run{
    standardInput = System.in
}

6. Changing the project default layout
sourceSets {
main {
java {
srcDirs = ['src']
}
}
test {
java {
srcDirs = ['test']
}
}
}
buildDir = 'out'

7.
Using the wrapper is considered best practice and should be mandatory for every Gradle
project. Gradle scripts backed by the wrapper are perfectly prepared to run as part of
automated release processes like continuous integration and delivery.

drop table

default drop table does not free the table space, while truncate table will free the table space.
The fastest way to unload and load data from/to oracle is to use some pro*c to "flatten out" the data to a flat file and sqlldr
with direct path mode to reload it. (By Tom)
My test shows that it needs 5 minutes to unload 50 millions data from the database (4G csv file)

Monday, June 2, 2014

SLF4J, logback and groovy

logback.groovy does not support
<configuration debug="true"> in logback.xml.
statusListener(OnConsoleStatusListener) may help.
Or add the below to the source:
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);

HelloWorld.java
package log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;

public class HelloWorld {
public static void main(String[] args) {
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
Logger logger = LoggerFactory.getLogger(HelloWorld.class);
logger.info("Hello World!");
}
}


logback.xml

<configuration debug="true">

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>myApp.log</file>
    <encoder>
      <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyyMMdd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="FILE" />
    <appender-ref ref="STDOUT" />
  </root>
  
</configuration>

logback.groovy

statusListener(OnConsoleStatusListener)

appender("FILE", FileAppender) {
  file = "myApp.log"
  encoder(PatternLayoutEncoder) {
    pattern = "%date %level [%thread] %logger{10} [%file:%line] %msg%n"
  }
}

appender("STDOUT", ConsoleAppender) {
  encoder(PatternLayoutEncoder) {
    pattern = "%d{yyyyMMdd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
  }
}

root(DEBUG, ["FILE","STDOUT"])

Sunday, June 1, 2014

The elephant and the ant

http://books.google.ca/books?id=sNF5PxD0SV4C&printsec=frontcover&dq=the+ant+and+the+elephant&hl=en&sa=X&ei=n9uLU6_wKoKe8gHZuYDwDQ&ved=0CDoQ6AEwAA#v=onepage&q=the%20ant%20and%20the%20elephant&f=false
1. Just when it seemed he would be swept downstream and gone forever, the ant grabbed onto a snag and scrambled to safety.
2. The ant remained stranded wondering what he would do, ...
3. called the ant in his wee, small voice.
4. I've had my swim for today, and besides, if I went racing about helping everyone who was in trouble I'd have no time left to relax.
5. Then the turtle tottered on his way to ...
6. Suddenly he went toppling backward and landed upside down.
7. "Blast it all, " he muttered. "Dad blame it! " And he began thrashing out with his legs.
8. As he stretched his stringy neck looking about for help, the turtle spied a hornhill roosting on her nest high on a tree limb.
9. As she leaned down to say more, the hornbill tipped the nest and her one big egg rolled out to go tumbling all the way to the ground. Luckily it landed in a clump of fluff-twuff weeds without so much as a crack.
10. Still she kept on furiously thrashing the air until her wings worn to a frazzle.
11. a giraffe came striding along
12. He flopped down with such a whump! it upset a huge boulder which was all set to topple. 
13. With a furious roar he leaped to his feet, tugging frantically to free himself.
14. he went lumbering off the trees
15. "Out of my way, you stupid stump!" He snorted. And with a furious lunge he tried to knock over the stump. This drove the horn still deeper. Then with a mighty tug he tried pulling himself free, but the stump refused to let go. At last the rhino realized he was hopelessly stuck.
16. That would have been that if a jolly big somebody hadn't decided to take a stroll through the jungle that day.
17. Then without a word of thanks the old codger went tottering away down the bank to disappear in the river.
18. The elephant didn't suspect there was a deep ravine just ahead. It was too well hidden by scatter-flat ferns.
19. He waited for hours, staring up at the sky until it faded into evening and a deep stillness settled over the jungle.

Tuesday, May 27, 2014

Java remote debug to linux

1. On linux side, no need to configure anything (For JConsole, need config iptables)
2. Compile the application with the debug options, for gradle, add the below (may use javap to verify)
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
3. add -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y to start the Java application
4. From Eclipse, create a new remote Java application in the debug configuration for the app
5. When the Java application suspends on linux (the message would like "Listening for transport dt_socket at address: 4000"), run the debug from PC eclipse
~~~ enjoy

For maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<debug>true</debug>
                                       <debuglevel>lines,vars,source</debuglevel>
</configuration>
</plugin>