顯示具有 IT 標籤的文章。 顯示所有文章
顯示具有 IT 標籤的文章。 顯示所有文章

2012年12月11日 星期二

MongoDB 筆記

MongoDB 筆記

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 排定的工作,每天就可以收到想要的報表

2010年7月22日 星期四

Zoundry Raven blog writer 工具介紹

從網路上找到 Zoundry Raven 這個 offline blog writer ,

Web site is http://www.zoundryraven.com/ ,它可以backupblog , offline wirte blog,

寫好blog upload to website

這是一個很棒的工具,我應該會使用它。

2010年5月9日 星期日

檔案復原工具與圖片管理工具

檔案復原工具與圖片管理工具:

之前,不小心把Seagate 備份HD 給 MAC partition 
Window XP 與MAC 都讀不到HD 的資料,整個Partition 大概掛了, 只好找軟體可以去Recovery HD 資料
最重要的一點是,千萬讓這顆HD 寫入任何資料,不然,資料可能救不回來

推薦軟體: 
Power Data Recovery -http://www.powerdatarecovery.com/
原因: 我用過幾個軟體,覺得介面友善, 救回的檔案分類清楚,圖檔都有就回來,拍攝日期也沒跑掉,
        方便我重新分類

用過其它軟體的經驗:      
1.Easy Recovery Pro 2002: 會把照片多成好幾份,且圖檔被縮小, 無法使用,宣告失敗
2.R-Studio :因為我的圖檔太多(超過2萬),所以會當掉,無法使用得知測試結果,宣告失敗
3.FinalData: 什麼都就不出來,宣告失敗


2.圖檔救回來,再來就是先把重覆的挑掉,再用日期分資料夾:
推薦軟體:
原因: Free,簡單好用,也夠用

VISUAL SIMILARITY DUPLICATE IMAGE FINDER:
http://www.mindgems.com/products/VS-Duplicate-Image-Finder/VSDIF-About.htm
原因:很好用,可是要錢

3.再來,把所有照片匯入iPhoto, 記得在iphoto 的偏好設定內>在事件選單> 把Finder 這個打勾,        
   這樣才可以幫你做日期分類事件








2010年1月29日 星期五

Python 文件產生方法 - Sphinx 產生PDF 中文解法

Sphinx 是利用rst 文件 去產生  html、latex、pdf 等等的文件產生工具,
現行產生pdf 會碰到 中文字無處理的問題,解決方案:

1. rst 轉 Latex ,Latex 再轉 pdf

a. 找出 sphinx-quickstart 產生的project folder
b.在 project-folder/source 找出 conf.py
c.edit conf.py  找到以下並修改為:
   latex_preamble = '''\usepackage{CJKutf8}\n\AtBeginDocument{\\begin{CJK}{UTF8}{bsmi}}\n\AtEndDocument{\end{CJK}}'''
   source_encoding = 'utf-8'

d.再利用產出的 latex 文件去轉成 pdf
e.如何安裝 latex 與 CJK (Chineses/Japan/Korea) 字型 請參考:
  在Windows 下使用LaTeX



Python 文件產生方法 - 工具篇

1.Code highlighter:
  Pygments -http://pygments.org/

2.rStructure text 轉 PDF
  rst2pdf -http://code.google.com/p/rst2pdf/

3.Docutils:Documentation Utilities
  http://docutils.sourceforge.net/

4.Sphinx-Python document generator (會包含 docutils 的套件)
  http://sphinx.pocoo.org/index.html

5.xhtml2pdf
  http://www.xhtml2pdf.com/

6.ReportLab's Open Source Libraries
 http://www.reportlab.com/software/opensource/

7.html5lib
  Library for working with HTML documents

現行作法:
1. 用reStructureText 寫文件
2. rst2html.py 產生 html 檔  ------- 已完成.
3. html 檔用 pdfCreator 產生 PDF 檔 -- 已完成.
4. rst2pdf 產生 PDF 檔-已完成. 但需加入 styles 檔

