《思学篇》

序: 今吾留学已逾二载,尚且彷徨。观乎同辈,或有身兼中西之学,文理书乐皆通,踌躇满志者,窃以为不如。 吾温顺静思,非浪荡轻浮之人,奈何拘于家学见闻。究其根本,盖教育环境之异。

吾祖世代或农或商,非书香门第,几无藏书,唯《本草》《毛选》,皇历账本数册而已,想儿时亦无此趣。闲暇务农而少游冶,亦无良师益友导引。既入大学,尚忧衣食。而后随波逐流,年华暗换,而立之年近,尚且浑噩。

余常叹:幼不得读书以茂才,少不能观史以宏志,壮不及交游以广识。幸入大学门径,博览群书,略晓古今之贤达,初窥大道;偶得游历机缘,登堂入室,声闻中外之智士,眼界始开。

“穷则思,思则变”,听闻“苏老泉,二十七,始发愤”,吾以为桑隅非晚,故思学。身已后人,当奋发图前,奈何心力见衰,难以专志。唯恐心有余而力不足,观荀子之《劝学篇》,做《思学篇》以自勉。

—-

方今之世,风云变幻。万马奔腾,先者领之;鱼跃龙门,能者居上。

人皆有天赋,需发而养之。欲增其才,识不可以不广;欲显其能,学不可以不精。雄韬武略,非生而有之;高瞻远瞩,需广学精思。古今中外不乏先例。魏吴起身先士卒,吸疮负粮,众人争死。拿破仑博闻强识,因势利导,举国拥戴。丘吉尔文武双修,弘毅独行,力挽狂澜。

或曰纵子勤勉,无家学家世可承,抑将有成乎?吾以为不尽然也!

谋 国之举,一代难成;佐国之臣,出于当世;鸿儒巨硕,自励自成。王莽篡国,三代之力;三国鼎立,各有家承。然煮酒论英雄之时,袁绍承四世三公之势,虎踞冀州 之地,曹操不以英雄论之,何也?善始不必善成,非有能者不能成其大。乱世出英豪,时势造英雄。刘邦布衣起家,而夺项王之天下。朱元璋由卑至尊,今谓之草根 皇帝。北宋一代,治世能臣多出寒门。自古大儒多出寒门。穷则益坚,安贫知命,不为逢迎攀比而劳身,虚名福利损命。

家世显赫,乃生之幸,非众人之福;良师益友,世人皆可寻而得之。 盖今世之教育,童蒙重在家教,小学贵在师严,中学益在志高,大学旨在求索。 所闻所见所识所能,皆可后天补养,所需者,时也!

而立之年吾志方立,其晚乎?尽人事而听天命。 诚能守一毅行,去躁守静,当有所成。


西元二零零年年末
英国曼彻斯特

Posted in 时评随笔 | Leave a comment

从阿里上市反观金融改革【转载】

最近中国公司阿里巴巴成功登陆了纽交所,不少人觉得这是一 件很光荣的事,毕竟阿里创造了美国历史上最大一笔IPO纪录,对一个中国企业实属不易。同时,我也认为这对中国金融体系以及中国广大投资者,这是一个悲 哀。中国是世界上储蓄率最高的国家之一,老百姓现在也急需很好的投资产品,遗憾的是大多数中国投资者都没有办法买到阿里巴巴的股票,阿里巴巴还要不远万里 到美国跨过制度、法律、语言的各种障碍寻求上市。

从中国金融体系角度来看,这种情况为什么会发生?你可以说是美国金融体系或者美国金融市场 具有很大的吸引力,他们拥有非常有效的制度和规则,而中国在这一点上望尘莫及。美国金融市场有两个特点,其一是其筛选功能,将一些非常优秀的创业型企业从 众多的企业里挑选出来交给投资者,筛选的能力很强;其二是市场监督的机制,不仅可以把企业甄选出来,而且还可以让企业选择适合它们需求的治理和管理体系, 这既能够满足企业治理模式和融资需求,同时又能够保护好投资者。

众所周知,阿里巴巴起先想在香港上市,但香港联交所并没有同意,因为阿里有 一套治理结构,比如说合伙人要主导董事会成员的提名权,这个其实在美国市场也存在一定风险,但是美国市场接受了阿里巴巴,因为美国相信在公司治理上它还是 有其他的方法来保护投资者,例如它的法律制度的一些安排是能够更好地保护到它的投资者。相较于中国大陆甚至香港的金融市场,美国金融体系具备很大优势。这 一问题就牵涉到中国金融体系改革的战略抉择问题,中国不光是阿里巴巴一家在境外上市,类似优质的企业现在已经有几家了,比如腾讯、京东等等,中国的老百姓 不能够享有这些优秀企业成长中的投资机会。

