木匠的微型博客 Charlie Twitter

    follow me on Twitter

    Tuesday, February 05, 2008

    在维多利亚Oracle用户组学到的东西

    上周四下午, 第一次参加了Victoria Oracle Users Group
    组织的技术交流活动. 题目是 Database Gems: 9i, 10g, and 11g.

    VicOUG 请来了著名Oracle 技术网站的http://www.psoug.org/的作者: Dan Morgan,
    --
    最常用的是
    Morgan's Library http://www.psoug.org/library.html, 可以找到各种语法和函数用例.
    这个伙计自称因为人员好, 被评为Oracle Ace Director.

    言归正传, 以下是我学到的3点,

    1)
    ALTER SYSTEM SET PLSQL_WARNINGS='ENABLE:ALL';
    建议在所有的开发(Development)及测试(Test)环境设置.

    有啥好处呢? 编译PL/SQL的时候,给出有用的警告信息.
    a) 严重问题, 比如参数混淆 (这点我还没有理解, 需要一个示例)
    b) 性能问题, 一个INSERT语句,传递一个VARCHAR2值给一个NUMBER列
    c) 提示信息, 比如有一段代码 永远不会被执行

    详细说明, 请参考:
    Oracle® Database PL/SQL Language Reference
    11g Release 1 (11.1)
    - 第十一章: 11 Handling PL/SQL Errors
    -- Overview of PL/SQL Compile-Time Warnings

    2)
    wmsys.wm_concate

    你可以Sum() 数字列, 也可以 Sum() Varchar2 字符串列,
    我们叫作String Aggregate, 以后会有一长篇文章介绍.

    这里有一个示例, 自己在 SQL*Plus 或者SQL Developer里面跑一下吧,
    select DEFAULT_TABLESPACE,
    translate(wmsys.wm_concat(username),',','|')
    from dba_users
    group by DEFAULT_TABLESPACE;

    3)
    FBI index, virtual column index and SHRINK clause

    有个听众提个问题, 说在10.2以下版本, 有Function Based Index的表不能做空间回收-Shrink.
    Dan Morgan这位老大自己没测试过, 随口就说11g上,在一个表的虚拟列上的构建索引,这张表可以Shrink, 岂不是犯了和 老旦一样的错误.
    (老旦:Dan. 你们都知道是谁, 曾被老刘 Lewis 严肃的教育过, 以后有另外一篇文章评论,关于PGA 和 Parallel execution)

    第二天到办公室一测试, 发现11.1也不行.

    以下是测试用例:

    --drop table scott.y1;
    create table scott.y1(sal number, comm number);

    drop index scott.yi_fbi1;
    create index scott.yi_fbi1 on scott.y1(sal + comm)
    --tablespace data_auto
    ;

    alter table scott.y1 enable row movement;

    alter TABLE scott.y1 shrink space compact;
    alter TABLE scott.y1 shrink space;

    ERROR at line 1:
    ORA-10631: SHRINK clause should not be specified for this object

    drop index scott.yi_fbi1;

    alter table scott.y1 add (income AS (sal + comm));

    drop index scott.yi_vi1;
    create index scott.yi_vi1 on scott.y1(income);

    alter TABLE scott.y1 shrink space;

    ERROR at line 1:
    ORA-10631: SHRINK clause should not be specified for this object

    Sunday, February 03, 2008

    在加拿大给美国客户远程工作, 相关流程总结

    我自己亲身经历, 也有多位加拿大的华人朋友问到, 所以在这里总结一下.

    如果你是搞IT系统维护或开发的,这样的话VPN远程接入美国客户应该是通常的手段了.至于远程会议等要看对方要求了.一般公司都有WEBEX之类的.

    填一份 W-8BEN表格, 给美国客户寄去 备案, 就行了. 美国客户/雇主就可以开始给你付工钱了. (如果在美国工作, Independent Contractor 需要填w9 form)
    另外,对方有可能要求签一个安全保密协议, Non-Disclosure-Agreement.
    如果你觉得有必要, 再跟美国雇主签一个Offer(工作合同)

    美国公司如何支付工钱: 美国公司 "电子转帐或寄支票" 来 支付工钱

    纳税:
    1) 美国缴税 - 不用

    问过会计师了 无需向美国缴税
    刚刚打电话,问了会计师, 确认不用向美国缴税.
    下来就是明年报税, 找会计的问题了.

    加拿大居民/公民, 不用给美国缴税.
    If you perform the service from Canada, the income is not US source of income and is not taxable by US government.
    http://www.irs.gov/businesses/small/...=96459,00.html

    A nonresident alien (NRA) usually is subject to U.S. income tax only on U.S. source income.
    http://www.irs.gov/businesses/small/international/article/0,,id=96459,00.html

    Nonresident Aliensa
    A nonresident alien usually is subject to U.S. income tax only on U.S. source income.

    http://www.irs.gov/publications/p519/ch02.html#d0e1779

    <<
    如果你是美国公民, 绿卡持有人,

    根据w8 form 指南, 美国客户(Payor)会预先扣缴 30% 的税
    See: http://taxes.about.com/od/taxplanning/qt/form_W8BEN.htm
    >>

    2)加拿大缴税
    如果是 Independent Contractors, 交加拿大这边的30%~50%的个人所得税.

    注册公司:
    年收入在$30,000以下, 不需要在加拿大注册公司.
    (我个人觉得, 20万以下, 都不需要成立公司)
    注册个公司很容易,拿着公司注册号去开个银行帐号,然后就等对方电子转帐或寄支票了.
    http://www.smallbusinessbc.ca/bizResources-name.php
    http://www.bcbusinessregistry.ca/introduction/index.htm

    财务税务最好找个专业会计师.一年千把来块钱的开支,都可以打入公司运营成本, 还可以要回美国预扣的30%的税钱, 提交Form 8233.
    如果你恰好组织BC省府维多利亚市,我还可以给你介绍一个有这方面经验的华人专业会计师.

    也可以参考
    华枫论坛> ◆主题论坛◆> 创业者俱乐部.
    http://www.chinasmile.net/forums/showthread.php?t=303814

    下面是一些英文原文资料摘要:

    US Withholding for Canadian Independent Contractors

    Using Form W-8BEN to Claim US-Canada Tax Treaty Benefits
    American companies generally withhold income taxes on income being paid to foreign nationals. You may qualify for reduced withholding if meet some rules. Basically, there are three steps to this process. First, you must clarify in which country you are a resident. Second, you must decide where your "fixed place of business" is located. Third, you must notify your clients of your tax status using Form W-8BEN.
    Withholding
    The tax treaty specifically allows for US companies to withhold income taxes on self-employed Canadian residents (Article XVII, paragraph 1). Withholding will be 10% on the first $5,000 of income, and 30% on income over that threshold. The client and independent contractor may agree on a lesser percentage of withholding if these amounts are considered "excessive" (Article XVII, paragraph 2).
    Normally, US companies are required to "withhold 30% of any payment of an amount subject to withholding made to a payee that is a foreign person" (Instructions for Form W-8BEN). Form W-8BEN is used to inform the US company that you are "a beneficial owner that is a foreign person entitled to a reduced rate of withholding." You qualify for a reduced rate of withholding if you meet the residency and fixed place of business rules
    Filling out Form W-8BEN
    Provide your name in Line 1 and check "individual" in Line 3. However, if you are working under a business name, provide your business name in Line 1 and check the appropriate type of entity in Line 3.
    See: http://taxes.about.com/od/taxplanning/qt/form_W8BEN.htm

    Claiming Tax Treaty Benefits
    Exemption From Withholding
    If a tax treaty between the United States and your country provides an exemption from, or a reduced rate of, withholding for certain items of income, you should notify the payor of the income (the withholding agent) of your foreign status to claim the benefits of the treaty. Generally, you do this by filing Form W-8BEN, Certificate of Foreign Status of Beneficial Owner for United States Tax Withholding with the withholding agent.

    Rules that Apply to Compensation for Personal Services
    Independent contractors. If you perform personal services as an independent contractor (rather than an employee) and you can claim an exemption from withholding on that personal service income because of a tax treaty, submit Form 8233 to each withholding agent from whom amounts will be received.
    See: http://www.irs.gov/businesses/small/international/article/0,,id=96438,00.html


    Instructions for the Withholding Agent

    Requirement To Withhold
    A withholding agent must withhold 30% of any payment of an amount subject to withholding made to a payee that is a foreign person unless it can associate the payment with documentation (for example, Form W-8 or Form W-9) …
    Responsibilities of the Withholding Agent
    If you are a withholding agent making a payment of U.S. source interest, dividends, rents, royalties, commissions, nonemployee compensation, other fixed or determinable annual or periodical gains, profits, or income, and certain other amounts (including broker and barter exchange transactions, and certain payments made by fishing boat operators), you are generally required to obtain from the payee either a Form W-9, Request for Taxpayer Identification Number and Certification, or a Form W-8. These forms are also used to establish a person's status for purposes of domestic information reporting (for example, on a Form 1099) and backup withholding. If you receive a Form W-9, you must generally make an information return on a Form 1099. If you receive a Form W-8, you are exempt from reporting on Form 1099, but you may have to file Form 1042-S and withhold under the rules applicable to payments made to foreign persons. See the Instructions for Form 1042-S for more information.
    Generally, you must withhold 30% from the gross amount paid to a foreign person unless you can reliably associate the payment with a Form W-8. You can reliably associate a payment with a Form W-8 if you hold a valid form, you can reliably determine how much of the payment relates to the form, and you have no actual knowledge or reason to know that any of the information or certifications on the form are unreliable or incorrect.
    Do not send Forms W-8 to the IRS. Instead, keep the forms in your records for as long as they may be relevant to the determination of your tax liability under section 1461. Use the information on Forms W-8 to prepare Forms 1042-S.
    See: http://www.irs.gov/instructions/iw8/ch01.html

    Tuesday, January 22, 2008

    Supporting Multilingual Databases and NLS_CHARACTERSET

    We recommend going to AL32UTF8 as the ultimate solution for Oracle 11g-.
    AL32UTF8 is the database character set that supports the latest version (5.0 in Oracle 11.1) of
    the Unicode standard. It also provides support for the newly defined supplementary characters.

    Here are some major points I briefed as a reference.

    How to move to AL32UTF8 / UTF8 (Unicode) Database Character Set
    Note:119119.1

    to check you database Character Set,
    select value from NLS_DATABASE_PARAMETERS where parameter='NLS_CHARACTERSET';

    Usualy database will grow when going to AL32UTF8, use CSSCAN to generate the size expansion report.

    The NLS_LENGTH_SEMANTICS initialization parameter determines whether a new column of character datatype uses byte or character semantics. The default value of the parameter is BYTE. The BYTE and CHAR qualifiers shown in the VARCHAR2 definitions should be avoided when possible because they lead to mixed-semantics databases. Instead, set NLS_LENGTH_SEMANTICS in the initialization parameter file and define column datatypes to use the default semantics based on the value of NLS_LENGTH_SEMANTICS.

    columne_name VarChar2(300 char/byte)

    Related function: lengthb(), substrb()

    UniStr() over Chr()
    select Chr(163) from dual;
    select UniStr('\C2A3') from dual;

    convert(string_column,'AL32UTF8','US7ASCII'), convert from US7ASCII to AL32UTF8.

    To use WE8MSWIN1252 over WE8ISO8559P1, WE8MSWIN1252 supports European Code.

    Reference

    * US7ASCII: US 7-bit ASCII character set
    * WE8ISO8859P1: ISO 8859-1 West European 8-bit character set
    * WE8MSWIN1252: Microsoft Windows West European Code Page 1252
    * UTF8: Unicode 3.0 Universal character set CESU-8 encoding form
    * AL32UTF8: Unicode 5.0 Universal character set UTF-8 encoding form

    **Unicode character sets in the Oracle database, Note:260893.1

    exp/imp

    set NLS_LANG=
    export

    set NLS_LANG=
    import into the new UTF8 db.

    The conversion to UTF8 is done while inserting the data in the UTF8 database.

    Today's learning:

    如果你确信了那些消极的结论,那么你就极少可能去冒险和尝试新事物。消极的想法掩盖了你的感受,使其处于恐惧中。

    积极的想法的也是以同样的方式起到其作用。带着积极的心态,你将搜寻那些积极的选择然后确信其积极的结论。它帮助你克服恐惧并且尝试那些可能你认为“不能做到”的事情.

    积极的思想,有助于确定目标实现.

    Tuesday, January 08, 2008

    看看日本人是怎么抵制中国货的

    打击日货, 喊得有些累了, 这里转抄一篇, 华人同胞, 共同学习进步.

    --From 枫华园
    http://www.fhy.net

    最近很多国家在抵制中国货,特别是日本。日本抵制中国货不是象我们中国只是喊口号,而是肆意贬低中国货,特别是利用宣传工具。

    日本有2个电视台播放了2个关于中国货的节目。一个是试验生活中怎么不用中国货,当然是很可笑的了,可给消费者的影响可想而知。另外一个台,放了他们在中国的采访,说是广东的一个地方,说用来浇蔬菜的河水被污染了,河里的水--当然水很黑很臭的了。看了这样的镜头还有谁敢买中国的成品?还把河水和菜拿到日本来化验,虽然没查出什么。可还请什么专家来说话,说不能否定含有重金属。

    利用媒体,不是直接抵制中国货,这就是日本的手法。断章取义,再好的东西都可说成说垃圾的,我们中国人在抵制日货方面是不是也可以其人之道还其人之身呢?中国的媒体在干吗?我们不放日本作品?我们可以去揭揭日资企业的违法问题?可以说说销售到中国的倭货是在日本被淘汰的东西的?要找问题,为什么不利用现代的科技手段呢?

    建议大家不要光叫抵制日货的口号,真有爱国的思想的,多做一些具体的事情,真正的抵制日货。

    Tuesday, December 25, 2007

    过冬至 陕西老乡聚会 Potluck(家常便饭)

    2007冬至, 由苏州热心朋友Yang组织 (他老婆是陕西人), 我们来自陕西的老乡 聚会了, potluck, 又吃到了各种正宗陕西菜, 写日志以纪念.


    主人家在Cordova Bay, 面朝佐治亚/欢德福卡海峡,温哥华岛与大陆之间; 夜晚出来赏景, 月色映着海面, 别有一番韵味.

    陆陆续续有十多位老乡到场, 如果算上不认识的, 比如乘以十, 那么BC省府-维多利亚的陕西人就有一两百个了. 有一位搞房屋建筑的材料专家,竟然跟我同一栋楼上班,他4层,我5层(就是前文书提到的三面海景绿玻璃楼),天天进进出出碰面,还以为他是韩国人. 我要执行四川同事 老高 的建议,在电梯里面贴一个广告,邀请同楼的所有华人老乡,到街道对面吃(早年飘洋过海来的)福建人开的四川皇都自助餐.

    那天品尝到了久违的牛羊肉泡馍,肉夹馍,秦镇米皮,八宝饭,个个精彩,宛如回到了陕西老家.
    我消化系统不太好,当晚吃的很多,却也睡得比较香,算是吃的对路啦.

    去年2006冬至是到四川同事 老高 家里包饺子, 广东人讲了"冬至大过年".
    近期 Potluck(家常便饭) 活动频繁, 发生撞车, 特次向 开吻 表示歉意, 来年我们可以春节聚会.
    Potluck实际意思就是各做各的饭菜, 带到某个东主家一起大伙会餐.

    本想体验一下加拿大的Boxing day,准备26日一早去FutureShop店门口排队,
    商家又出新花样, 提前24日太平洋西海岸时间下午4:00开始网上抢购, 我抢到了一台500GB移动硬盘, 随后放弃了去现场排队的冲动.

    今日星相预测:
    Today is all about helping your friends and family.

    今日激励:
    积极的心态创造了一个富裕、热情以及解决方法的思想意识。而不是思考什么不能做,积极的思想者不会被束缚在“能”和“不能”里。一个积极思想者为解决问题是以新思路去自由思考,因为他们不会被限定在失败的恐惧中。

    下期题目: 乘坐救护车

    Saturday, November 17, 2007

    老爸的加拿大生活总结

    上周六(Nov 10)到温哥华送走了老爸老妈回中国,顺便买了一大堆干货,质量远远好于维多利亚的华人商店,下篇帖子再做介绍, 就叫温哥华中国货攻略.

    好了,言归正传, 以下是我老爸回国前发给国内亲人的邮件正文:

    -->
    最后一封信

    一切都准备好了,明天(中国是9日)离开维多利亚,到温哥华去。那里有国际机场,从那里离开加拿大回中国。你哥过去在电话里给我们说,这里好比是天堂,这是从生活环境说的。这里夏天不热,冬天不冷,空气清新,人们礼貌、热情、有序,除了语言不通,生活在这里,确实是好。地大人少(它一个人,中国就43个人),资源丰富,生活水平当然高了。回顾中国,以现在的速度建设,委实可观,但现实中也委实有很多问题。不管怎么说,我们是中国人,希望我们的祖国愈来愈强大!
    <--

    老爸跟咱有着一样的赤子爱国之心.

    Tuesday, October 30, 2007

    年末岁尾 升职加薪

    又到了公司财政年末尾, 开始了一年一度的Performance Review(个人业绩审核),
    老板会给你造出很长一串任务计划,指示你来年完成,好比爬山,没有个尽头,
    总是满足不了领导的期望值,领导就有借口反驳你的加薪要求; 但是还得坚持"斗争".

    还没有开始评审,上周四下午,老板发来一封邮件,说的11月1日起,给本人升职加薪,不亦乐乎,
    我就喜欢简单.

    具体是个啥职位呢, Data Solutions/Systems Architect,
    (刚进公司时,CIO给了俺一个 Data Solution Architect 干)
    只比我原来的职称多了一个单词 - System, 搞不清楚其中有何区别,
    号称是提升了职位, 糊涂, 难得糊涂.

    然后老板发出公告,宣布我们部门有4个人获得升职, 这不是卖乖吗?!!
    工资比我原来要求的少加了三千,结果闹腾的全公司同事都知道了,一个一个跑来祝贺,
    有人是真心的,有人是妒忌的,在所难免,引起人民群众内部矛盾,唉,老板真是老谋深算,
    给你加了薪水,也不让你舒服.
    我倒是喜欢悄悄给咱加了工资,咱以后继续卖力工作.
    想要维护好上上下下的群众关系,真是不容易.

    下面看看 System Architect 的定义, 还有我喜欢的职位 - Database Designer

    System Architect Definition
    The system architect has the task of putting together the skeleton of a software project.

    Depending on the specifications gathered by the requirements analyst, the system architect will choose to focus on ease of maintenance, application performance, compatibility with existing systems, or a combination of all three. Each decision that the system architect makes has to be carefully considered because a wrong move the beginning of a project can have damaging effects later in the software evelopment life cycle.

    Database Designer Definition
    Most software projects boil down to information storage and retrieval. Deciding how and where this information is stored is the domain of the database designer. Working with a system architect and a requirements analyst, the database designer ensures that all necessary data has a place to be stored. At the same time, the speed at which the data can be stored and retrieved are taken in to account so that user's are not left waiting for unreasonable amounts of time.

    Sometimes database designers take on database related activities such as arranging for backups, creating ad-hoc reports, and server tuning. However, these other tasks are often part of a Database Administrator's (DBA) job.

    Tuesday, October 09, 2007

    公司2008 Technical Vision 和 前eBay CTO

    今天公司请来了前eBay CTO, Marty, 来评论我们的2008技术架构展望.
    他是两年前离开eBay的, 现在开了个Consulting皮包公司.
    eBay去美国出差的朋友可能认识他.

    谈到了数据库的分割(split),
    从三个维度:
    1) 功能
    2) 读/写
    3) 大表本身, 比如根据键值 (something like partition key)
    这样一来, Oracle Sales 又要高兴了, 可以卖出更多的许可证.
    现在我们已经购买了16个, 包括 RAC, Partition, Diagnostic Pack options.

    还谈到了 Messaging Queue, Enterprise Service Bus,
    Coherence ( like TimesTen, 网格内存数据库, 刚刚被Oracle并购, 比TimesTen有更好的分布扩充性)

    o SOA
    o Recent database issues with connection pool usage and Oracle 10g bugs
    o Data Replication/Data Warehousing/Data Archiving within Oracle
    -- 竟然又开始推销 Quest SharePlex
    -- 而我强烈坚持升级Oracle 11g, 启用Active Standby database.
    o Site Separation model
    - App server(s)
    - Oracle Partitioning


    IT Architecture[Operation Driven]
    o Best Practices in implementing Operations into Product Development process flow
    o Config Management[Build, Packaging, Deployment, Promotion Model]

    Sunday, October 07, 2007

    怀念张纯如 -- 南京大屠杀电影 十一月将在温哥华公映

    纪念已故美籍华裔作家张纯如, 和她的10年前《南京大屠杀》一书,揭露亚洲浩劫史实真相.
    希望华人同袍找机会前往观看, 回顾历史, 展望未来.

    前两天看了一部由美国独立电影人制作的纪录片《南京梦魇——南京大屠杀
    http://www.youtube.com/watch?v=YoW2WYdOsvg

    知道了 张纯如 这位有为青年, 除了敬佩, 还是敬佩.
    我只是想让她知道, 打击日货, 消灭日货的力量正在逐日壮大, 直到日本消亡.

    眼下正在发展华人群众捐款,
    http://rapeofnanking.info/Donate.html

    就算有人不捐款,起码请您youtube点击一下,

    ***********************************************
    Youtube:
    part 1 http://www.youtube.com/watch?v=YoW2WYdOsvg (English)
    part 2 http://www.youtube.com/watch?v=iqH47MIpuoA

    part 1 http://youtube.com/watch?v=TgENINXPrAM (Chinese)
    part 2 http://www.youtube.com/watch?v=mwdzxTMFUl4
    网站:www.RapeofNanking.info
    捐款:http://rapeofnanking.info/Donate.html
    ***********************************************

    醒醒吧, 我的中国同胞. 此事紧紧关乎你我的人生,健康,灵魂.
    当日本人来屠杀你的时候,一切就都太晚了.
    还犹豫什么, 勿忘国耻, 打击日货, 中国需要你,世界需要你, 做有正义感, 有骨气的中国人!

    --资料1

    张纯如, 她出生于美国,曾在美联社和《芝加哥论坛报》当记者。1997年,她的《南京大屠杀:被二战遗忘的浩劫》在美国出版,这是首部全面记录当年日军血洗南京城暴行的英文著作,曾连续5个月被列为《纽约时报》书评的最佳畅销书。2004年11月9日,年仅36岁的她突然在自己的轿车内用手枪自杀身亡。有推测认为,她自杀的原因很可能与撰写太多南京大屠杀血腥场面患上了抑郁症有关。

    --资料2

    1937年12月13日,日本侵略军侵占南京后,在日本华中方面军司令官松井石根和第6师师长谷寿夫指挥下,在南京全城进行了40多天的血腥屠杀,使用集体枪杀、活埋、刀劈、火烧等惨绝人寰的方法,杀害中国平民和被俘军人达30万人。

    以下为转载:
    http://www.chinadian.ca/viewthread.php?tid=27819&extra=page%3D1

    据星岛日报消息,為纪念10年前以《南京大屠杀》一书,揭露亚洲浩劫史实真相的已故美籍华裔作家张纯如,一部纪录她在发掘歷史真相时心路歷程的电影《张纯如:南京大屠杀》(Iris Chang-The Rape of Nanking),將於11月在温哥华公映。

    温哥华抗日战爭史实维护会会长列国远周二表示,今年除了是《南京大屠杀》一书出版10周年,也是南京大屠杀70周年,為纪念这位勇於追求歷史真相的女斗士,本地电影界出资拍摄电影,由皮克(Anne Pick)和斯帕克(Bill Spahic)任导演,华裔演员郑啟蕙演出张纯如一角。

    列国远提到,由於郑啟蕙喜欢《南京大屠杀》这本书,当她知道张纯如早在她读到《南京大屠杀》一书之前就已自杀身亡时,郑啟蕙感到万分遗憾。后来当《张纯如:南京大屠杀》电影在寻求张纯如一角时,郑啟蕙即主动联络製片,希望能扮演张纯如。

    列国远说,郑啟蕙不仅长相酷似张纯如,而且与她神交多年,演出时入木三分,甚至还為主题曲撰词抒怀。

    《张纯如:南京大屠杀》將在11月15日、17日、22日与25日共放映5场,票价15元。史维会邀得张纯如父母与女主角郑啟蕙出席与观眾会面,分享参与本片的感受。

    全部收益,將用来资助加国老师赴中国学习二战浩劫史实及史维会其他工作。详情查询及购票,请致电+1-604-313-6000

    Monday, September 17, 2007

    勿忘国耻, 打击日货, 纪念九一八

    经由Oracle国贸旧同事推荐, 最近开始研究<<推背图>>, 愈看, 心情愈舒畅.

    先是预言,马英九将会是台湾最后一个总统.
    中国统一以后,日本挑衅,导致其战败, 并从此以后, 一蹶不振, 快哉!

    各位同胞,赶紧觉悟,从我们开始,从今天开始打击日货,做有骨气,有正义感的中国人.

    看看ChinaRen 校友录里的链接, 有骨气之爱国人士, 后继有人.
    “九·一八”国耻日 万人签名纪念


    这里是 推背图 的链接:
    http://fengwen1103.blogdriver.com/fengwen1103/1107632.html


    第四十五象 戊申 (第二次中日战争)

    图:两个面向西的武士用长矛指着太阳冲来

    谶曰:

    有客西来 至东而止
    木火金水 洗此大耻

    颂曰:

    炎运宏开世界同
    金乌隐匿白洋中
    从此不敢称雄长
    兵气全销运已终

    金圣叹:「此象于太平之世复见兵戎,当在海洋之上,自此之後,更臻盛世矣。」

    解:我猜肯定是美国瞧我们站了它的世界领袖之位,心生嫉妒,挑唆日本争夺钓鱼岛,(也有可能是因为台湾问题,也许第43象同第40象一样,时间跨度很长)引发战争,美日同盟两个打我们一个,但我们最终取得胜利,我们取代美国成为日本的宗主国。(想起我们现在提的和平崛起的理论,简直好笑,我们必须做好军事斗争的准备。)

    “有客西来至东而止”,依推背图以前提到的客是指敌人来看,这里的客也是敌人,且是从西往东来。我猜想肯定是美国。我们看图,有两个武士面向西来,(注意是面向西,不是向东)有人说,是中国和某国结盟共同攻击日本,我看未必,没看到这两个人是向西的,一定是美日同盟,指着太阳,是说明他们是为日本而战。这个猜想更为符合实际,因为美日有同盟条约,我们和谁结盟,俄罗斯吗,它会为我们与日美而战,太天真了。所以我们必须做好打一场恶仗的准备。“木火金水”,五行缺土,一定是为了领土之争,最可能的是钓鱼岛了。(有人认为,“木火金水”指的是韩国的国旗,我们同韩国结盟打日本,我觉得几乎不可能,别忘了他们都是美国的非北约盟国,美国驻军占领呢,怎敢和我们结盟,分析推背图要注意结合客观的国际局势和现实发展趋势去研究解读。)“洗此大耻”,联想7勇士日前登岛被捕,真大耻也,别着急,我们早晚要洗的。“炎运宏开世界同”,有可能发展成世界大战,“金乌隐匿白洋中”,金乌,古时对太阳的称呼,如果日本膏药旗,没了太阳,自然成了白旗,说明日本投向了。“从此不敢称雄长,兵气全销运已终”,日本再也不敢有野心了,没了军队(估计连自卫队也没有了),国运从此衰落。(变成中国的附属国?)

    Tuesday, September 11, 2007

    登陆加拿大两年记

    坐在落地玻璃墙的办公室里, 温和的阳光透过窗纱照到脸上, 看着海面跑来跑去的轮船, 有客轮,
    大邮轮--从加勒比海到阿拉斯加,经过维多利亚停靠, 还有 集装箱货轮, 时不时有水上飞机跃出水面,迎空而起.

    回想起来这两年的生活, 赶上了加拿大的医疗制度,
    我自己看过两次医生,一次是2005年冬天 踢足球撞断了脚腕, 在家工作,休息了一个月,
    一次是上周被黄蜂(wasp)蜇了,吃了一周抗感染药,好了.
    加上看牙医,那就更多了, 6颗门牙花了$7000, 自己只用付$1500,也不用回中国看了.

    吃住早就习惯了, 今年夏天, 开始买房子, 根据现在的家庭状况, 可以选择中等的独立屋了,
    上天预计我们可以2008年二月拿下, 下一篇帖子再做分解.

    说说游玩, 每年出去露营3周, 尽情游览国家/省立/市立公园, 享受着加拿大第三大福利. (老人,小孩福利,暂时靠不上)

    其实我是2005年6月30日,从波士顿,沿着美国东北部90号高速公路,到著名的水牛城,
    然后北上,在尼加拉瓜瀑布附近,穿过美加边境,踏上了加拿大的土地.

    我目标还是比较明确的,父母过来探亲半年, 看看真实的西洋镜.
    望着年迈的父母,想想最初的抉择,我们1998年开始准备移民的时候要的不就是这些吗.

    设想着回到自己的老家,那个人说历史开始的地方,古老的城墙,妖娆的方言,凉皮,泡馍,酸汤水饺,肉夹馍,拉面,都是我心底一直的牵挂。

    十几岁的时候背井离乡,何日是再回去的一天呢?加拿大是个非常好的国家,可它和我们的回去和留下又有多大的关系呢?中国有无数无法解决的难题,可它是我们自己的地方呀!我曾以为也就这样了,在加拿大的蓝天碧水中快乐地老去,不经意的设想回去却勾起这么许多的情绪来。很多的东西哪有那么多道理可讲呢?

    回去留下真的就是每个人和每个家庭自己的选择,我不知道那些高深的东西,这里藏龙卧虎的大师太多,可是只要你情愿, 只要你舒服, 只要你愿意选择自己的道路, be passionate and persistent, 哪里的生活都适合你.

    明天又是每周三Soccer day, 继续和维多利亚各种高科技公司的足球爱好者较量,包括开发FireFox 的外包公司, 坚持锻炼身体, 健康是革命的本钱.

    Monday, September 10, 2007

    Good practice: Middle-tier DAL or Database API – Database access guideline

    The reason I don't use "Best Practice" is that will prevent rest of people create some better new ideas, and let you out the 'Keep an open mind' zone.

    So I turned to Good practice:

    Middle-tier DAL or Database API – Database access guideline
    (Hibernate vs Store procedure)

    • Maximise SQL and minimise PL/SQL
    • Minimise client code and maximise database server code.

    Generally servers are more powerful and built for this type of work. You also want to minimise trips back and forth to the server.

    Reference:

    Business Logic - PL/SQL Vs Java
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:883929178230

    I prefer to put all logic that deals with data in PLSQL. There is no more natural language to interact with SQL data then PLSQL. None.

    For example -- native compilation was added -- turned plsql into object code that runs natively on the OS.

    Database API, build the data API in the database, you call the data API
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:25405782527721

    When to use Hibernate DAL
    • One step SQL (SELECT OR UPDATE) to finish your goal
    • Heavy and forced interaction in mid tier, like CCBB encryption, that means high coulping too, and hard to encapsulate the process logic.

    Jave developer can help us on this list.

    When to use Database API and Store Procedure Package
    • Complex SQL
    For example, book delete check, reference Single Hash Table and list of IDs.
    • Many (more than 2) steps data machinations logic in a sigle module
    • Reture rows more than one page, let's say 20 rows from database.

    We like Database API approach, because it:
    1.. make software components modular, I'm totally into modular programming
    2.. software modules must carry out a very specific task (and be very efficient at carrying it out)
    3.. each software module should be loosly coupled (to limit dependencies)
    4.. It removes the need for triggers as all inserts, updates and deletes are wrapped in APIs. Instead of writing triggers you simply add the code into the API. I loath triggers.
    5.. It prevents people who don't understand SQL writing stupid queries.
    All SQL would be written by PL/SQL developers or DBAs, reducing the likelyhood of dodgy queries.
    6.. The underlying structure of the database is hidden from the users, so I can make structural changes without client applications being changed.The API implementation can be altered and tuned without affecting the client application.
    7.. The same APIs are available to all applications that access the database. No duplication of effort.

    Anything that generates SQL on-the-fly worries me, not just Java. I want to be able to cut and paste the SQL, not try and capture or trace it during a run.

    Our concept is "build the data API in the database, you call the data API" .
    Database API has been layered by different UI technologies over time.

    All about API's. The applications don't do table level(select/insert/update/delete) stuff, the apps don't even really know about tables.

    On top of database schema we have an API that does the data stuff.

    In the application we call this API but have our own application logic as well
    (only application logic is in the application, data logic is – well, right where it belongs – next to the data, waiting for the 'next great programming paradigm to come along')

    The fact that our UI is in Java isn't really relevant. You could pretty much see how you would use this package from C#, Java/JSP, Swing, VB, Pro*C, Forms, Powerbuilder, a mobile phone, .


    Storing application code in the database has had it's champions and detractors.

    When you start putting application code in the database, you are in the thoroughly non-portable arena. That code, were you to port your application to another database, would have to be rewritten. But think about your application mid-tier layer, will you port Java code to C#/.Net,-> Pascal -> C -> VB, then to Python, Ruby on Rail ...etc., will you do that?

    Its very specificity to that database means it can also take advantage of, and wire close to that engine. There are situations where stored code in the database can be notably faster. Supposed you have to update some chunk of a million rows after doing some machinations on the data.

    In a stored procedure the data is read, manipulated, and updated in one step. Meanwhile if you did the same in your middle tier application code, you would have to send that data set over the network, do your manipulations, and send it back. Not only would it make this one task slower, but other transactions vying for that same data could potentially have to wait while that data is in transit, and being manipulated. Also, stored code can serve to encapsulate specific requests which can be invaluable at simplifying your overall application. All three databases support stored procedures and functions. Oracle also supports packages, or collections of stored procedures as well as various object oriented features, which almost no one ever uses. An additional note, a database engine actually context switches between stored code, and the SQL code embedded therein. As since of 9i, Oracle introduced bulk binding, so you can do work on large sets of rows, and update them all in one go, instead of each loop iteration. This feature can even further improve performance quite dramatically.

    Document the SQL access database

    We'll build a small application for this target, on Oracle APEX (HTML DB).
    then QA (and Developer) need to record all the SQL access db in the new developing applications.
    * SQL execution path
    * SQL performance statistics

    Sunday, September 09, 2007

    Oracle DBA 职业成长计划 本月Victoria IT club讨论主题

    Oracle DBA 职业成长计划 -- 本月IT club讨论主题,
    主要针对 加拿大BC省 维多利亚 IT同行.

    以下是内容简介:

    Grow That DBA Career
    Square one - How to be an expert.
    Salary center:
    A typical Database Administrator working in British Columbia -- Victoria earns a median total cash compensation of $96,509, according to our analysis of data reported by corporate HR departments. Half of the people in this job earn between $82,461 and $105,361, from http://salary.monster.ca/
    --
    Should I Become A DBA?
    How do I get my first DBA job?
    You’ve landed your first job!
    Junior DBA Roadmap
    Junior to Intermediate DBA
    Intermediate to Senior DBA
    --
    Attitude and skill set for future
    Approach to design database application
    Reactive Tuning
    Q & A

    欢迎各位IT老大(大佬)前来, 有钱的捧个前场, 没钱的捧个人场.

    Time: 3:00-5:00pm 15-Sep-2007
    Location:
    2nd Flr meeting room
    Emmanuel Baptist Church (Victoria Evangelical Chinese Bible Church)
    2121 Cedar Hill Cross Rd.
    就在UVic维多利亚大学南门, 穿过马路西南角.

    Wednesday, August 15, 2007

    Compiz Fusion 强劲灵巧的 Linux 用户界面

    今天在 lifehacker 看到的, 最新发布了.52, 第一个稳定版本将会是.60, 很快就会与大家见面的.
    http://lifehacker.com/

    这里有它的动画演示,
    http://www.youtube.com/watch?v=_ImW0-MgR8I&NR=1, 还有这个动画.

    支持Cube, Rotate Cube, Group Windows and Tabbing, Dodge, Focus, Free Zoom, AddHelper(Dark rest windows) 功能太多了, 而且都非常实用.

    等.60版本出来以后装一个试试, 或许真要投靠Linux办公桌面了.

    Thursday, August 09, 2007

    Learn something new every day 天天进步

    读了Tom的In search of the truth

    总结了两点学习和应用实践Oracle的座右铭:

    1)Keep an open mind, learn thing(s) new everyday
    2)Ask for proof from everyone

    今天我学到了一个新的 SQL Hint, LEADING Hint change in 10g,
    知道了RAC的cache传输和节点多少没有线性比例关系.

    大的方面,开始学习Oracle OLAP & Analytic Workspace Manager, 知道了如何规划和预先分配OLAP cube空间尺寸大小.
    参见: Mark Rittman 的 Oracle Database 10g OLAP Performance Tips & Techniques


    题外话, 最后看看我老家所在的省城: 西安, 聊以自嘲.

    "  如同一个大县城,又向一个饱经沧桑的老人,中国第10大城市的经济总量刚刚1000亿,这就是西安,一个不求上进而颓废的城市,市民打扮如同黄土高原的放牧者"

    Saturday, July 14, 2007

    "continue": PL/SQL 在 Oracle 11g 里面的功能完善

    Oracle 终于支持 CONTINUE 了, 像我一样 做 Development DBA 的人用得着了.
    原来老得翻翻文档, 找出 Label 和 GoTo的语法, 特别烦人.

    这个东西实在算不上一个新特性, 只能叫作功能完善而已.

    使用"CONTINUE" 的 PL/SQL程序样本, 请参考:
    http://technology.amis.nl/blog/?p=2261

    Sunday, July 08, 2007

    一个安全的"亲吻", 加拿大遭遇轻度汽车追尾

    一大早带上抓螃蟹的笼子,沙滩椅,餐具,
    准备前往 Pothole 省立公园 会合 "开吻"一家五口, 一起野餐, 游泳, 钓螃蟹.
    刚到小区出门的十字路口, 后面一辆小Van风驰跟上,紧紧贴在后面停了下来, 感觉要被撞上了,
    此时忽略了一个要过路口的行人,
    (在加拿大, 行人优先级最高. 帮助解释上下文)
    此中年妇女愤愤的瞪了我一眼, 绕道车后面穿过,
    恰逢我左转, 她又要继续横过十字路口另一边的人行道,
    总不能再抢道了, 我赶紧停在了十字路口当中,
    中年妇女转身给了我一个会心的微笑, 稍微弥补了刚才的过失,
    还没有得意一秒钟, 就觉得全身一震, 沉稳有力 幅度小,
    哈哈, 被后面的老兄追尾了, 还好, 刚刚启动, 速度慢.

    OK, 后面才是关键部分.
    此中年妇女马上走过来, 主动要求做目击证人, 并留下了姓名,电话,住址.
    后面车主紧跟着过来,写下了自己的姓名,电话,住址,车牌和驾照号码,
    和我们车的信息, 并且抄给我们一份, 根据他们两个的经验,协商了解决办法.
    交谈中才得知, 后面车主从Campbell River赶到 维多利亚 来看望治疗癌症的老婆,
    所以行动急躁了点儿.

    我们啥也不用干, 问题就解决了, 轻松愉快.
    对于初次遇到car accident的我们 (这里讲车祸,有点过分了), 帮了大忙.

    作现场目击证人, 这是加拿大一个人人愿意主动承担的公民义务,
    生活在一个普遍讲求诚信的国家, 真好. 我就喜欢过简单宁静的生活.

    来到维多利亚,考取驾照有一年了,仍然觉得技术没有多大提高,胆子却越来越小了.
    我也通过这次事件,又学习了一课:
    随时留心前方路两边的行人,每隔3秒左右扭头一个循环,
    (祖籍英国教练 Alan 常常咆哮教训: moving your head)
    撞了前面的行人可比汽车之间磕磕蹭蹭问题严重多了,
    况且在加拿大, 汽车追尾多数情况下是后面车的责任. ;)
    -- 左转并道 和 倒车 除外.

    转眼想到了 NinGoo@Net 写的 "暂住证?居住证?身份证?"
    在我们中国, 啥时候 <<身份证>> 才能变成真正的ID, 记录每一个人的信用记录.

    Wednesday, May 09, 2007

    回忆陕西方言

    想家, 自然想起了家乡的方言.
    我长大的家乡 商洛地区 (商州) 属于陕南山区,八山一水一份田,与关中平原的方言略有不同.

    看了 GTD Life 整理的陕西方言,
    在这里检出一些我耳熟能详的句子短语, 与生活在 维多利亚 BC Canada的陕西老乡分享:

    11.喋―→吃饭、打人
    24.嘹杂列―→很好,很美
    xx.辽地太-->棒极了
    xx.搁揪-->蹲下
    xx.瓜娃-->憨厚老实,傻孩子
    **.污瞍-->阿齰, 脏乱,恶心
    1.制达―→这里
    2.雾达―→那里
    3.啊达―→哪里
    5.野个―→昨天
    12.试火―→试一试
    14.谝―→聊天,说话
    15.扎势―→摆架子,打肿脸充胖子
    16.花搅―→开玩笑、恶作剧、取笑
    17.蚕活―→厉害,有本事,办事效率高, (好,舒服 -- 意思太多了)
    18.骚青―→热情过分,讨好献媚之嫌
    19.木乱―→不舒服、不适,思绪烦乱
    20.罢咧―→一般,还行、过得去
    22.幕囊―→行动迟缓、浪费时间的行为
    27.麻达―→麻烦、问题
    xx.麽麻哒 --> 没有问题,一定办理
    28.麻米儿―→不讲理、不明事理
    29.瓷马二楞―→不机灵,迟钝
    30.克里马擦―→快点
    31.逼咧―→完蛋了,指事态无可挽回
    32.裂远―→一边歇着去

    一转眼已经离开中国2年了,新移民的时间过得真快.
    希望明年拿到公民身份,然后南下美国打工,顺便找机会回老家玩一个月.

    Tuesday, April 24, 2007

    高效字符串替换

    今天看到AnySQL提到了关于字符串的灵活替换一文.

    1)
    SELECT
    REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
    REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TABLE_NAME,'0','#'),
    '1','#') ,'2','#') ,'3','#') ,'4','#')
    ,'5','#') ,'6','#') ,'7','#') ,'8','#') ,'9','#') PATTERN_NAME
    FROM USER_TABLES;
    2)
    地铁上,AnySQL又想到了改进的方法,

    SELECT
    TRANSLATE(TABLE_NAME,'0123456789','##########') PATTERN_NAME
    FROM USER_TABLES;

    3)
    还有更简洁的, 运用正则表达式 替换 或者 查找:

    select REGEXP_REPLACE(TABLE_NAME, '[1-9]', '#' )
    from cat;

    在大数据量情况下(比如超过1百万行数据),需要注意一个问题: 就是函数REGEXP_InStr()
    和PGA内存的使用.

    update abedba.addresses
    set
    NAME = REGEXP_REPLACE(NAME, '['||CHR(13)||CHR(10)||']', ' ' )
    where
    REGEXP_InStr(NAME, '['||CHR(13)||CHR(10)||']' ) > 0;

    ERROR at line 1:
    ORA-04030: out of process memory when trying to allocate 4000 bytes (kxs heap,kghalp : evarxalc)

    work around 就是使用传统的InStr()函数:

    update abedba.addresses
    set &1 = REGEXP_REPLACE(&1, '['||CHR(13)||CHR(10)||']', ' ' )
    where INSTR(&1, CHR(10)) > 0 or INSTR(&1, CHR(13)) > 0;

    --最后一点,就是经验问题,
    如果你有多个列做相同的修改, 最好用SQL*Plus变量替换column_name,存成脚本, 成批运行,
    这样,就不用担心改错了数据, 比如把ADDRESS改成CITY.

    错误样本:
    update abedba.addresses
    set
    ADDRESS= REGEXP_REPLACE(CITY, '['||CHR(13)||CHR(10)||']', ' ' )
    where
    REGEXP_InStr(CITY, '['||CHR(13)||CHR(10)||']' ) > 0;

    正确脚本:
    -- C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql
    -- http://mantis/jira/browse/OPS-2043

    update abedba.addresses
    set
    &1 = REGEXP_REPLACE(&1, '['||CHR(13)||CHR(10)||']', ' ' )
    where
    INSTR(&1, CHR(10)) > 0 or INSTR(&1, CHR(13)) > 0;

    /*
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql NAME
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql ADDRESS
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql ADDRESS2
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql CITY
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql PROVSTATE
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql COUNTRY
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql ZIPCODE
    @C:\Charlie\DEV\scripts\deploy\2007apr10\addr_u.sql PHONE
    */

    这是我的第一个技术帖, AnySQL不要说我盗版吆.

    改进型:

    SELECT * FROM(
    SELECT TABLE_NAME, count(*) over (PARTITION BY REGEXP_REPLACE(TABLE_NAME, '[0-9]+', '#' ) ) AS tab_cnt
    , REGEXP_REPLACE(TABLE_NAME, '[0-9]+', '#' ) tran_tab
    FROM USER_TABLES
    ) WHERE tab_cnt > 1

    运行结果:
    TABLE_NAME TAB_CNT TRAN_TAB
    -- -- ---
    LOGMNR_HEADER2$ 2 LOGMNR_HEADER#$
    LOGMNR_HEADER1$ 2 LOGMNR_HEADER#$
    PARTS2 2 PARTS#
    PARTS1 2 PARTS#
    T101 4 T#
    T2 4 T#
    T1 4 T#
    T3 4 T#

    优点:
    1) 两位数,3位数,n位数 都可以.
    REGEXP_REPLACE(TABLE_NAME, '[1-9]', '#' )
    更改成,
    REGEXP_REPLACE(TABLE_NAME, '[1-9]+', '#' )
    替换1到任意多个数字.

    2) Count(*) over (PARTITION BY)
    更容易理解, RATIO_TO_REPORT 分析函数有点用过了.

    我最近正在学习 SQL Analytic Functions, 感谢 rollingpig 给出RATIO_TO_REPORT的这个用法.

    Wednesday, April 11, 2007

    再谈在加拿大就医 - 看急诊

    昨天下午,改了夏时制以后,吃完晚饭,7:30pm,天光依然大亮,随即出门散步.
    街道依然有小猫徜徉,老婆依旧伏身逗玩猫咪,依旧不听我的忠言警告;
    (黑龙江老乡George的乖女儿被猫儿抓破脸的一幕依然印象深刻)
    事情发展的那么快,小猫翻身打滚的一瞬间,老婆的手上被划出一道3厘米长的
    血口子.

    幸好我们住的离Jubilee医院近,10分钟走到,
    进了急诊室,有向导,诊断,开始看似一切顺利,
    心里暗暗祷告,那些网上华人老乡流传的故事该不会发生在我们身上...

    初诊以后就在大厅等候医生治疗,
    等了两个小时,只有两个排在我们前面的人被叫进去,
    这才发现好多人是有备而来,有看小说的,有玩电脑的...
    一直等到午夜12点,才轮到我老婆,3分钟内打针吃药,看的到挺快.

    顺便看一下今天的星相,还是积极乐观的,吻合了我的心愿.
    You are an inventor, ready to change routines and improve the ordinary with slight but brilliant tweaks and modifications. That optimistic, hopeful spirit encourages and amazes those around you.