5.xhtml2pdf.exe 產出的pdf 中文字碼為黑塊.
6.Sphinx 掛rst2pdf 的 pdfBuilder ,產生PDF 檔中文字碼為黑塊.

2010年1月27日 星期三

Python 文件產生方法 - rst2pdf 中文解法

目的: 使用讓 rst2pdf 去產生中文的 PDF 文件,rst2pdf 的功能是將 reStructureText 文件轉換成 PDF 檔
       這份文件是說明如何讓它輸出 有中文的 PDF 檔


1.Q:如何安裝 rst2pdf:
   A: easy_install rst2pdf

2.產生方式
解法1: 讓 rst2pdf 去讀外部的style 檔


 rst2pdf -help 看到  -s 的作法
   -s STYLESHEETS, --stylesheets=STYLESHEETS
       A comma-separated list of custom stylesheets.Default=""
     
指令: rst2pdf -s xxx.style source.txt -o  output.pdf
說明:
1.kaiu 應該是標楷體

2.source.txt 是 reStructureText 且需存成 utf-8 編碼的文件檔
3.
xxx.style 的內容:
{
 "embeddedFonts" : [["kaiu.ttf","kaiu.ttf","kaiu.ttf","kaiu.ttf"]],
  "fontsAlias" : {
    "stdFont": "kaiu",
    "stdBold": "kaiu",
    "stdItalic": "kaiu",
    "stdBoldItalic": "kaiu",
    "stdMono": "kaiu"
    }
}
 

解法2: 修改 style.json 
 如: D:\Python26\Lib\site-packages\rst2pdf-0.12.3-py2.6.egg\rst2pdf\styles\styles.json

修改後內容:
  "embeddedFonts" : [ ["kaiu.ttf","kaiu.ttf","kaiu.ttf","kaiu.ttf"]],
    "stdFont": "kaiu",     
    "stdBold": "kaiu",
    "stdItalic": "kaiu",
    "stdBoldItalic": "kaiu",
    
    "stdSans": "kaiu",
    "stdSansBold": "kaiu",
    "stdSansItalic": "kaiu",
    "stdSansBoldItalic": "kaiu",
    
    "stdMono": "kaiu",
    "stdMonoItalic": "kaiu",
    "stdMonoBold": "kaiu",
    "stdMonoBoldItalic": "kaiu",
    "stdSerif": "kaiu"

修改前內容:
  "embeddedFonts" : [ ],
    "stdFont": "Helvetica",     
    "stdBold": "Helvetica-Bold",
    "stdItalic": "Helvetica-Oblique",
    "stdBoldItalic": "Helvetica-BoldOblique",
    "stdSans": "Helvetica",
    "stdSansBold": "Helvetica-Bold",
    "stdSansItalic": "Helvetica-Oblique",
    "stdSansBoldItalic": "Helvetica-BoldOblique",
    "stdMono": "Courier",
    "stdMonoItalic": "Courier-Oblique",
    "stdMonoBold": "Courier-Bold",
    "stdMonoBoldItalic": "Courier-BoldOblique",
    "stdSerif": "Times-Roman"




3.結論:

a.建議使用 解法 1 產生pdf檔,因為尚未解決 Sphinx 如何產生中文的PDF 檔








2010年1月14日 星期四

程式版本控管與管理流程之靠腰

很多IT 部門的軟體變更管理,會有資料管制人員負責去協助變更管理,其目的是避免程式開發人員自行變更而造成混亂,說明一下變更流程大概如下:

1.提出變更申請目的
2.AP 頭頭同意
3.附上變更軟體資料、測試報告等等。交付資料管制人員處理。
4.資料管制人員,檢查申請人所付資料是否符合?
要進入正式區軟體庫中的檔案是否與申請項目相同