在经济“新常态”下,今后五到十年中国整个经济转型的过程中,会涌现出一批有中国特色的、引领世 界潮流的创新型的企业,而这些企业今后到哪里融资,对这些企业中国的老百姓能不能投资,是中国金融体系改革亟需要关注的一点。如果在今后五到十年这些企业 还是跑到美国去上市,这就不是一个悲哀的问题了,我觉得那会是一个耻辱,我相信这种压力肯定会要倒逼中国金融体系有更大更快的变革。目前关键的问题就是中 国下一步金融体系要怎么改?在我看来未来可能会有三种情景,而且这三种情景取决于国内的金融制度改革的战略选择。

第 一种情景,大多数优秀的中国企业继续在美国上市,在中国投资者的压力下,中国的资本账户会有更大的开放,允许中国的投资者有更多的钱可以兑换成美元,到美 国市场上进行投资。中国实体经济对外投融资巨大的需求正在倒逼资本账户的开放,最近几年中国央行也在推动资本账户下可兑换,我相信今后几年会有很快的进 展。但如果在这个情景下,中国没有开发出能吸引自己企业的融资平台,中国的融资投资就只能通过美国市场(或其他国际市场)来运作,于是美国金融市场成为了 中国这些新型创新型企业的投资银行,这个结果肯定不是大家想要看到的。更进一步,这存在两个问题,一是中国有很多投资者,资金在中国,同时还是中国企业需 要融资,但是要到美国去才能做这件事情,交易成本就会非常高,这个肯定不是最优的解决方案。还有一些企业甚至国际化程度没有像阿里巴巴这么高,可能还走不 到美国去,融资就很困难,这就是我们讲的中小企业融资难的问题。二是汇率风险和国家风险,中国企业都在美国融资,而中国企业需要的都是人民币,中国投资者 到美国投资,最后也还是需要人民币,这里就存在汇率风险的问题;这些企业的融资都是在与国内各种制度完全不同的国家进行,肯定也有各种各样的国家和政治风 险。

第二种情景,中国企业去香港上市,中国现在有不少企业这么做,比如腾讯。香港市场相对来说离中国比较接近,而它的制度、资本市场的成熟 度、为金融企业服务的程度、公司治理的监管以及对投资者的保护都比大陆发展得要好。当然,香港市场的上市制度也存在某些限制,比如香港市场也有汇率问题, 至少现在港币是紧盯美元的,同时也有制度的风险。最近沪港通、深港通都在筹备当中,可能也是希望在这个方面起到一定的作用。如果香港成为重要的人民币离岸 市场,投融资也用人民币来计价,这种情景相比第一种情景对中国内地的投资者和融资企业风险和成本都要低一点,但是这毕竟不是最优的。更重要的是人民币金融 市场的定价权是不应该由一个离岸市场来主导的。

第三种情景,在中国的某一个地方打造一个具有国际水平的、比较开放的金融市场,按照人民币来 计价,让中国众多的投资者和需要融资的企业的投融资需求可以在境内得到满足。可能大家觉得这个情景还是天方夜谭,但是我觉得不完全是,而且我相信只要有开 放和改革的勇气,这在今后十年是可以实现的。上海自由贸易试验区的设立和实践就是为了在投融资便利、制度创新上发挥更大作用,所以我觉得有很多事情是可以 放到上海自贸区来实现的,中国的投资者缺乏投资品种,大量的融资者也在中国,但是没有好的市场把他们撮合在一起。说到底这是一个制度的问题,所以需要有制 度上的创新。

举一个可以创新的例子,中国现在非常缺的市场是中长期债券市场,中国的中长期发债方只有那些风险较小、信用评级较高的大企业。 如何为中国的中小企业提供一个平台,让他们也有中长期的债券融资的可能,而且还要能规避国内的所谓刚性兑付的潜规则?我认为,在自贸区发展这样的高收益债 券市场是一个很好的选择,为什么这样说?自贸区是对外开放的,债券市场开始可以主要引进境外持人民币的投资者,让境外投资者按照国际规则来进行风险定价, 该破产就破产,这样就可以打破刚性兑付的潜规则。这个债券市场要用人民币定价和结算,并通过自贸区已基本建成的分账户核算体系,逐渐地开放与境内账户的渗 透的程度让境内和境外互通,最后境内的投资者也可以没有限制地买这些债券。这样一个平台的建立是对中国的金融体系制度上的创新,真正能够为中国的投资者和 融资者服务,同时也能够推动人民币的国际化。而要实现这样一个平台关键是相关监管部门要看到中国整个金融体系的改革发展的大趋势,不要再为部门的利益而扯 皮,因为时间已经非常紧迫,今后五到十年中国会有一大批企业需要这样的服务,而如果中国市场不提供这样的服务,这些企业就会投奔美国或香港金融市场了。

