2011年12月21日 星期三

讀書心得-投資人宣言

讀書心得-投資人宣言

2011年12月9日 星期五

讀書心得-智慧型資產配置

讀書心得-智慧型資產配置

2011年11月24日 星期四

Nonstop NTP client demo

# Program name = ntp.py
# This program is for Nonstop server NTP client
# prerequirements : HP Nonstop OSS , Pyhton 2.4.2 (get it from ITUGLIB,http://ituglib.connect-community.org), and 
# donwload ntplib-0.1.9 from Python Package Index
# You have to modify ntplib.py in ntplib-0.1.9 to accept ip address NTP. Here is snippet
#   def request(self, host, version=2, port='ntp'):
#       """make a NTP request to a server - return a NTPStats object"""
#        # lookup server address
#        #addrinfo = socket.getaddrinfo(host, port)[0]
#        #family, sockaddr = addrinfo[0], addrinfo[4]
#        family=2
#        sockaddr=(host,123)

# You need to use Super Group to run the program.Because SETTIME is Super Group ONLY.
# Usage : gtacl -c "$(python ntp.py)"


import ntplib
import os
from time import ctime
c = ntplib.NTPClient()
response = c.request('XXX.XXX.XXX.XXX', version=3)
response.offset
response.version
ntptime=ctime(response.tx_time)
ntptimelist =ntptime.split()
newtime=ntptimelist[1]+' '+ntptimelist[2]+' '+ntptimelist[4]+','+ntptimelist[3]

#print ntplib.leap_to_text(response.leap)
#print response.root_delay

settimestring = "settime"+' '+newtime
#print settimestring
print "time"    


#os.system('gtacl -c "time"')
#os.system('gtacl -c "status *"')
#os.system('gtacl -p fup "info \uitc.\$dev.cup.*"')

2011年10月25日 星期二

MS Window 平台發送email 工具-blat

MS Window 平台發送email 工具-Blat
目的:每天可以從email 收到批次或程式執行的結果,想法是把結果寫入檔案,再透過windows 排定的工作發送email 到個人信箱

1.發送email 的工具,website :http://www.blat.net/ ,download 並解壓縮 ,sample 是 D:\blat

2.建立 send.bat,內容:


del sendbody.txt
del sendlog.txt
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set batdate=%%i/%%j/%%k)
echo %batdate% >> sendbody.txt
echo "Refresh job report" >> sendbody.txt
echo "請檢查" >> sendbody.txt

blat sendbody.txt ^
   -to user1@abcd.com.tw,user2@abcd.com.tw  ^
   -f rayyeh@uitc.com.tw ^
   -charset big5 ^
   -server 192.168.10.x  ^
   -s %batdate%"  REFRESH 批次結果"  ^
   -attach "D:\blat\full\report.txt" ^
   -log "D:\blat\full\sendlog.txt" 

 




3.sendbody.txt  是email 內文的內容:
2011/10/25
"Here is job report"

-attach "D:\blat\full\report.txt" 是email 附加上檔名 report.txt

4.把send.bat 加入 window 排定的工作,每天就可以收到想要的報表

2011年1月5日 星期三

Python 2D 軟體

寫下python 2D/3D 軟體,避免忘記:

1.Gnuplot :
優點: 有GUI 可以互動式學習指令,上手容易,也有3D 的功能,也可以 programming with python
缺點:圖沒有很漂亮


2.Pylab:就是 matplotlib 
優點:
缺點:

3.Enthought 的Chaco 2D 繪圖軟體:
優點:畫面漂亮,
缺點:沒有互動式GUI 可以玩


  • 介紹 Chaco 2D 用Ipython 指令方式繪圖:
1.啟動Ipython
>> import numpy as np
>> from enthought.chaco.shell import *
>> x=np.array([1,2,3,4,5])
>> y1=np.array([2,3,4,5,6])
>> y2 =np.array([4,5,6,7,8])
>> plot(x,y1,'r.') 
>> hold()
>> plot(x,y2,'g+',marker_size =10)
>> title('First Plot')
>> show()



  •  Chaco programming 方式:
   可以到 Chaco 的網站有很多Sample code 可參考,另外
    安裝chaco 後,在 chaco/example/ 底下也有很多sample 可以學習