要討論的是如何確認申請人所附檔案是正確的(第 4 點):
1.申請人比對正式區軟體庫內容並產生差異檔 - DiffData1
2.資料管制人員依申請人申請,比對正式區軟體庫內容並產生差異檔 -DiffData2
3.比對DiffData1 與DiffData2 內容是否一致

問題來了,Source Code 是可以這麼做,但若是非Source Code (如COM/DLL) 要如何管理呢?
subversion 的diff 檔比不出來呀,解法是產生檔案的checksum 去證明是兩者一致,
如你去網路Download 檔案,也都是會看到檔案提供者在網站公告chksum ,讓你知道你下載的檔案是正確未被篡改過,要產生Checksum 有很多種方法,普遍是用MD5,那只要可以利用Subversion 找出差異檔並產生每個檔案的MD5 並產生報表,申請人與資料管制人員都利用這種方式進行變更管裡,問題就解決了。

口說無憑,程式碼如下
#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""
SVNMD5.EXE.
Used to compare working copy and Repository ,genereate compare report.
It's 100 % Python :)
I use Python 2.6.4 , py2exe,pysvn 1.7.2 to create SVNMD5.EXE
Diff report format : Unified diff format
"""

__author__ = ' Ray Yeh <yeh_ray@hotmail.com>'
__version__ = '1.0'
__licence__ = 'GPL V3'


import sys
import os
import re
from datetime import datetime
import pysvn
import codecs
import hashlib


def Usage():
print """Usage: """ + sys.argv[0] + """ PATH >> Report_file
Usage sample1 : SVNMD5.exe d:\project >> d:\svnreport.txt --> Output report at d:\svnreport.txt
Usage sample 2: SVNMD5.exe d:\project --> Output at screen
Batch compare working copy with repository and generate report to PATH

by Ray Yeh version 1.0
"""
sys.exit(1)

#------------------------------- Process the options -------------------------
if len(sys.argv)==2 :
workingdir=sys.argv[1]
else:
Usage()

try:
os.chdir(workingdir)
except OSError:
print "Cannot change dir to " + workingdir
Usage()
#------------------------------- Find out what has changed -------------------
client = pysvn.Client()
changes = client.status(workingdir)

#print 'files to be added:'
addedlist =[f.path for f in changes if f.text_status == pysvn.wc_status_kind.added]
#print 'files to be removed:'
deletedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.deleted]
#print 'files that have changed:'
modifiedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.modified]
#print 'files with merge conflicts:'
conflictedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.conflicted]
#print 'unversioned files:'
unversionedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.unversioned]
#print 'missing files:'
missinglist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.missing]

dt=datetime.now()

print "SVN compare run at:"+ dt.strftime("%A, %d. %B %Y %I:%M%p")
print "Compare Woking directory:"+workingdir + "\n"


str_1 =u"================== 產生 Compare 資料開始 ================="
str_2 =u"================== 產生 Compare 資料結束 ================="
print str_1.encode('big5_tw')
# Added files
for item in addedlist:
buff =""
file=open(item, 'rb')
buff=file.read()
file.close()
m=hashlib.md5()
m.update(buff)
print item+ " =>MD5 Chksum:" + m.hexdigest()

#Modified files
for item in modifiedlist:
buff =""
file=open(item, 'rb')
buff=file.read()
file.close()
m=hashlib.md5()
m.update(buff)
print item+ " =>MD5 Chksum:" + m.hexdigest()
print str_2.encode('big5_tw')

#Unversionedl files
for item in unversionedlist:
buff =""
file=open(item, 'rb')
buff=file.read()
file.close()
m=hashlib.md5()
m.update(buff)
print item+ " =>MD5 Chksum:" + m.hexdigest()

deletedcount=0
modifiedcount=0
missingcount=0
addedcount=0
unversionedcount=0

i=0
for i in addedlist:
addedcount +=1
i=0
for i in modifiedlist:
modifiedcount +=1
i=0
for i in missinglist:
missingcount+=1
i=0
for i in unversionedlist:
unversionedcount +=1

str_3=u'比對目錄路徑:'
str_4=u'比對檔案清單:'
str_5=u'新增 '
str_6=u'差異 '
str_7=u'刪除 '
str_8=u'未納版'
print str_3.encode('big5_tw')
print str_4.encode('big5_tw')
print str_5.encode('big5_tw')+'%d folders/files:\n%s' %(addedcount, addedlist)
print str_6.encode('big5_tw')+'%d folders/files:\n%s' %(modifiedcount, modifiedlist)
print str_7.encode('big5_tw')+'%d folders/files:\n%s' %(missingcount, missinglist)
print str_8.encode('big5_tw')+'%d folders/files:\n%s' %(unversionedcount,unversionedlist)
print "=========================================================="

2010年1月12日 星期二

使用svn 去產生 Working copy 與 repository 的比對報表

目的: 使用svn 去產生 Working copy 與 repository 的比對報表
解決方案:
1.Ad hoc 方法:
a.安裝支援 CLI(Command Line Interface) 的 svn 軟體,利用Command Line 去產生比對報表

2.利用 程式產生,並使用svn command line :
a. 利用DiffUtils 去產生 Context format ,如果不想看Context format 就用 svn 原始的diff 去產生 unified format 。
b.GNU32 -DiffUtils 2.8.7 (show differences between files)
http://gnuwin32.sourceforge.net/
c.SVN- Setup-Subversion-1.6.6.msi
http://subversion.tigris.org/

#!/usr/bin/env python
# Python version of the bash shell "svnreport"

"""
SVNREPORT1.EXE.
Used to compare working copy and Repository ,genereate compare report.
It's 100 % Python :)
I use Python 2.6.4 , py2exe to create SVNREPORT1.EXE
Diff report format : Unified diff format
"""

__author__ = ' Ray Yeh <yeh_ray@hotmail.com>'
__version__ = '1.0'
__licence__ = 'GPL V3'


import sys
import os
import re
from datetime import datetime


def Usage():
print """Usage: """ + sys.argv[0] + """ PATH >> Report_file
Usage sample1 : svnreport1.exe d:\project >> d:\svnreport1.txt --> Output report at d:\svnreport.txt
Usage sample 2: svnreport1.exe d:\project --> Output at screen
Batch compare working copy with repository and generate report to PATH