这三种情景都比现在中国的情况是一种进步。其中哪一种情景在今后五到十年更可能发生就取决于今后三到五年的决策。我们当然应该争取最好的第三种情景,但这更需要中国改革者高度的勇气和智慧。

 

=============拓展讨论===========

1. 阿里巴巴在美国IPO居然是中国错失网络盛宴的证明?

Posted in 时评随笔 | Leave a comment

SCITE as nodejs groovy and qml (qtquick 2.0) c++11 IDE

in cpp.properties global setting file (sudo scite on  Linux)

#at the begining of this config file:

file.patterns.java=*.java;*.jad;*.pde;*.groovy

file.patterns.js=*.js;*.es;*.js6
#file.patterns.qml=*.qml

##############add for C++11 mingw32##########

#add more header and lib file path to support third party lib

cpluspluspts= -pedantic  -Os   -std=c++11  -I D:\Software\mingw64\include -L D:\Software\mingw64\lib

# support only single file compile directly into binary, no makefile is needed
cc=$(GCCPATH)\g++ $(ccopts)  -c $(FileNameExt) -o $(FileName).o

#################modify #####################
command.compile.$(file.patterns.cplusplus)=$(GCCPATH)\g++ $(cpluspluspts) $(FileNameExt) -o $(FileName)
command.build.$(file.patterns.cplusplus)=$(make.command)
command.go.$(file.patterns.cplusplus)=PATH $(GCCPATH);%PATH%  &&  $(FileName)
command.go.needs.$(file.patterns.cplusplus)=$(GCCPATH)\g++ $(cpluspluspts) $(FileNameExt) -o $(FileName)

##################add ######################
command.go.*.js=node.exe $(FileNameExt)
#es6 is not standard file suffix
command.go.*.js6=node.exe  –harmony $(FileNameExt)
###################################
keywords.$(file.patterns.qml)=$(keywordclass.javascript)
QT5PATH=C:\Qt\5.2.0\mingw48_32\bin;C:\Qt\Tools\mingw48_32\bin;%PATH%
command.go.*.qml=PATH $(QT5PATH) && qmlscene  $(FileNameExt)
#if it does not work, ->  start qmlscene from Qt for desktop command prompt!
#######################################
#tab openning needs to be adjusted,  append *.groovy    to java pattern for the timebeing
#file.patterns.groovy=*.groovy
#GROOVYPATH=D:\Software\Groovy2\bin\
#script need not compile and make
#command.compile.*.groovy=groovyc $(FileNameExt)
keywords.$(file.patterns.groovy)=$(keywordclass.java)
command.go.*.groovy=groovy $(FileNameExt)
###################################

Posted in Uncategorized | Comments Off

Using matplotlib to plot NI DAQmx data file (big data)

Due to the recent research requirement, I need to replot and analysis signal of high sampling rate (several mega samples per seconds) with PCIe card.

I planned to use numpy and matplotlib to plot, but I was a bit worried on the capability of using npTDMS and matplotlib to processing big data (100MB to 1GB, but big data in modern sense)

A quick test shows it works (to draw array of several mega samples), seems not worse than NI AIdem for visualization, all subject to serious delay during zooming in. However, the loading is much slower,  as npTDMS is pure python, not C API implemented.

And the program just consume as little memory as it is on disk size.

Continue reading

Posted in Uncategorized | Comments Off

using OpenCV in Qt4 GUI using python

This python read from webcam and display into Qt4 widget(not highGUI) code is adapted from example code from : #http://wrdeoftheday.com/?page_id=2

since not all source code is attached, I complete the code and make it available for downland. This can serve as a better starting point for more complicated app.

zip password: iesensor.com

zip file:  qtcvpy

Continue reading

Posted in Programming | Comments Off

beaglebone black debian wheezy usb net configuration and ssh login on windows and Linux

 

follow the tutorial and make usbnet boot automatically
http://hipstercircuits.com/enable-serialuarttty-on-beaglebone-black/

on my BBB debian wheezy:

sudo cat  /etc/modprobe.d/usbnet.conf

#auto load usbnet
options g_multi file=/usbnet.img stall=0
#there is a usbnet.img already there under /

Continue reading

Posted in Uncategorized | Comments Off

batch post-Process Ansys Fluent CFD Case And Plot In Python using Matplotlib or Tecplot

Features:

1. parse the ansys fluent profile text file into python list of dict;  draw velocity profiles by matplatlib (“see source code of draw_profile.py”)

2. generate tecplot batch and macro file to draw contours automatically in batch mode.  (see “vizCFDbytecplot.py”)

download the source file here,

vizFluentbytecplotandPython

I hope it can inspire you, but it will not serve you directly.

Edit some variables at the beginning of source code should make it work for you.

you need to record your own tecplot macro to style the plot.

 

 

License:BSD

Qingfeng Xia  2013

“CFD study of synthetic jet at low Reynolds numbers”

University of Manchester

 

Posted in Programming, Research | Comments Off

solutions for python pip install gcc compilation error: -mno-cygwin

 

(1)install unofficial python extension package  binary installer

Unofficial Windows Binaries for Python Extension Packages

by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine.

 

(2)
MinGWmay be not compatible with python pip compiler:   -mno-cygwin
remove the official mingw from path. or install mingw built for python

Windows GCC (MinGW) binaries for Python developers  gcc4.3

 

(3) Remove the  -mno-cygwin  option

-mno-cygwin in Python\Lib\distutils\cygwinccompiler.py causes this problem: see Compiling with cython and mingw produces gcc: error: unrecognized command line option ‘-mno-cygwin’ or http://korbinin.blogspot.com/2013/03/cython-mno-cygwin-problems.html.

My Python distribution (Anaconda)’s cygwinccompiler.py does not have that though. Anyway, after removing all -mno-cygwin in the definition of the Mingw32CCompiler class you should be able to compile.

Posted in Uncategorized | Comments Off

Recommend RT-Thread RTOS to Linux programmers

In a nutshell, Linux programmers will love RT-Thread API.
  1. Thread in RT-Thread works like  POSIX thread:  #include <posix_types.h>
  2. Each thread has TCB (task control block),  like Linux kernel thread, share the global memory, but has its own stack (pre-decleared array with fixed size), has event and timer for each thread;  Thescheduler, which uses bitmap algorithm,  is similar with Linux kernel
  3. RT-Thread is high performance RTOS, mainly focusing on ARM cortex-M 32bit CPU.
  4. RTGUI/FTK   (object-oriented style widget,  just like GTK+)
  5. Device model like Linux device tree.
  6. IPv4 and IPv6 are supported by lwIP lib with <socket.h>, but 6LowPAN is not supported as Contiki.
  7. Simulator on Linux and Windows (32bit  x86 only) and good documentation.
  8. Python scons building system; but it is easier than Makefile to control multiple targets building.

Most important, it is free even  for commercial usage, via applying free license and keep RT-thread banner.

Finally, this is the host place:  https://github.com/RT-Thread

Posted in Uncategorized | Comments Off

Software SPI library for Arduino tested on Mega2560

Since there is only one hardware SPI, but it is used by Ethernet or Wifi shield. If you wantto conenct some other sensors via SPI, the Ethernet lib is reluctant to cooperate.

So a software bit-banging library may be necessary.

Four SPI modes are supported, just change the macro definition in header file.

Continue reading

Posted in Uncategorized | Comments Off

[notes]Arduino IDE can NOT include libraries within project subfolders

The IDE requires every file to be in the same directory as the main program!

Continue reading

Posted in Uncategorized | Comments Off

Setup Codelite to work with visual studio toolset

I am tired to upload figures , I just give it as PDF file with figures inside

Setup Codelite to work with visual studio toolset (totorial version)

Posted in Uncategorized | Comments Off

python pinyin module support simplified and traditional chinese codecs

git clone https://github.com/qingfengxia/pinyin.py.git

Pinyin python module

Origin:      Author:cleverdeng      E-mail:clverdeng@gmail.com (not reachable)

forked by Qingfeng Xia based on v0.9:  
               (1)renamed class name from PinYin to Pinyin, 
               (2)dict file "word.data"  is  renamed  as "pinyin.data" 
               (3) add encoding support, or it will not work for windows cmd prompt! 
               (4) move load_word() (renamed as loaddict() ) into __init__(), to make API concise
               (5) word.data  "ord(UNICODE)= list of pinyin", for quick loading and human readable check
                  why some unicode has multiple pinyin units??? 

