answersy.com Blog Got questions? Got answers! 2011-10-20T04:28:21Z http://answersy.com/zchen/feed/atom/ WordPress zchen http:// <![CDATA[How to install 64-bit sqlplus and perl DBD::Oracle package on Mac OS X?]]> http://answersy.com/zchen/?p=393 2011-10-20T04:28:21Z 2011-10-20T03:18:58Z The Mac OS X version is 10.6.8.
The Perl is installed at /usr/bin/perl, version (perl -version) is "v5.10.0 built for darwin-thread-multi-2level."

There are two good articles on the web that discuss this issue, but none of them is perfect for me. So I tried to add my stuff here.
The first is about installing sqlplus: http://www.danilovizzarro.it/2008/07/how-to-install-sqlplus-and-the-oracle-client-v102-on-a-mac-os-x-leopard-1054/
The second is about installing DBD::Oracle: http://blacka.com/david/2008/11/12/how-to-install-dbdoracle-on-mac-os-x/

To install sqlplus, you need download instantclient form oracle site, the following (64-bit) packages:

  • Basic: instantclient-basic-10.2.0.4.0-macosx-x64.zip
  • Sqlplus: instantclient-sqlplus-10.2.0.4.0-macosx-x64.zip
  • To install DBD::Oracle, you need one more package:

  • SDK: instantclient-sdk-10.2.0.4.0-macosx-x64.zip
  • Once you download and unzip them, all the files will go to a directory called instantclient_10_2. Move this folder to something like /opt/oracle


    $ sudo mv instantclient_10_2 /opt/oracle

    You should set unix environment variable like the following:

    DYLD_LIBRARY_PATH="/opt/oracle/instantclient_10_2"
    export DYLD_LIBRARY_PATH
    TNS_ADMIN="/opt/oracle/tns"
    export TNS_ADMIN
    ORACLE_HOME="/opt/oracle/instantclient_10_2"
    export ORACLE_HOME

    To connect to the an Oracle via sqlplus you can run the following command:

    # sqlplus DB_USER/DB_PASS@//DB_HOST:DB_PORT/DB_SID

    To install DBD::Oracle, you will need to download perl DBD package from CPAN, I chose version 1.32.

    After you download the package, unzip it to ~/Download/DBD-Oracle-1.32, make sure you have set ORACLE_HOME and DYLD_LIBRARY_PATH correctly.
    You need to set some soft link in $ORACLE_HOME (This is the key step most readme files failed to mention.)


    $ cd /opt/oracle/instantclient_10_2/
    $ sudo ln -s /opt/oracle/instantclient_10_2/ lib
    $ sudo ln -s libclntsh.dylib.10.1 libclntsh.dylib
    $ ls -l

    lrwxr-xr-x 1 root admin 31 Oct 19 16:36 lib -> /opt/oracle/instantclient_10_2/
    lrwxr-xr-x 1 root admin 20 Oct 19 16:32 libclntsh.dylib -> libclntsh.dylib.10.1

    Now you can compile the DBD::Oracle Package now:

    $ cd ~/Download/DBD-Oracle-1.32
    $ perl Makefile.PL
    $ make
    $ sudo make install

    In perl script you connect to oracle server using the following code:

    #! /usr/bin/perl -w

    use warnings;
    use strict;
    use Data::Dumper;
    use DBI;

    my $sid = "host=host.xyz.com;sid=DBSID;port=1521"
    my $dbh = DBI->connect("dbi:Oracle:$sid", $user, $pass) or die "ERROR: failed to connect db: $@\n";

    ]]>
    0
    zchen http:// <![CDATA[How to install Perl DBD, DBI::mysql Modules under Mac OS X?]]> http://answersy.com/zchen/?p=385 2011-10-12T04:05:56Z 2011-10-12T04:04:26Z Please refer to http://www.quicomm.com/apm_dbddbi.htm

    And you are likely see the following error:

    dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
    Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
    Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

    You need to set the following in your .profile or .bash_profile

    export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

    see also http://lightyearsoftware.com/2011/02/mysql-5-5-on-mac-os-x/

    ]]>
    0
    zchen http:// <![CDATA[Why?!]]> http://answersy.com/zchen/2011/09/24/why/ 2011-09-24T09:03:38Z 2011-09-24T09:03:38Z 为什么?!

    ]]>
    0
    zchen http:// <![CDATA[Hiking Wunderlich County Park]]> http://answersy.com/zchen/?p=370 2011-08-21T03:42:56Z 2011-08-20T17:32:33Z Resume my hiking experience again! I have to say I picked a good hike this time: the Wunderlich County Park.

    Exit either Sand Hill Rd or Woodside Rd from I-280, the park is only about 5 minutes away, with a relatively small sign at the entrance of the park.

    I went there at around 7:00AM in the morning. The weather was fabulous and there were not many cars in the parking lot. The park is actually a very popular destination, you can hardly find a parking if you get there after 8:30AM :-)

    Overall, the hike is fairly easy. I started from the parking lot and walk to the south corner. Alambique Trail starts to the left and Bear Gluch Trail begins to the right. Bear right to the Bear Gluch Trail. 

    The trail was fully covered by shades. After ascending 0.7 mile, I past Redwood Flat. There are lots of redwood trees on both side of the trail.

    After another 0.8 mile, I suddenly noticed the sky became much brighter. That was “the Meadows.”

    The Meadow Trail is on the left while Bear Gluch Trail continues to the right heading to the Alambique Creek. After about 0.5 mile, I got to the Alambique Flat, a quite shady spot where one can hear the creek trickling by.

    Then I turned onto the Alambique Trail and the rest of the journey became easy descending path.

    It took me less than 2 hours before I got back to the parking lot. I really enjoyed the sunshine coming through the shady redwood trees!

    ]]>
    0
    zchen http:// <![CDATA[感悟之四]]> http://answersy.com/zchen/?p=357 2011-07-20T22:21:05Z 2011-07-20T22:20:24Z 路上,和一个单身的同事谈到组成家庭。他说:“年纪越大,越难。因为各自都有不愿放弃的东西,不能做出太大的让步。”人是历史的,虽然对每个人而言,历史仅仅十几二三十年之短,但是似乎它就足以积淀下很多让人坚守而不放弃的原则。其实再想一想人生之前后,又有多少放不下的东西最终不得不放下呢?当人可以主动选择的时候,总是很自信满满,其实再成功的人难道不都是被选择的结果,虽然我们并不知道是被谁选择。

    ]]>
    0
    zchen http:// <![CDATA[感悟之三]]> http://answersy.com/zchen/?p=363 2011-07-12T23:06:55Z 2011-07-12T23:06:55Z 每个人在每个时间都有自己的优先级。成功的人先把别人的优先级变成自己的优先级,再影响别人把优先级变得和自己相似或一致,这就是影响力,在一定程度上也是获得幸福的一种能力。失败的人只想到自己的优先级,不肯做任何让步,结果就没有人愿意跟随他,最终只有很小的影响力,也少有幸福感。人越老越难以改变自己的本性,因此也就很难越出自己的境界。

    ]]>
    0
    zchen http:// <![CDATA[Some Shell Commands]]> http://answersy.com/zchen/?p=355 2011-07-12T22:59:27Z 2011-07-11T06:27:39Z Unix Sort

    $ sort -n -k 1 -k 2 src.tsv > des.tsv (sort by number value)
    $ sort -k 1 -k 2 src.tsv > des.tsv (sort by text value)

    vim: change file format: dos/unix/mac

    $ vim +"argdo set ff=" +wqa <files>
    $ vim +"argdo set ff=unix" +wqa <files>

    $ vim +"argdo set ff=dos" +wqa <files>

    $ vim +"argdo set ff=mac" +wqa <files>

    vi/vim remove ^M
    :%s/^V^M//g

    ls absolute path
    $ls -d $PWD/*

    ]]>
    0
    zchen http:// <![CDATA[感悟之二]]> http://answersy.com/zchen/?p=353 2011-06-23T14:41:02Z 2011-06-23T14:41:02Z 人在基本温饱满足之后最大的需要是人际关系。人最重要的人际关系除了父母家庭,大多是在学生时代和职业初期形成的。再往后的关系,就越来越容易淡漠。如何保持功利之外的关系对人的一生非常重要。

    ]]>
    0
    zchen http:// <![CDATA[感悟之一]]> http://answersy.com/zchen/?p=349 2011-06-13T03:35:57Z 2011-06-13T03:35:57Z 生命短暂而脆弱,充满了悲剧的因素;但是人们却并不因为弱小而放弃贪婪或执着;精神领域里,为了寻找存在的本源意义,人为自己设计了神圣的信仰和主宰;物质世界中,为了追求幸福生活,人们把地球改变得足以让上帝大吃一惊。
    然而,对每一个人至关重要的事情,在他人眼中其实无关紧要,而那些成就了的伟业,也都尽数随着时间的蹉跎而渐渐淡出了人们的生活日常。时间总是在磨平一切旧的痕迹,为新生命让路。

    ]]>
    0
    zchen http:// <![CDATA[男性健康标准:有两个亲密朋友更长寿]]> http://answersy.com/zchen/?p=350 2011-06-13T02:52:09Z 2011-06-13T02:52:09Z 男人的健康经常被忽略,近日,美国十几位健康专家称,如果以下10条中你能达到7条,就可以被称为“真正健康”的男人了。

    1.有较高水平的高密度脂蛋白

    全球每年约有35.6万名男性死于心脏疾病。心血管病专家指出,如果血液中有充足的HDL(高密度脂蛋白),基本上就不用担心了。

    要增加体内的HDL水平,需要至少每周4次、每次20分钟的中等强度锻炼。正常人血液中的HDL是40毫克/分升左右,最好能达到该数字的两倍。

    2.有两个亲密的哥们儿

    这两个哥们儿不包括目前的同事、邻居、健身教练等,总之不能为任何固定出现在生活中的人。

    心理学家认为,如果一个35岁以上的男人符合这一标准,表明他拥有健康的社会联系,他会比2/3的男人更长寿。

    3.对以下两个问题回答“是”

    “每天早晨,你期待着去工作吗?”

    “每天下午,你期待着回家吗?”

    经过长达30年的实践研究发现,持肯定答案的人死于心脏疾病的风险非常低。

    4.前列腺特异性抗原值低于2.5纳克/毫升

    前列腺癌专家指出,这个指标表明他患前列腺癌的危险性比较低。

    5.能在28分钟内步行3公里

    能否在相当长的一段时间里保持轻快、有力的步伐,是衡量身体健康的一个好方法。

    根据瑞典研究者的结论,一个健康的40岁男人,应该能在28分钟之内走完3公里,相当于正常步幅每分钟走134步。

    6.平衡的肌肉力量

    大多数男人热衷于让肌肉做过度的外推运动,例如俯卧撑,而真正具有平衡力量的男人则比较少。

    理想状况是他的肱二头肌和肱三头肌的力量比率应为1∶1,也就是说,如果他能够拉开25公斤的拉力器10次,也就应该能推开25公斤的推力器10次;他的股四头肌和腘绳肌的力量比率应是3∶2,也就是说,若他能够负重30公斤抬腿10次,就可以用腿压下20公斤重物恰好10次。

    7.比例匀称的头颅

    在临床上,面部宽度是长度的60%为最佳,具有这样标准的男人不但容貌俊美,而且对呼吸道、下颌及牙齿方面的疾病也有很好的免疫力。

    8.能快速爬坡

    让他在跑步机上行走,逐步增加跑步机的倾斜度,直到再也迈不动步子。大部分30~40岁的男人能够坚持9分钟,若能达到12分钟就很了不起了。如果能达到15分钟,那意味着极佳的心血管健康状况。如果心脏曾经有过问题,做这个试验前一定要征得医生的同意。

    9.将线穿入针孔,一次成功

    这意味着他有非常好的感知力和立体敏锐性。如果穿不上针或者打球时总接不到球,应该考虑看看眼科医生。另外,每年的眼科检查中也需要特别做一下青光眼的检验。

    10.左右完美对称

    拿软尺量一量他的手腕、耳朵以及鼻孔的周长。如果这些地方左右对称或相差在1毫米内,说明身体很匀称、很均衡,这样的男人跑得最快,做剧烈运动时的自我控制力也好。任民

    ]]>
    0