by Ray Yeh version 1.0
"""
sys.exit(1)

#------------------------------- Process the options -------------------------
if len(sys.argv)==2 :
workingdir=sys.argv[1]
else:
Usage()

try:
os.chdir(workingdir)
except OSError:
print "Cannot change dir to " + workingdir
Usage()

#------------------------------- Find out what has changed -------------------

svnstatus=os.popen("svn status").readlines()

added=""
deleted=""
modified=""
commit_message=""
#print svnstatus

for line in svnstatus:

matchObject=re.match(r"^\?\s*(.*)\n",line)
if matchObject:
added = added + "\"" + matchObject.group(1) + "\" "
#print matchObject.group(1)
commit_message += "added file " + matchObject.group(1) + "\n"

matchObject=re.match(r"^\!\s*(.*)\n",line)
if matchObject:
deleted = deleted + "\"" + matchObject.group(1) + "\" "
commit_message += "deleted file " + matchObject.group(1) + "\n"

matchObject=re.match(r"^\M\s*(.*)\n",line)
if matchObject:
modified = modified + "\"" + matchObject.group(1) + "\" "
commit_message += "modified file " + matchObject.group(1) + "\n"

'''if added:
#os.system("svn diff "+added)
if deleted:
print "deleted-"+deleted
#os.system("svn diff "+deleted) '''
if modified:
os.system('svn diff ' +modified )


if not added:
commit_message += "no added files\n"
if not deleted:
commit_message += "no deleted files\n"
if not modified:
commit_message += "no modified files\n"

modifiedcount =0
addedcount = 0
deletedcount=0

addedlist=added.split()
modifiedlist=modified.split()
deletedlist=deleted.split()

i=0
for i in addedlist:
addedcount +=1
i=0
for i in modifiedlist:
modifiedcount +=1
i=0
for i in deletedlist:
deletedcount +=1

dt=datetime.now()
print "======================================================="
print "SVN compare run at:"+ dt.strftime("%A, %d. %B %Y %I:%M%p")
print "Compare Woking directory:"+workingdir
print "Add %d folders/files:\n%s" %(addedcount, added)
print "Modified %d folders/files:\n%s" %(modifiedcount, modified)
print "Deleted %d folders/files:\n%s" %(deletedcount, deleted)
print "======================================================="





3.利用程式產生,不使用svn command line ,
a.pysvn -http://pysvn.tigris.org/
b.python 2.6.4

### -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
PYSVNRPT.EXE.
Used to compare working copy and Repository ,genereate compare report.
It's 100 % Python :)
I use Python 2.6.4 , py2exe,pysvn 1.7.2 to create PYSVNRPT.EXE
Diff report format : Unified diff format
"""