installation: 
               copy the two files:  pinyin.py, pinyin.data , into your project folder, or under $PYTHONPATH , or your sitepackages

test:   testing code is under __main__ section
               python -m pinyin.py

 Continue reading 
Posted in Download, Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (2)

as a further explanation to:

” Comparsion of DateTime classes in popular programming Languages (1)”

This part is a copy and paste of lang/lib spec.

Continue reading

Posted in Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (1)

C    boost::Datetime  Java JDK8(javax.time)  Qt Python and Javascript

(1) Table comparison

(2) Further explanation from each language spec

Joda package for (Java) is not described here, whose API is analoguous to Qt and Python. As there is new API of LocalDateTime,  it is the equivalent to QDatetime, and python’s datetime.

Table: Comparsion of DateTime classes in popular programming Languages

Author: Qingfeng Xia  2013    Versioin 0.1             http://www.iesensor.com

see attached word doc

Table Comparison of DateTime classes in popular programming Languages

Continue reading

Posted in Programming | Comments Off

You must know C++11, but have you noticed C11?

Previous C++ standard is C++03 (2003); previous C std is C99.They are not released together, but they did this time as  a combo of C11 and C++11.

__STDC_VERSION__ == 201112L

C11 (formerly C1X) is an informal name for ISO/IEC 9899:2011  (see wiki)

http://en.wikipedia.org/wiki/C11_%28C_standard_revision%29

Continue reading

Posted in Programming | Comments Off

Four wheel car robot based on Arduino Mega2560 and Raspberry Pi

git clone https://github.com/qingfengxia/arduinorobotcar.git

Datasheets (most of them in Chinedse) for robot parts makes the git size big

=========================================

Recently, I have been working on Arduino 2/4 wheel car robot in my spare time.

===============design goals==================

Robot car composing 4 DCMotors, Senors, ServoArm, BlueTooth remote control

Phase 1:
(1)   two/four wheel driving car steering,
There is no designated positive or negative pole for DC motor,  swapping pin1 and pin2 can made motor rotate reversely

Phase 2:
(2) sensors:  using  PID for sensor fusion ,
a)  altrasound range sensors included
b)  acceleration or angle speed
c) Infrared receiver
(3) Control by Infrared remote or PC control via bluetooth

Phase 3:
(4)  usb Camera supervision using Raspberry Pi usb wifi
(5) voice command recogniation by raspberry Pi connected to internet

Continue reading

Posted in Programming, Robot | Comments Off

Melexis90620 IR sensor controlled by Arduino and Raspberry Pi

I have made a C++ library class for Melexis90620 (in order to use multiple sensors simultanuously ),  a test program to demo this class, python program to show the contour.

Also, I made I2C C program to control itby Raspberry PI, but raspberry Pi can not read from RAM (reading EEPROM is fine).

A new plan under evaluation is to use 4 Melexis90620 togother to make 16X16 pixel IR camera. The only obstacle is to change the I2C slave address. I saw some guy has change the address of Melexis90614.  I dump EEPROM of reserved addr,  I found some byte should be addr, but I dont know how to write EEPROM. (command sequence)

Continue reading

Posted in Download, Programming, Robot, Sensor | Comments Off

my robotics lab is ready to go

IMG_20130303_170947

Posted in Robot | Comments Off

QtCore vs C++ STL & boost lib (4) smart pointers

see “Count with me: how many smart pointer classes does Qt have?”

http://blog.qt.digia.com/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/

Smart pointers  Introduction Ver
QPointer<T> Qt Object , guarded pointer,
set NULL after delete/deconstruction
However, pointed resource not released
 Qt4.0
QSharedPointer reference-counted strong sharing of pointers Qt4.5
QWeakPointer reference-counted weak sharing of pointers Qt4.5
QScopedPointer Qt4.6
QScopedArrayPointer QScopedPointer drived Qt4.6
QSharedDataPointer Qt (Implicit Sharing) copy-on-write Qt4.0
QExplicitlySharedDataPointer ExplicitlyShared Qt4.4

C++11 <smart_pointer>

Introduction to smart pointers:   http://en.wikipedia.org/wiki/Smart_pointer

std::auto_ptr  Not recommended in C++11  C++03
std::shared_ptr Reference counting C++11
std::weak_ptr Intended for Garbage collection C++11
std::unique_ptr non-copyable, but can be transfered C++11
boost::scoped_ptr<T> Equal to QScopedPointer

neither copyable nor movable.

Continue reading

Posted in Programming | Comments Off