__author__ = ' Ray Yeh <yeh_ray@hotmail.com>'
__version__ = '1.0'
__licence__ = 'GPL V3'


import sys
import os
import re
from datetime import datetime
import pysvn


def Usage():
print """Usage: """ + sys.argv[0] + """ PATH >> Report_file
Usage sample1 : PYSVNRPT.exe d:\project >> d:\svnreport.txt --> Output report at d:\svnreport.txt
Usage sample 2: PYSVNRPT.exe d:\project --> Output at screen
Batch compare working copy with repository and generate report to PATH

by Ray Yeh version 1.0
"""
sys.exit(1)

#------------------------------- Process the options -------------------------
if len(sys.argv)==2 :
workingdir=sys.argv[1]
else:
Usage()

try:
os.chdir(workingdir)
except OSError:
print "Cannot change dir to " + workingdir
Usage()
#------------------------------- Find out what has changed -------------------
client = pysvn.Client()
changes = client.status(workingdir)

#print 'files to be added:'
addedlist =[f.path for f in changes if f.text_status == pysvn.wc_status_kind.added]
#print 'files to be removed:'
deletedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.deleted]
#print 'files that have changed:'
modifiedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.modified]
#print 'files with merge conflicts:'
conflictedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.conflicted]
#print 'unversioned files:'
unversionedlist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.unversioned]
#print 'missing files:'
missinglist=[f.path for f in changes if f.text_status == pysvn.wc_status_kind.missing]

dt=datetime.now()

print "SVN compare run at:"+ dt.strftime("%A, %d. %B %Y %I:%M%p")
print "Compare Woking directory:"+workingdir + "\n"



print "====================="+u" 產生 Compare 資料開始 "+"==================="
for item in modifiedlist:
difftext=client.diff('t:',item)
print difftext
print "====================="+u" 產生 Compare 資料結束 "+"==================="


deletedcount=0
modifiedcount=0
missingcount=0
addedcount=0
unversionedcount=0

i=0
for i in addedlist:
addedcount +=1
i=0
for i in modifiedlist:
modifiedcount +=1
i=0
for i in missinglist:
missingcount+=1
i=0
for i in unversionedlist:
unversionedcount +=1

print u"比對目錄路徑:"+workingdir
print u"比對檔案清單:"
print u"新增 %d folders/files:\n%s" %(addedcount, addedlist)
print u"差異 %d folders/files:\n%s" %(modifiedcount, modifiedlist)
print u"刪除 %d folders/files:\n%s" %(missingcount, missinglist)
print u"未納版 %d folders/files:\n%s" %(unversionedcount,unversionedlist)
print "=========================================================="


4. 安裝 Pysvn WorkBench Subversion

2009年12月11日 星期五

COCOMO II Model Overview

COCOMO II Model:
1.Source Lines of Code(SLOC)
a.SLOC 是logical line ( If-else-endif) 視為一個 SLOC
b.Comment 不計算在SLOC
c.宣告算在SLOC

2.Cost Drivers:
a.
Effort = 2.94 * EAF * (KSLOC)E
Where EAF=
Effort Adjustment Factor derived from the Cost Drivers
E=
an exponent derived from the five Scale Drivers
例如,EAF=1.00, E= 1.0997,8,000 source lines of code

Effort = 2.94 * (1.0) * (8)1.0997 = 28.9 Person-Months


3.Effor Adjustment Factor:
a.
Complexity (effort multiplier of 1.34)

b.
Language & Tools Experience (effort multiplier of 1.09)
c.the others normal ,set 1.00
Effort Adjustment Factor = EAF = 1.34 * 1.09 = 1.46

Effort = 2.94 * (1.46) * (8)1.0997 = 42.3 Person-Months


4.Schedule Equation:
a.
Duration = 3.67 * (Effort)SE
Where

Effort Is the effort from the COCOMO II effort equation

SE Is the schedule equation exponent derived from the five Scale Drivers


b.
0.3179 that is calculated from the scale drivers:



Duration = 3.67 * (42.3)0.3179 = 12.1 months

Average staffing = (42.3 Person-Months) / (12.1 Months) = 3.5 people



5.SCED Cost Drivers:


a.Required Development Schedule
(SCED)
b.代表若要加速工作進度,在樂觀的條件下,需要多少人力
c.
SCED rating of Very Low corresponds to an Effort Multiplier of 1.43 (in the COCOMO II.2000 model)

d.means that you intend to finish your project in 75% of the optimum schedule .



Duration = 75% * 12.1 Months = 9.1 Months
Effort Adjustment Factor = EAF = 1.34 * 1.09 * 1.43 = 2.09

Effort = 2.94 * (2.09) * (8)
1.0997 = 60.4 Person-Months


Average staffing = (60.4 Person-Months) / (9.1 Months) = 6.7 people



Remember: SCED cost driver means "accelerated from the nominal schedule".

2009年12月8日 星期二

MS SQL Role and User security

SQL server 兩種登入方式(二選一) :
1. Window 網域帳號登入,歸Window 作業系統
2. SQL server 帳號登入,SQL server 管理(Server roles are usually reserved for database and server administrators.)
3. Windows Authentication is the recommended security model when using SQL Server.

安全分等:
  • Login security—Connecting to the server (登入 Server)
  • Database security—Getting access to the database (存取DB)
  • Database objects—Getting access to individual database objects and data(存取DB的某一個object/data)

Role types:
1.Server Role -DBA 維護,管理整台server
2.Database Role - 管理單一的database
3.public role 只要一加入 SQL server,都有public role

Database Role(Predefine):
  • db_owner: Members have full access.
  • db_accessadmin: Members can manage Windows groups and SQL Server logins.
  • db_datareader: Members can read all data.
  • db_datawriter: Members can add, delete, or modify data in the tables.
  • db_ddladmin: Members can run dynamic-link library (DLL) statements.
  • db_securityadmin: Members can modify role membership and manage permissions.
  • db_bckupoperator: Members can back up the database.
  • db_denydatareader: Members can’t view data within the database.
  • db_denydatawriter: Members can’t change or delete data in tables or views.

Server Role(Predefine ):
  • SysAdmin: Any member can perform any action on the server.
  • ServerAdmin: Any member can set configuration options on the server.
  • SetupAdmin: Any member can manage linked servers and SQL Server startup options and tasks.
  • Security Admin: Any member can manage server security.
  • ProcessAdmin: Any member can kill processes running on SQL Server.
  • DbCreator: Any member can create, alter, drop, and restore databases.
  • DiskAdmin: Any member can manage SQL Server disk files.
  • BulkAdmin: Any member can run the bulk insert command.





2009年11月18日 星期三

TCP Windows Size 解答

說明TCP Windows Size 的用途與注意事項
1.TCP Windows Size 目的是 Sender 與 Receiver 最好能把Data 一次處理完,
以避免因為網路設備彼此速度不同,而造成Data Lost 的問題。

2. TCP Windows Size 要多大呢?
window size = bandwidth * delay
假設網路是 100 Mbits/s, round trip time (RTT)是 5 ms,所以 Windows Size 應為
( 100 * 10^6) *( 5 * 10^-3) = 500 * 10^3 bits (65 kilobytes)

3.最後 Client 與 Server 的buffer 要設一樣:
/* An example of client code that sets the TCP window size */

int window_size = 128 * 1024; /* 128 kilobytes */

sock = socket(AF_INET, SOCK_STREAM, 0);

/* These setsockopt()s must happen before the connect() */
setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
(char *) &window_size, sizeof(window_size));
setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
(char *) &window_size, sizeof(window_size));
connect(sock, (struct sockaddr *) &address, sizeof(address));


/* An example of server code that sets the TCP window size */
int window_size = 128 * 1024; /* 128 kilobytes */
sock = socket(AF_INET, SOCK_STREAM, 0);

/* These setsockopt()s must happen before the accept() */
setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
(char *) &window_size, sizeof(window_size));
setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
(char *) &window_size, sizeof(window_size));

listen(sock, 5);
accept(sock, NULL, NULL);
4.備註:
a.Nonstop 系統
TCP programming :setsockopt 參數(SO_SNDBUF/SO_RCVBUF)
Default 8192 bytes

5.參考:
a.A User's Guide to TCP Windows
b.Enabling High Performance Data Transfers
c.Windows 2000 TCP Performance Tuning Tips

6.
a.Max Transmission Unit (MTU) - TCP header(20 byte)- IP header (20 bytes) =Max Segment Size(MSS)
b.

2009年3月3日 星期二

WMI and ADSI tools

今天在清查Window system 電腦的User ID 清單,找煩了,想說有沒有程式可以偷懶,
原來有這麼多玩具呀,一下子就把資料清出來了。

1.WMI-Windows Management Instrumentation
For Windows 所有元件,從硬體到軟體都在範圍內

2.ADSI- AD Service Interface
For AD 專用
如果你要管理Local user and group account請用ADSI

3.WMI 與ADSI 是不相容,所以不要把WMI 的Code 弄到 ADSI 裡面RUN

4.開發讀取 WMI or ADSI 的語言可有VBscript,Python
為了向下相容,我使用 VBscript 去開發

5.開發好的程式如何執行, 可以是
wscript xxx.vbs  -- 會出現window message,還要按Enter 去顯式下一個message
cscript xxx.vbs   -- 不會出現window message.
我習慣的作法  cmd > cscript xxx.vbs  >> xxx.txt ( output to xxx.txt)



Ref:
中文:
http://www.microsoft.com/taiwan/technet/scriptcenter/default.mspx


英文
http://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx

2009年2月9日 星期一

如何把Excel 轉成UTF-8的資料

1.因為要把EXCEL 的資料轉成UTF-8 的格式才能在Sqlite3 使用,故需要轉碼
2.方法如下:
a.開啟EXCEL 檔,另存新檔,變成 CSV 檔案
b.利用notepad 開啟 CSV 檔案 ,並另存成 UTF-8 檔案
c. 接下來就可用Sqlite3 來開啟中文資料了

2009年1月10日 星期六

Regular expression

字元 代表該字元^ 限制字串必須出現於行首
$ 限制字串必須出現於行末
\ 將特殊字元還原成字面意義的字元
^ 某字元以外的任何字元
- 字元集合中可使用 - 來指定字元的區間

+ 其前的字元或字元集合出現一次或一次以上
? 其前的字元或字元集合可出現一次或不出現
* 其前的字元或字元集合可出現任何次數或不出現
(...) 用以括住一群字元,且將之視成一個集合
{n} 重複 n 次
{n,m} 重複 n 到 m 次
{n,} 至少重複 n 次
[] 其中之一字元可出現可不出現,例如 [abc] 表示不論出現 a 或 b 或 c 都算符合
| 代表「或」, 例如 (Sun|Mon|Tue|Wed|Thu|Fri|Sat), (日|一|二|三|四|五|六) 以左右括號括住

. (句點符號) 代表除了換行符號 (\n) 以外的任一字元。如果要包括換行符號,請使用 [\s\S]
\w (\W) 代表任何英文(以外的) 字元
\s (\S) 代表空白 (以外的) 字元
\d (\D) 代表數字 (以外的) 字元
\b (\B) 代表位於文字邊界的 (以外的) 字元。(在英文中)你可以把 \b 視作空白或 TAB 字元, 例如 \bBB 可符合 "ABB CBB" 中的 CBB 但非 ABB, 因為 ABB 位於行首, 不算是文字邊界; 這是容易混淆的地方。
\r 代表換行字元
\n 代表換行字元 (通常和 \r 一同出現, 所以一般以 \r\n 代表換行)
\t 代表 TAB 字元
\( 代表左括號
\) 代表右括號
\X 以十六進位字元碼代表某個字元; 例如 [\x21-\x7E] 可代表所有看得到的字元 ([\x20-\x7E] 則包括空白字元)

2008年4月20日 星期日

Subversion Server 與 TortoiseSvn 初體驗(一)


1.安裝Subversion Server
software download http://subversion.tigris.org/
新增捷徑 並修改啟動參數:
"C:Program FilesSubversionbinsvnserve.exe" --daemon --root c:svn

以上Subversion Server 已經啟動服務

2.安裝TortoiseSvn(name "TSVN") -- TSVN is Client
software download http://tortoisesvn.net/downloads
安裝 語言package (可以在那個網頁找到)

3.如何使用:
a.產生一個Resposity 的目錄(幫你管理version 的資訊)
for example: create folder c:SVN,所以TSVN 的檔案庫瀏覽器path file:///C:/SVN
然後 用TSVN ,press mouse right bottom, you can see "create resposity here"

b.設定你的專案
for example: c:SVN1, 並開始將檔案放入 SVN1 folder 中

當完成時, 請press mouse right buttom to SVN commint .

所以你的第一個檔案就已經check in Resposity 中

c.取出檔案進行修改

Press mouse right key to SVN checkout

you can select "Checkout directory" and save to your folder.


d.當你編撰完檔案後,只要press mouse right key and SVN Commit ,就可以檔案同步Server 了,記得寫上change 的原因,

方便管理版本



e.當你建立完新的東西, 需要加入subversion

press mouse right key and "Add" to SVN server.

Reference URL:

1.http://jostudio.blogspot.com/2006/12/svn-subversion-tortoisesvn.html


2.http://subversion.tigris.org/








2008年1月28日 星期一

google 還不錯用-part1

介紹一下Google功能吧:
1.Google docs : 可以直接上傳doc,excel,ppt 檔案上去,也可以直接在google docs內編寫檔案,
並發佈給朋友同事使用,還可以直接轉成blog,Google excel,直接當作記帳本,去哪都可以計帳使用
2.Gmail :可以當mail box,也可以當作IM 使用,讚
3.Google 筆記本:看到哪個網站就給他log 起來,回去慢慢看
4.待辦事項清單:編寫要做哪些事,再利用igoogle ,一切都方便使用

2008年1月21日 星期一

Ubuntu 及 虛擬機器

上個星期把NB 的HD 整理了一下,想把google 的python module 拿來玩玩,首先就先download
visual box 安裝虛擬機器,安裝後,裝了 Ubuntu 版的linux, 感覺還不錯, 畫面也是很有善,想起十幾年前的linux,可真是hacker 在玩的,沒有資源,就是一堆英文文件,畫面也是醜醜的,經過這麼多年的演化,
大家應該可以把linux 直接當個人電腦使用了.
virtual box :http://www.virtualbox.org/
Ubuntu :http://www.ubuntu.org.tw/