tag:blogger.com,1999:blog-73721983576915576422024-03-13T07:56:56.023-07:00我已找到生命的真實義,有了感恩與平靜家欣的網誌Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-7372198357691557642.post-18035875952280440092019-04-26T04:06:00.001-07:002019-04-26T04:07:28.450-07:00iM短影邀請碼:1566741,最高賺$80/位我的iM短影邀請碼:1566741,最高賺$80/位<br />
<br />
問於答請見 <a href="https://www.facebook.com/notes/im%E7%9F%AD%E5%BD%B1/%E7%8E%A9im%E7%9F%AD%E5%BD%B1%E8%B3%BA%E7%8F%BE%E9%87%91-%E5%B8%B8%E8%A6%8B%E5%95%8F%E9%A1%8C%E5%A4%A7%E5%BD%99%E6%95%B4-/1140147926151546/">https://www.facebook.com/notes/im%E7%9F%AD%E5%BD%B1/%E7%8E%A9im%E7%9F%AD%E5%BD%B1%E8%B3%BA%E7%8F%BE%E9%87%91-%E5%B8%B8%E8%A6%8B%E5%95%8F%E9%A1%8C%E5%A4%A7%E5%BD%99%E6%95%B4-/1140147926151546/</a><br />
<br />
<br />
<br />Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-65831788977127730972018-07-18T23:12:00.000-07:002018-07-19T11:16:41.082-07:00原來Youtube也有#Hashtag功能,為你的影片加上hashtag!<div class="separator" style="clear: both; text-align: left;">
今天在YouTube上聽歌時,驚然發現原來YouTube也有<span style="color: cyan;">#hashtag</span>(主題標記)功能!</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-2tEai4TOd0Q/W1ArRF4XwlI/AAAAAAAAJwY/PaCqQDT9VIEMbHAlYGXLUYD7lyJoQnMUQCLcBGAs/s1600/%25E6%2593%25B7%25E5%258F%2596.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="679" data-original-width="1060" height="408" src="https://3.bp.blogspot.com/-2tEai4TOd0Q/W1ArRF4XwlI/AAAAAAAAJwY/PaCqQDT9VIEMbHAlYGXLUYD7lyJoQnMUQCLcBGAs/s640/%25E6%2593%25B7%25E5%258F%2596.JPG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
就趕快去研究了一下</div>
<div class="separator" style="clear: both; text-align: left;">
官方的說明可參考 <a href="https://support.google.com/youtube/answer/6390658">https://support.google.com/youtube/answer/6390658</a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
使用方法跟一般hashtag的用法一樣,在影片標題與內容時把要做hashtag的關鍵詞前加上一個"#"就可以了。</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-HnyFEOiR0fE/W1AritHmtPI/AAAAAAAAJwg/4_ICLiBC_14cHAtPexjM5cYCUWklEO7OgCLcBGAs/s1600/%25E6%2593%25B7%25E5%258F%25962.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="509" data-original-width="456" height="400" src="https://3.bp.blogspot.com/-HnyFEOiR0fE/W1AritHmtPI/AAAAAAAAJwg/4_ICLiBC_14cHAtPexjM5cYCUWklEO7OgCLcBGAs/s400/%25E6%2593%25B7%25E5%258F%25962.JPG" width="357" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
加了hashtag的好處,是hashtag會顯示為連結的形式,點選後就直接前往該hashtag的搜尋結果頁面,查看更多相關影片。也就是說使用者不用麻煩地到搜訊列上面再打字,可以依你hashtag的引導去找更多相關影片囉!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
注意以下:</div>
<div class="separator" style="clear: both; text-align: left;">
1. hashtag<span style="color: red;">不支援空格</span>,空格以及空格後的文字會被忽略。</div>
<div class="separator" style="clear: both; text-align: left;">
2. 一部影片的hashtag不能超過 <span style="color: red;">15 個</span>,超過系統就會忽略該影片的所有標記,因此要斟酌使用喔!</div>
<div class="separator" style="clear: both; text-align: left;">
3. 若標題和內文都使用hashtag,只有標題的hashtag會被顯示出來在標題中,內文的hashtag在內文還是有但不會顯示在影片標題上(如第一張圖)。</div>
<div class="separator" style="clear: both; text-align: left;">
4. 使用誤導或不當內容的hashtag可能會導致影片被移除。</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
來吧,也為你的影片加上<span style="color: cyan;">#hashtag</span>增加友善度和曝光度吧!</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-27416663660053989522016-03-22T06:28:00.003-07:002016-03-22T06:34:30.504-07:00【好康!】打卡送市價$250 Biotta瑞士有機蔬果汁!到2016/3月底好康道相報~~<br />
<div>
因為老闆娘是我的朋友,才會知道這麼好的免費消息</div>
<div>
在這邊分享給大家 :D</div>
<div>
<br /></div>
<div>
即日起到2016年3月底止,到全台「無毒的家」任一家分店</div>
<div>
1. 在「Biotta 百奧維他 瑞士有機蔬果汁」的FB粉絲頁按讃</div>
<div>
2. 打卡上傳與Biotta 百奧維他 瑞士有機蔬果汁的合照,並標註#lovebiotta</div>
<div>
3. 完成即可免費獲得一瓶「Biotta 百奧維他 布魯士根莖蔬果汁」市價$250!同時還可享買一箱送一箱,以及抽獎活動<br />
<br />
就像這樣<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.imgur.com/IJyEGpF.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://i.imgur.com/IJyEGpF.jpg" height="200" width="150" /></a></div>
<br /></div>
<div>
<br /></div>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
官方活動頁面 <a href="http://www.yogi-house.com/promotion.php?id=26">http://www.yogi-house.com/promotion.php?id=26</a></div>
<div>
<br /></div>
<div>
我是到無毒的家 竹北文興店</div>
<div>
地址:302新竹市竹北市文興路一段362號 (近竹北高鐵站,在文興路麥當勞旁)<br />
營業時間:周一~周六 9:00~21:00</div>
<div>
<iframe allowfullscreen="" frameborder="0" height="450" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d115891.91542795043!2d120.9616266494013!3d24.808381695252603!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x346836557652a09b%3A0xb91295cd57e4ed52!2z54Sh5q-S55qE5a625paH6IiI5bqX!5e0!3m2!1szh-TW!2stw!4v1458653226135" style="border: 0;" width="600"></iframe>
</div>
Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-5985506887287586812015-06-27T10:25:00.001-07:002015-06-27T10:53:36.481-07:00[C & C++]個人推薦好用語法 & 技巧筆記(此文章會不定時更新)<br />
<ul>
</ul>
<h3>
<b>初始化陣列</b></h3>
<ul>
</ul>
與其用 <br />
<span style="color: orange;"><i><b>for(int i=0; i < size; i++) { array[i] = 0; }</b></i></span><br />
不如用
<br />
<span style="color: orange;"><i><b>for(int & val : array) { val = 0; }</b></i></span><br />
就不用理陣列的大小,當然vector更是方便<br />
<br />
<ul>
</ul>
<h3>
Vector用法</h3>
基本用法<br />
<ul>
<li>宣告:<b><i><span style="color: orange;">vector<int</span></i></b><b><i><span style="color: orange;"><b><i><span style="color: orange;">></span></i></b> array;</span></i></b></li>
<li>二維陣列+初始化:</li>
</ul>
<div style="text-align: left;">
<span style="color: orange;"><i><b> vector</b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"><span style="color: orange;"><i><b><b><i><span style="color: orange;"><</span></i></b></b></i></span></span></i></b>vector</b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"><int</span></i></b><b><i><span style="color: orange;"><b><i><span style="color: orange;">></span></i></b></span></i></b> </b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"><b><i><span style="color: orange;">></span></i></b></span></i></b> array; //注意</b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"> >要有一個空白</span></i></b></b></i></span></div>
<div style="text-align: left;">
<span style="color: orange;"><i><b> array.resize(y, vector</b></i></span><b><i><span style="color: orange;"><int</span></i></b><b><i><span style="color: orange;"><b><i><span style="color: orange;">>(x, 0));</span></i></b></span></i></b></div>
<div style="text-align: left;">
或直接</div>
<div style="text-align: left;">
<div style="text-align: left;">
<span style="color: orange;"><i><b> vector</b></i></span><span style="color: orange;"><i><b><span style="color: orange;"><i><b><b><i><span style="color: orange;"><</span></i></b></b></i></span>vector</b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"><int</span></i></b><b><i><span style="color: orange;"><b><i><span style="color: orange;">></span></i></b></span></i></b> </b></i></span><span style="color: orange;"><i><b><b><i><span style="color: orange;"><b><i><span style="color: orange;">></span></i></b></span></i></b> array(y, vector</b></i></span><b><i><span style="color: orange;"><int</span></i></b><b><i><span style="color: orange;"><b><i><span style="color: orange;">>(x, 0));</span></i></b></span></i></b></div>
</div>
<ul>
</ul>
Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-4052915130879681572015-02-12T20:31:00.002-08:002015-06-27T10:28:15.393-07:00賀!總瀏覽數破萬!<br />
今早忽然發現,部落格總瀏覽數破萬啦! ヽ(∀゚ )人(゚∀゚)人( ゚∀)人(∀゚ )人(゚∀゚)人( ゚∀)ノ<br />
特地截圖做紀念<br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-PdhOqVFPL0I/VN1-4ynh6yI/AAAAAAAAGVo/_9KB5_noYjY/s1600/%E7%80%8F%E8%A6%BD%E6%95%B8%E7%A0%B4%E8%90%AC.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="492" src="http://1.bp.blogspot.com/-PdhOqVFPL0I/VN1-4ynh6yI/AAAAAAAAGVo/_9KB5_noYjY/s1600/%E7%80%8F%E8%A6%BD%E6%95%B8%E7%A0%B4%E8%90%AC.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<a href="https://www.blogger.com/blogger.g?blogID=7372198357691557642" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>雖然只是個小小的部落格,也很少更新 <br />
還是十分感謝網友們的支持<br />
<img src="http://dl.stickershop.line.naver.jp/products/0/0/9/617/android/stickers/5792.png" id="irc_mi" style="margin-top: 133px;" /> <br />
(圖片來源:<a href="http://dl.stickershop.line.naver.jp/products/0/0/9/617/android/stickers/5792.png" target="_blank">四葉妹妹LINE貼圖</a>)Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-48021110774906680602015-02-02T02:32:00.002-08:002015-03-13T20:53:35.606-07:00[鍵盤] 太豪PBT二色鍵帽114鍵 開箱本文同步發表在PTT鍵鼠版<br />
<a href="https://www.ptt.cc/bbs/Key_Mou_Pad/M.1422868226.A.5EB.html">https://www.ptt.cc/bbs/Key_Mou_Pad/M.1422868226.A.5EB.html</a><br />
<br />
因為沒有專業相機,手機拍畫質不好請見諒。我是1/31號在露天下標,很快今天2/2就在超商收到貨囉!<br />
拆外盒沒什麼好看的... 直接進入主題吧!<br />
<br />
<a href="http://i.imgur.com/6x2NMX1.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/6x2NMX1.jpg" height="360" width="640" /></div>
精美的包裝盒,寫著此鍵帽是PBT二色射出成型,可用在Cherry MX軸的機械式鍵盤,並有奈米抗菌技術<br />
<br />
<a name='more'></a><br />
<br />
<a href="http://i.imgur.com/8TUk1pX.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/8TUk1pX.jpg" height="320" width="240" /></div>
MADE IN TAIWAN(<a href="http://www.tai-hao.com/chinese/company.htm" target="_blank">太豪公司網站</a>)<br />
<br />
<a href="http://i.imgur.com/SqIsva2.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/SqIsva2.jpg" height="480" width="640" /></div>
打開了,我買的是114鍵版本,為了要換那有特殊長度按鍵的鍵盤...<br />
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/wOg7uPX.jpg" height="240" width="320" /></div>
拿起一顆按鍵來看看,這就是二色成型呀~參考<a href="http://www.techbang.com/posts/20943-you-may-not-know-the-keyboard-knowledge-iii-discussion-on-small-details-of-keycap-replacement-diy-on-their-own-computer-king-124-in-november-2014-expert-views?page=2" target="_blank">老貓文章</a>的介紹,以這顆黑橘色為例,第一輪黑色塑料字體成形,第二輪注入橘色塑料填充滿完整鍵帽,成品外層是有顆粒感的。<br />
<br />
<a href="http://i.imgur.com/SKj5F9S.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/SKj5F9S.jpg" height="480" width="640" /></div>
這是我目前用的鍵盤,<a href="http://gaming.coolermaster.com/tw/products/keyboards/quickfiretk/" target="_blank">CM Quickfire TK</a>白色極地版(紅軸)<br />
<br />
<a href="http://i.imgur.com/TAWKbGr.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/TAWKbGr.jpg" height="400" width="300" /></div>
凸字排列方向鍵結合數字區,這個創新設計想用80%上打100%鍵盤,用了一兩週後開始適應了。
我的前一支也是第一支機械式鍵盤,也是80%的大小,用了應該有五年吧,最特別是它是日文鍵盤,按鍵有些不同讓我當初動了些手工...這個之後再來po一篇文。但黑軸讓我長時間的寫程式和打字的手,實在有點受不了了。後來試打後決定要這把CM紅軸,感恩版友用很棒的價錢賣給我。<br />
<br />
換鍵帽前先來跟原本的鍵帽超級比一比<br />
<br />
<a href="http://i.imgur.com/6ICdpLh.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/6ICdpLh.jpg" height="124" width="320" /></div>
高度是一樣的<br />
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/36UFgEK.jpg" height="198" width="320" /></div>
手指接觸面比較,寬度太豪的較CM來得窄一點,大約是17 vs. 17.5mm。長度的話則是太
豪的比較長,大約是20 vs. 18.5mm。這張照片也能看到兩種鍵帽coating的不同,相對太
豪的細顆粒感,CM的很平滑(註:<a href="http://gaming.coolermaster.com/tw/products/keyboards/quickfirext/" target="_blank">Quickfire XT</a>的話則也是有顆粒的)。<br />
<a href="http://i.imgur.com/ukApVxj.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/ukApVxj.jpg" height="200" width="183" /></div>
疊起來也可以看出長度的差別。上:太豪,下:CM
為什麼想換鍵帽呢?主要有幾個原因:
1. CM原廠是ABS材質,很容易打起來油油的,表面的平滑更增加這種油膩感。<br />
2. 好奇想試試PBT,而且黑橘很好看不是嗎~~~<br />
3. 本人是喜歡英刻的,看起來簡潔。原廠鍵帽不僅有注音還有我根本不會用到的倉頡...<br />
<br />
而且這支鍵盤讓我有了以下體驗和推論:
在無法完全盲打的條件下(我是接近盲打但有時還是要瞄一下),用100%大小鍵盤時,即便也有注音倉頡用起來也是很順暢,因為體積關係,眼睛一次注意到的是鍵盤的一個區域
。但鍵盤體積縮小後,一眼看過去就是大部分或整個鍵盤,此時視線內的資訊量太多,令人有點眼花撩亂無法迅速找到字或按鍵切換狀況。<br />
<br />
CM TK包含注音倉頡,方向鍵和數字鍵又需要切換,代表切換的Numlock燈不在按鍵上
而在更遠的右上角,然後極地版剛好是白色殼配白光...一再再加重這現象...囧<br />
<br />
因此我會想建議,鍵盤體積越小,字體要儘量越簡單越好,讓找字能迅速順利,來提昇打字的體驗與速度,搞不好再利用體積的優勢,甚至更勝於全尺寸鍵盤咧(或許)<br />
<br />
回到正題,轉眼間已經換一半啦(明明就是事後圖... )
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/8BwoyfD.jpg" height="480" width="640" /></div>
中間過程留作紀念<br />
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/CZ45ksq.jpg" height="300" width="400" /></div>
空白鍵 特規,殘念...<br />
<br />
<a href="http://i.imgur.com/cLtm1GW.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/cLtm1GW.jpg" height="360" width="640" /></div>
完成圖,新裝上陣囉!<br />
數字區因為數字和功能鍵的組合是特規,我沒記起來所以不敢換,只換掉方向鍵,方向鍵
切換後的0和2和. (英文句號)應該不會忘。F1~F12搭配Fn的功能平常沒再用,安心換掉。
Win key是特規只有一般按鍵大小,因此換成無刻。<br />
<br />
2/7更新:<br />
版友建議可以把數字鍵直接換成功能鍵,換完之後的確不錯,更好看<br />
缺點是那六個功能鍵高度會凸起,但不影響手感<br />
現在就改成這樣用,不過數字鍵盲打真的還不是很熟<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-CLmxAno5-e4/VNY9yXRRXWI/AAAAAAAAGHY/zbqMVa9JY94/s1600/IMG_20150207_020621%5B1%5D.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-CLmxAno5-e4/VNY9yXRRXWI/AAAAAAAAGHY/zbqMVa9JY94/s1600/IMG_20150207_020621%5B1%5D.jpg" height="360" width="640" /></a></div>
<br />
<br />
鍵帽本身不透光,但原本白光經過反射後,在白色底殼上呈現淡橘色光了耶...<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/KG2VsKT.jpg" height="360" width="640" /></div>
LED全亮的樣子 <br />
<br />
結論<br />
初體驗PBT的鍵帽,的確比原廠ABS手感好,但看著新的版面找字竟然有點不適應哈哈。這是本人在PTT鍵鼠版第一次跳坑+發文(還沒自介咧... ),謝謝PTT鍵鼠版。看著看著對側刻同刻鍵帽開始有興趣了...<br />
<br />
附錄:贈送的隨機鍵帽是數字7,可惜我用win8.1...哈哈<a href="http://i.imgur.com/OKbyTqq.jpg" rel="nofollow" target="_blank"></a>
<br />
<div class="richcontent">
<img alt="" src="http://i.imgur.com/OKbyTqq.jpg" height="360" width="640" /></div>
Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-29772398768442376482013-10-26T13:35:00.000-07:002013-10-27T22:52:54.556-07:00[轉貼]一個Sqrt函數引發的血案轉自<a href="http://kb.cnblogs.com/page/189867/">http://kb.cnblogs.com/page/189867/</a><br />
講到當年Quake-III中一段開平方根的函數,竟然比系統內建sqrt()還要快!<br />
我覺得它的設計原理可以給重視運算速度的programmer有很大的啟發 :)<br />
<br />
<br />
好吧,我承認我標題黨了,不過既然你來了,就認真看下去吧,保證你有收穫。<br />
我們平時經常會有一些數據運算的操作,需要調用sqrt,exp,abs等函數,那麼時候你有沒有想過:這個些函數係統是如何實現的?就拿最常用的sqrt函數來說吧,系統怎麼來實現這個經常調用的函數呢?<br />
<a name='more'></a> 雖然有可能你平時沒有想過這個問題,不過正所謂是“臨陣磨槍,不快也光”,你“眉頭一皺,計上心來”,這個不是太簡單了嘛,用二分的方法,在一個區間中,每次拿中間數的平方來試驗,如果大了,就再試左區間的中間數;如果小了,就再拿右區間的中間數來試。比如求sqrt(16)的結果,你先試(0+16)/2=8,8*8=64,64比16大,然後就向左移,試(0+8)/2=4, 4*4=16剛好,你得到了正確的結果sqrt(16)=4。然後你三下五除二就把程序寫出來了:<br />
<br />
<center>
<table 408px="" border="1" cellpadding="10"><tbody>
<tr><td><pre><span style="color: blue;">float</span> SqrtByBisection(<span style="color: blue;">float</span> n) <span style="color: green;">//</span><span style="color: green;">用二分法</span>
{
<span style="color: blue;">if</span>(n<<span style="color: purple;">0</span>) <span style="color: green;">//</span><span style="color: green;">小於0的按照你需要的處理 </span>
<span style="color: blue;">return</span> n;
<span style="color: blue;">float</span> mid,last;
<span style="color: blue;">float</span> low,up;
low=<span style="color: purple;">0</span>, up=n;
mid=(low+up)/<span style="color: purple;">2</span>;
<span style="color: blue;">do</span>
{
<span style="color: blue;">if</span>(mid*mid>n)
up=mid;
<span style="color: blue;">else</span>
low=mid;
last=mid;
mid=(up+low)/<span style="color: purple;">2</span>;
}<span style="color: blue;">while</span>(abs(mid-last) > eps);<span style="color: green;">//</span><span style="color: green;">精度控制</span>
<span style="color: blue;">return</span> mid;
}</pre>
</td></tr>
</tbody></table>
</center>
<br />
然後看看和系統函數性能和精度的差別(其中時間單位不是秒也不是毫秒,而是CPU Tick,不管單位是什麼,統一了就有可比性)
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://pic002.cnblogs.com/images/2010/160962/2010100617115874.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://pic002.cnblogs.com/images/2010/160962/2010100617115874.png" /></a></div>
從圖中可以看出,二分法和系統的方法結果上完全相同,但是性能上整整差了幾百倍。為什麼會有這麼大的區別呢?難道系統有什麼更好的辦法?難道。。。。哦,對了,回憶下我們曾經的高數課,曾經老師教過我們“牛頓迭代法快速尋找平方根”,或者這種方法可以幫助我們,具體步驟如下:<br />
<div style="background-color: #f1f1f1; border: #e1e1e1 1px solid; color: black; margin: 8px; padding: 5px;">
求出根號a的近似值:首先隨便猜一個近似值x,然後不斷令x等於x和a/x的平均數,反覆運算個六七次後x的值就已經相當精確了。 <br />
例如,我想求根號2等於多少。假如我猜測的結果為4,雖然錯的離譜,但你可以看到使用牛頓反覆運算法後這個值很快就趨近於根號2了: <br />
(4 + 2/4) / 2 = 2.25 <br />
(2.25 + 2/2.25) / 2 = 1.56944.. <br />
(1.56944.. + 2/1.56944..) / 2 = 1.42189.. <br />
(1.42189.. + 2/1.42189..) / 2 = 1.41423.. <br />
.... <a href="http://diducoder.com/sotry-about-sqrt.html"><img alt="" src="http://pic002.cnblogs.com/images/2010/160962/2010100617122297.gif" style="display: block; margin-left: auto; margin-right: auto;" /></a> <br />
這種演算法的原理很簡單,我們僅僅是不斷用(x,f(x))的切線來逼近方程x^2-a=0的根。根號a實際上就是x^2-a=0的一個正實根,這個函數的導數是2x。也就是說,函數上任一點(x,f(x))處的切線斜率是2x。那麼,x-f(x)/(2x)就是一個比x更接近的近似值。代入 f(x)=x^2-a得到x-(x^2-a)/(2x),也就是(x+a/x)/2。</div>
相關的代碼如下:<br />
<br />
<center>
<table border="1" cellpadding="10" style="width: 300px;"><tbody>
<tr><td><pre><span style="color: blue;">float</span> SqrtByNewton(<span style="color: blue;">float</span> x)
{
<span style="color: blue;">float</span> val = x; <span style="color: green;">//</span><span style="color: green;">最终</span>
<span style="color: blue;">float</span> last; <span style="color: green;">//</span><span style="color: green;">保存上一個計算的值</span>
<span style="color: blue;">do</span>
{
last = val;
val = (val + x/val) / <span style="color: purple;">2</span>;
}<span style="color: blue;">while</span>(abs(val-last) > eps);
<span style="color: blue;">return</span> val;
}</pre>
</td></tr>
</tbody></table>
</center>
<br />
然後我們再來看下性能測試:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://pic002.cnblogs.com/images/2010/160962/2010100617123967.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://pic002.cnblogs.com/images/2010/160962/2010100617123967.png" /></a></div>
哇塞,性能提高了很多,可是和系統函數相比,還是有這麼大差距,這是為什麼呀?想啊想啊,想了很久仍然百思不得其解。突然有一天,我在網上看到一個神奇的方法,於是就有了今天的這篇文章,廢話不多說,看代碼先:<br />
<br />
<center>
<table border="1" cellpadding="10" style="width: 300px;"><tbody>
<tr><td><pre><span style="color: blue;">float</span> InvSqrt(<span style="color: blue;">float</span> x)
{
<span style="color: blue;">float</span> xhalf = <span style="color: purple;">0.5f</span>*x;
<span style="color: blue;">int</span> i = *(<span style="color: blue;">int</span>*)&x; <span style="color: green;">//</span><span style="color: green;"> get bits for floating VALUE </span>
i = <span style="color: purple;">0x5f375a86</span>- (i>><span style="color: purple;">1</span>); <span style="color: green;">//</span><span style="color: green;"> gives initial guess y0</span>
x = *(<span style="color: blue;">float</span>*)&i; <span style="color: green;">//</span><span style="color: green;"> convert bits BACK to float</span>
x = x*(<span style="color: purple;">1.5f</span>-xhalf*x*x); <span style="color: green;">//</span><span style="color: green;"> Newton step, repeating increases accuracy</span>
x = x*(<span style="color: purple;">1.5f</span>-xhalf*x*x); <span style="color: green;">//</span><span style="color: green;"> Newton step, repeating increases accuracy</span>
x = x*(<span style="color: purple;">1.5f</span>-xhalf*x*x); <span style="color: green;">//</span><span style="color: green;"> Newton step, repeating increases accuracy</span>
<span style="color: blue;">return</span> <span style="color: purple;">1</span>/x;
}</pre>
</td></tr>
</tbody></table>
</center>
<br />
然後我们最後一次来看下性能測試:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://pic002.cnblogs.com/images/2010/160962/2010100617125422.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://pic002.cnblogs.com/images/2010/160962/2010100617125422.png" /></a></div>
這次真的是質變了,結果竟然比系統的還要好。。。哥真的是震驚了!!!哥吐血了!!!一個函數引發了血案!!!血案,血案。。。<br />
到現在你是不是還不明白那個“鬼函數”,到底為什麼速度那麼快嗎?不急,先看看下面的故事吧:<br />
<div style="background-color: #ecf4fc; border: #c3e3ee 1px solid; color: black; margin: 8px; padding: 5px;">
Quake-III Arena (雷神之錘3)是90年代的經典遊戲之一。該系列的遊戲不但畫面和內容不錯,而且即使電腦配置低,也能極其流暢地運行。這要歸功於它3D引擎的開發者約翰·卡馬克(John Carmack)。事實上早在90年代初DOS時代,只要能在PC上搞個小動畫都能讓人驚歎一番的時候,John Carmack就推出了石破天驚的Castle Wolfstein,然後再接再勵,doom, doomII, Quake...每次都把3-D技術推到極致。他的3D引擎代碼資極度高效,幾乎是在壓榨PC機的每條運算指令。當初MS的Direct3D也得聽取他的意見,修改了不少API。<br />
最近,QUAKE的開發商ID SOFTWARE 遵守GPL協議,公開了QUAKE-III的原代碼,讓世人有幸目睹Carmack傳奇的3D引擎的原碼。這是QUAKE-III原代碼的下載位址: <br />
<a href="http://www.fileshack.com/file.x?fid=7547">http://www.fileshack.com/file.x?fid=7547</a><br />
(下麵是官方的下載網址,搜索 “quake3-1.32b-source.zip” 可以找到一大堆中文網頁的。<a href="ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip)">ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip)</a><br />
我們知道,越底層的函數,調用越頻繁。3D引擎歸根到底還是數學運算。那麼找到最底層的數學運算函數(在game/code/q_math.c), 必然是精心編寫的。裡面有很多有趣的函數,很多都令人驚奇,估計我們幾年時間都學不完。在game/code/q_math.c裡發現了這樣一段代碼。它的作用是將一個數開平方並取倒,經測試這段代碼比(float)(1.0/sqrt(x))快4倍:<br />
<center>
<table border="1" cellpadding="20" style="width: 300px;"><tbody>
<tr><td><pre><span style="color: blue;">float</span> Q_rsqrt( <span style="color: blue;">float</span><span style="color: black;"> number )
{
</span><span style="color: blue;">long</span><span style="color: black;"> i;
</span><span style="color: blue;">float</span><span style="color: black;"> x2, y;
</span><span style="color: blue;">const</span> <span style="color: blue;">float</span> threehalfs = <span style="color: purple;">1.5F</span><span style="color: black;">;
x2 </span>= number * <span style="color: purple;">0.5F</span><span style="color: black;">;
y </span>=<span style="color: black;"> number;
i </span>= * ( <span style="color: blue;">long</span> * ) &y; <span style="color: green;">//</span><span style="color: green;"> evil floating point bit level hacking</span>
i = <span style="color: purple;">0x5f3759df</span> - ( i >> <span style="color: purple;">1</span> ); <span style="color: green;">//</span><span style="color: green;"> what the fuck?</span>
y = * ( <span style="color: blue;">float</span> * ) &<span style="color: black;">i;
y </span>= y * ( threehalfs - ( x2 * y * y ) ); <span style="color: green;">//</span><span style="color: green;"> 1st iteration</span>
<span style="color: green;">//</span><span style="color: green;">y = y * ( threehalfs - ( x2 * y * y ) ); </span><span style="color: green;">//</span><span style="color: green;"> 2nd iteration,
this can be removed</span>
<span style="color: black;">
#ifndef Q3_VM
#ifdef __linux__
assert( </span>!isnan(y) ); <span style="color: green;">//</span><span style="color: green;"> bk010122 - FPE?</span>
<span style="color: blue;">#endif</span>
<span style="color: blue;">#endif</span>
<span style="color: blue;">return</span><span style="color: black;"> y;
} </span></pre>
</td></tr>
</tbody></table>
</center>
<span style="line-height: 1.8;">函數返回1/sqrt(x),這個函數在影像處理中比sqrt(x)更有用。 </span><br />
注意到這個函數只用了一次疊代!(其實就是根本沒用疊代,直接運算)。編譯,實驗,這個函數不僅工作的很好,而且比標準的sqrt()函數快4倍!要知道,編譯器自帶的函數,可是經過嚴格仔細的彙編優化的啊!<br />
這個簡潔的函數,最核心,也是最讓人費解的,就是標注了“what the fuck?”的一句:<br />
<div class="cnblogs_code">
<pre> i = <span style="color: purple;">0x5f3759df</span> - ( i >> <span style="color: purple;">1</span> );</pre>
</div>
<span style="line-height: 1.8;">再加上:</span><br />
<div class="cnblogs_code">
<pre>y = y * ( threehalfs - ( x2 * y * y ) ); </pre>
</div>
<span style="line-height: 1.8;">兩句話就完成了開方運算!而且注意到,核心那句是定點移位元運算,速度極快!特別在很多沒有乘法指令的RISC結構CPU上,這樣做是極其高效的。</span><br />
演算法的原理其實不複雜,就是牛頓反覆運算法,用x-f(x)/f'(x)來不斷的逼近f(x)=a的根。<br />
沒錯,一般的求平方根都是這麼迴圈反覆運算算的,但是卡馬克(quake3作者)真正牛B的地方是他選擇了一個神秘的常數 0x5f3759df 來計算那個猜測值,就是我們加注釋的那一行,那一行算出的值非常接近1/sqrt(n),這樣我們只需要2次牛頓反覆運算就可以達到我們所需要的精度。好吧如果這個還不算NB,接著看:<br />
普渡大學的數學家Chris Lomont看了以後覺得有趣,決定要研究一下卡馬克弄出來的這個猜測值有什麼奧秘。Lomont也是個牛人,在精心研究之後從理論上也推導出一個最佳猜測值,和卡馬克的數字非常接近,0x5f37642f。卡馬克真牛,他是外星人嗎?<br />
傳奇並沒有在這裡結束。Lomont計算出結果以後非常滿意,於是拿自己計算出的起始值和卡馬克的神秘數字做比賽,看看誰的數字能夠更快更精確的求得平方根。結果是卡馬克贏了... 誰也不知道卡馬克是怎麼找到這個數字的。<br />
最後Lomont怒了,採用暴力方法一個數位一個數位試過來,終於找到一個比卡馬克數字要好上那麼一丁點的數字,雖然實際上這兩個數字所產生的結果非常近似,這個暴力得出的數字是0x5f375a86。<br />
Lomont為此寫下一篇論文,"Fast Inverse Square Root"。 論文下載地址: <br />
<a href="http://www.math.purdue.edu/%7Eclomont/Math/Papers/2003/InvSqrt.pdf">http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf</a> <br />
<a href="http://www.matrix67.com/data/InvSqrt.pdf">http://www.matrix67.com/data/InvSqrt.pdf</a><br />
參考:<IEEE Standard 754 for Binary Floating-Point Arithmetic><FAST INVERSE SQUARE ROOT><br />
最後,給出最精簡的1/sqrt()函數:<br />
<center>
<table border="1" cellpadding="20"><tbody>
<tr><td><pre><span style="color: blue;">float</span> InvSqrt(<span style="color: blue;">float</span><span style="color: black;"> x)
{
</span><span style="color: blue;">float</span> xhalf = <span style="color: purple;">0.5f</span>*<span style="color: black;">x;
</span><span style="color: blue;">int</span> i = *(<span style="color: blue;">int</span>*)&x; <span style="color: green;">//</span><span style="color: green;"> get bits for floating VALUE </span>
i = <span style="color: purple;">0x5f375a86</span>- (i>><span style="color: purple;">1</span>); <span style="color: green;">//</span><span style="color: green;"> gives initial guess y0</span>
x = *(<span style="color: blue;">float</span>*)&i; <span style="color: green;">//</span><span style="color: green;"> convert bits BACK to float</span>
x = x*(<span style="color: purple;">1.5f</span>-xhalf*x*x); <span style="color: green;">//</span><span style="color: green;"> Newton step, repeating increases accuracy</span>
<span style="color: blue;">return</span><span style="color: black;"> x;
} </span></pre>
</td></tr>
</tbody></table>
</center>
<span style="line-height: 1.8;">大家可以嘗試在PC機、51、AVR、430、ARM、上面編譯並實驗,驚訝一下它的工作效率。</span><br />
前兩天有一則新聞,大意是說 Ryszard Sommefeldt 很久以前看到這麼樣的一段 code (可能出自 Quake III 的 source code):<br />
<center>
<table border="1" cellpadding="20"><tbody>
<tr><td><pre><span style="color: blue;">float</span> InvSqrt (<span style="color: blue;">float</span><span style="color: black;"> x)
{
</span><span style="color: blue;">float</span> xhalf = <span style="color: purple;">0.5f</span>*<span style="color: black;">x;
</span><span style="color: blue;">int</span> i = *(<span style="color: blue;">int</span>*)&<span style="color: black;">x;
i </span>= <span style="color: purple;">0x5f3759df</span> - (i>><span style="color: purple;">1</span><span style="color: black;">);
x </span>= *(<span style="color: blue;">float</span>*)&<span style="color: black;">i;
x </span>= x*(<span style="color: purple;">1.5f</span> - xhalf*x*<span style="color: black;">x);
</span><span style="color: blue;">return</span><span style="color: black;"> x;
}</span></pre>
</td></tr>
</tbody></table>
</center>
<span style="line-height: 1.8;">他一看之下驚為天人,想要拜見這位前輩高人,但是一路追尋下去卻一直找不到人;同時間也有其他人在找,雖然也沒找到出處,但是 Chris Lomont 寫了一篇論文 (in PDF) 解析這段 code 的演算法 (用的是 Newton’s Method,牛頓法;比較重要的是後半段講到怎麼找出神奇的 0x5f3759df 的)。 </span><br />
PS. 這個 function 之所以重要,是因為求“開根號倒數”這個動作在 3D 運算 (向量運算的部份) 裡面常常會用到,如果你用最原始的 sqrt() 然後再倒數的話,速度比上面的這個版本大概慢了四倍吧… XD <br />
PS2. 在他們追尋的過程中,有人提到一份叫做 MIT HACKMEM 的檔,這是 1970 年代的 MIT 強者們做的一些筆記 (hack memo),大部份是 algorithm,有些 code 是 PDP-10 asm 寫的,另外有少數是 C code (有人整理了一份列表)</div>
好了,故事就到這裡结束了,希望大家能有收獲:)<br />
<br />
p.s.感謝有人提供另一位文章,做了各種sqrt的速度及正確率比較:<br />
<a href="http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi">http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi</a>Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com3tag:blogger.com,1999:blog-7372198357691557642.post-45523920644198157392009-05-21T11:52:00.000-07:002009-07-18T20:06:02.400-07:00H.264研究未來題目<ol><li>Quantization using Hamming code</li><li>Chroma predict Luma, or Luma predict Chroma</li><li>Decoder-side MB partition derivation(context-adaptive & edge inpainting)</li><li>RDO cbp cleanup</li><li>Decoder-side partition derivation with pixel-wise true motion</li><li>Pixel reorganization for best matching H.264 integer transform<br /></li></ol>Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.comtag:blogger.com,1999:blog-7372198357691557642.post-62034027339342447972009-01-31T22:24:00.000-08:002009-05-01T21:04:34.370-07:00實驗室Server架設(3) 自動新增與用者及更改桌面我們已經把伺服器的服務都架設完畢 <br />接下來這篇的內容,是一些自動化的工作,包含: <br /><ol> <li>自動新增使用者 </li> <li>自動更改桌面到其使用者的共用桌面(在NAS上) </li> </ol> <p><span style="font-weight: bold; color: rgb(255, 0, 0);">自動新增使用者</span> <br />傳統的新增方法,是到Active Directory的設定中,按右鍵選新增->使用者 <br /><br />新增完後在使用者上按右鍵,選內容,再做其他設定 <br /><br />這樣每新增一個使用者,管理者就必須設定一次,太麻煩啦! <br />來寫個batch檔,讓新增使用者+設定只要一個步驟吧! <br />以下開始batch檔內容: </p> <table border="1" cellpadding="2" cellspacing="0"><tbody> <tr> <td valign="top"><span style="color: rgb(51, 204, 0);">更多dsadd user選項參考<a href="http://technet.microsoft.com/zh-tw/library/cc755811.aspx#BKMK_5">http://technet.microsoft.com/zh-tw/library/cc755811.aspx#BKMK_5</a></span> <br /> <br />@echo off <br />echo "Powered by terry0201" <br />: <a title="http://terry0201.blogspot.com/" href="http://terry0201.blogspot.com/">http://terry0201.blogspot.com/</a> <br />title MAPL Server使用者新增 <br /><span style="color: rgb(51, 204, 0);">:改視窗Title</span> <br />set user=0 <br /><span style="color: rgb(51, 204, 0);">:設定一個變數來存使用者名稱</span> <br />set /p user=新增使用者名稱: <br /><span style="color: rgb(51, 204, 0);">:出現"新增使用者名稱:"的對話,利用set /p將輸入的使用者名稱存到user變數中</span> <br />if %user%==0 goto end <br /><span style="color: rgb(51, 204, 0);">:如果沒輸入使用者名稱,就跳到結束區段</span> <br /> <br />dsadd user "cn=%user%, cn=Users, dc=mapl, dc=lab" -disabled no -mustchpwd yes -profile "\\mapl-test\Profiles\%user%" -hmdrv Z: -hmdir \\mapl_nas\MAPL -loscr "FolderRearrange.vbs" -memberof "cn=Domain Admins, cn=users, dc=mapl, dc=lab" <br /><span style="color: rgb(51, 204, 0);">:新增使用者指令</span> <span style="color: rgb(51, 204, 0);">:新增使用者"%user%"在Users的group(-cn),屬於mapl.lab網域(-dc)</span> <br /><span style="color: rgb(51, 204, 0);">:-disable no 帳號可登入</span> <span style="color: rgb(51, 204, 0);">:-mustchpwd yes 因為不預設密碼,所以設定讓使用者第一次登入,需要變更(建立)自己的密碼</span> <br /><span style="color: rgb(51, 204, 0);">:-profile 設定user profile存放的位置</span> <br /><span style="color: rgb(51, 204, 0);">:-hmdrv -hmdir 設定home drive & home dir,讓網路硬碟自動掛載進來(沒確定是否有效)</span> <br /><span style="color: rgb(51, 204, 0);">:-loscr 登入自動執行script的名稱(放在網域控制站\NETLOGON目錄下)</span> <br /><span style="color: rgb(51, 204, 0);">:-memberof 指定該使用者加入之群組,給予應有的權限 </span> <br /> <br />echo 新增完成! <br />pause <br />exit <br /> <br />:end <br />echo 未新增,bye bye <br /><span style="color: rgb(51, 204, 0);">:未輸入使用者名稱的結束區段</span> <br />pause <br /></td> </tr> </tbody></table> <p> <br /><strong><span style="color: rgb(255, 0, 0);">自動更改桌面Script</span></strong></p> <p>上面提到的,登入自動執行script,在每次使用者登入時,都會自動去<span style="color: rgb(0, 0, 255);">把NAS作為網路硬碟掛載進來</span>,然後在修改Windows登錄檔,<span style="color: rgb(0, 0, 255);">將使用者的桌面指到NAS中對應的資料夾</span>(實驗發現每台電腦修改一次就夠)</p><p>這裡因為要修改登錄檔,用VB Script來實做。記得這個script要<span style="color: rgb(0, 0, 255);">放在網域控制站的NETLOGON資料夾中</span>,然後在新增使用者時設定logon script</p> <table width="" border="1" cellpadding="2" cellspacing="0"><tbody> <tr> <td valign="top" width=""> <p>'Powered by terry0201 <br />' <a title="http://terry0201.blogspot.com/" href="http://terry0201.blogspot.com/">http://terry0201.blogspot.com/</a> <br />'搬移使用者資料夾(桌面等)Script <br />'請放在 \\網域控制站\netlogon 下 </p> <p>Dim WshShell, Shell, obj <br />Dim Desktop </p> <p>Set WshShell=wscript.CreateObject("Wscript.Shell") <br />Set Shell = WScript.CreateObject ("Shell.Application") <br />Set obj = WScript.CreateObject("WScript.Shell") </p> <p>'掛載網路硬碟 <br />'obj.Run "net use Z: /delete" <br />'obj.Run "net use Z: \\mapl_nas\mapl" </p> <p>'設定使用者桌面 <br />Desktop = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop") <br />If str = "Z:\%USERNAME%" Then </p> <p>else <br />WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop", "Z:\%USERNAME%", "REG_SZ" <br />'MsgBox "資料夾設定已更改,請重新登入" <br />'obj.Run "logoff" <br />end if</p> </td> </tr> </tbody></table> <p>自動化工作就是以上這些。到這裡Server架設,及網域使用者環境都完成,接下來就可以新增電腦跟使用者到這網域中囉!(見下一篇) </p>Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-12093366620797512252009-01-31T05:28:00.000-08:002009-07-20T22:27:29.147-07:00實驗室Server架設(2) 對外Window Server 2003設置之前提到,對外一台Windows Server 2003機器負責網域的服務,包括<br /><ol><li dragover="true">建立mapl.lab的網域</li><li dragover="true">新增mapl.lab網域的使用者</li><li dragover="true">外面連線進來遠端或FTP的port Mapping</li></ol>其實要完成這些,就大約相等於基礎Windows Server 2003網域架設,主要包含以下服務:<ol><li>AD(Active Directory) -- 提供及管理網域服務</li><li>DNS -- 提供網域內各主機的查詢</li><li>DHCP -- 區網內IP配置</li><li>防火牆 -- Port Mapping</li></ol>以下開始設定:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU48uVgm4I/AAAAAAAAA3A/mH0A2iKTlVg/s1600-h/3.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU48uVgm4I/AAAAAAAAA3A/mH0A2iKTlVg/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297703152552811394" border="0" /></a>這是2003伺服器管理主頁面,我們只要動上面三項<br /><span style="font-weight: bold; color: rgb(255, 0, 0);">Active Directory</span><br />請參考<a href="http://140.126.107.250/cswang/">CSWang's Homepage</a>中<a dragover="true" href="http://140.126.107.250/cswang/thit/Win2k/CreateAD.htm">Windows2003 網域建立</a> <span style="color: rgb(255, 0, 0);">(網站不見了)</span><br />重要步驟如下:<br />網域控制站類型:新網域的網域控制站<span style="font-weight: bold; color: rgb(51, 51, 255);"> -> </span>建立新的:網域<span dragover="true" style="font-weight: bold; color: rgb(51, 51, 255);"> </span><span dragover="true" style="font-weight: bold; color: rgb(51, 51, 255);">-> </span>新網域DNS名稱:mapl.lab(不要用.com之類已定義好的網域)<span style="font-weight: bold; color: rgb(51, 51, 255);"> -> </span>對內網路的DNS指向管理網域的DNS Server(這裡是自己)<br />開啟AD的管理介面<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRho-bVDAI/AAAAAAAAA14/bl6v1fJAYfQ/s1600-h/2.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 280px;" src="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRho-bVDAI/AAAAAAAAA14/bl6v1fJAYfQ/s400/2.GIF" alt="" id="BLOGGER_PHOTO_ID_5297466418274831362" border="0" /></a>網域中的電腦、使用者分別可在Computers, Users中檢視管理<br /><br />設定漫遊使用者設定檔資料夾<br />在本機新增一個資料夾,並分享<br />就會在網域控制站中看到此資料夾,新增使用者時就以此資料夾存放設定檔<br />參考<br /><a href="https://www.microsoft.com.nsatc.net/taiwan/technet/prodtechnol/windows2000serv/howto/userdata.aspx">https://www.microsoft.com.nsatc.net/taiwan/technet/prodtechnol/windows2000serv/howto/userdata.aspx</a><br /><a href="http://www.pmail.idv.tw/plog/index.php?load=read&id=503">http://www.pmail.idv.tw/plog/index.php?load=read&id=503</a><br /><br />若不設定使用者的設定檔存放位置<br />則使用者會已本機使用者身份登入<br />因此每台電腦都有這個使用者各自的設定檔(登入較快?)<br /><br /><span style="color: rgb(255, 0, 0); font-weight: bold;">DNS</span><br /><div dragover="true" style="text-align: center;"><a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRjU6W_GyI/AAAAAAAAA2A/_ELVP64KhAY/s1600-h/3.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 178px;" src="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRjU6W_GyI/AAAAAAAAA2A/_ELVP64KhAY/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297468272608746274" border="0" /></a>開啟DNS管理介面,設定DNS伺服器<a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRj9hOQzAI/AAAAAAAAA2I/_eg_i48ffbM/s1600-h/1.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRj9hOQzAI/AAAAAAAAA2I/_eg_i48ffbM/s400/1.GIF" alt="" id="BLOGGER_PHOTO_ID_5297468970235907074" border="0" /></a><a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRkAgjIdbI/AAAAAAAAA2Q/z5e8dnH4rZc/s1600-h/2.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRkAgjIdbI/AAAAAAAAA2Q/z5e8dnH4rZc/s400/2.GIF" alt="" id="BLOGGER_PHOTO_ID_5297469021594613170" border="0" /></a>要建立正向對應區域<a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYRkClZJy-I/AAAAAAAAA2Y/C6vc_JgTFFI/s1600-h/3.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYRkClZJy-I/AAAAAAAAA2Y/C6vc_JgTFFI/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297469057254673378" border="0" /></a><a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRk9hpgB8I/AAAAAAAAA2g/JejaO1hKiGM/s1600-h/1.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://1.bp.blogspot.com/_3ub81-nYq4E/SYRk9hpgB8I/AAAAAAAAA2g/JejaO1hKiGM/s400/1.GIF" alt="" id="BLOGGER_PHOTO_ID_5297470069861779394" border="0" /></a>輸入網域的名稱<a dragover="true" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRzi0_pXAI/AAAAAAAAA24/cN9uCiIIZ8g/s1600-h/2.GIF"><img dragover="true" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRzi0_pXAI/AAAAAAAAA24/cN9uCiIIZ8g/s400/2.GIF" alt="" id="BLOGGER_PHOTO_ID_5297486103872887810" border="0" /></a>我是看書上建議選"允許安全與非安全動態更新","允許安全性動態更新"看起來似乎也行<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRlCCL821I/AAAAAAAAA2w/mgbx9xXYM-k/s1600-h/3.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 287px;" src="http://3.bp.blogspot.com/_3ub81-nYq4E/SYRlCCL821I/AAAAAAAAA2w/mgbx9xXYM-k/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297470147315686226" border="0" /></a>因為不想增加Server 2003的負擔,使用轉寄查詢,網域內Domain Name的查詢當然還是由Server 2003負責。<br /><br /><div style="text-align: left;"><span style="font-weight: bold; color: rgb(255, 0, 0);">DHCP</span><br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU5c3hbwgI/AAAAAAAAA3I/dBJ8CRyJTXA/s1600-h/1.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 311px; height: 199px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU5c3hbwgI/AAAAAAAAA3I/dBJ8CRyJTXA/s400/1.GIF" alt="" id="BLOGGER_PHOTO_ID_5297703704774558210" border="0" /></a>開啟DHCP管理介面<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU5e92DyKI/AAAAAAAAA3Q/pxFDho3043A/s1600-h/2.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 348px; height: 331px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU5e92DyKI/AAAAAAAAA3Q/pxFDho3043A/s400/2.GIF" alt="" id="BLOGGER_PHOTO_ID_5297703740831418530" border="0" /></a>設定區網下面電腦的Private IP<br /><br /><div style="text-align: left; font-weight: bold; color: rgb(255, 0, 0);">NAT及防火牆<br /></div></div><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3ub81-nYq4E/SYU5g78QPyI/AAAAAAAAA3Y/5Pqqnbsbk5E/s1600-h/3.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 283px;" src="http://3.bp.blogspot.com/_3ub81-nYq4E/SYU5g78QPyI/AAAAAAAAA3Y/5Pqqnbsbk5E/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297703774680268578" border="0" /></a>開啟"管理VPN伺服器"<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU7gMrq2oI/AAAAAAAAA3g/PWvXH43Na5o/s1600-h/1.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 283px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU7gMrq2oI/AAAAAAAAA3g/PWvXH43Na5o/s400/1.GIF" alt="" id="BLOGGER_PHOTO_ID_5297705961017498242" border="0" /></a>選擇對外(Public IP)的連線按內容<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_3ub81-nYq4E/SYU7itRB0YI/AAAAAAAAA3o/rlJ4USwENuk/s1600-h/2.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 358px; height: 400px;" src="http://3.bp.blogspot.com/_3ub81-nYq4E/SYU7itRB0YI/AAAAAAAAA3o/rlJ4USwENuk/s400/2.GIF" alt="" id="BLOGGER_PHOTO_ID_5297706004123865474" border="0" /></a>新增"服務與連接埠"<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU7krCExZI/AAAAAAAAA3w/E7UW0jAzzCg/s1600-h/3.GIF"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 370px; height: 400px;" src="http://2.bp.blogspot.com/_3ub81-nYq4E/SYU7krCExZI/AAAAAAAAA3w/E7UW0jAzzCg/s400/3.GIF" alt="" id="BLOGGER_PHOTO_ID_5297706037884011922" border="0" /></a>設定Port Mapping,這邊的例子是把遠端port 3390導到裡面192.168.0.5的預設遠端port 3389‧之後就可以用對外IP:3390遠端到192.168.0.5這台電腦<br /><br /><div style="text-align: left;"> 如此Windows Server 2003環境設定到此結束,之後就是新增使用者和電腦到網域,以及管理使用者的設定了‧<br /></div></div></div></div>Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-60504339252702184702009-01-31T04:42:00.000-08:002009-01-31T05:28:24.560-08:00實驗室Server架設(1) 組織環境最近和學弟,把實驗室的Server組織重新設計了一次<br />以下是簡單示意圖:<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_3ub81-nYq4E/SYRK64jSsmI/AAAAAAAAA1M/t4auHaHrzkA/s1600-h/MAPL+service.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 291px; height: 320px;" src="http://4.bp.blogspot.com/_3ub81-nYq4E/SYRK64jSsmI/AAAAAAAAA1M/t4auHaHrzkA/s320/MAPL+service.gif" alt="" id="BLOGGER_PHOTO_ID_5297441437167825506" border="0" /></a> 原本是各台跑實驗用Server(灌Windows Vista 64bit)用獨立Public IP,給每個人遠端進去跑實驗。麻煩的地方就在於,每台都要新增一次自己的帳號,然後跑完實驗後資料數據還要傳到別的地方整理。<br /> 改成了新架構後,對外一台Windows Server 2003機器負責網域的服務,包括<br /><ol><li>建立mapl.lab的網域</li><li>新增mapl.lab網域的使用者</li><li>外面連線進來遠端或FTP的port Mapping</li></ol> 各台Server都在LAN(區網)下,使用在2003 Server上的網域使用者來登入,如此<span style="color: rgb(255, 0, 0);">帳號只需新增一次而在每台都能登入</span>。另外,每個帳號的使用者<span style="color: rgb(255, 0, 0);">桌面都會重新導向到NAS的個人資料夾中</span>,利用NAS的大容量及RAID,實驗資料將可以放在同一個兼具安全與容量的地方,供每台跑實驗的Server使用。<br /> 最後,為了不讓共用桌面(NAS)的讀寫速度(單顆HDD Read:Write約20:20MB/s, 4顆做RAID5約60:30Mb/s)受網路速度(100Mbps=10MB/s)限制,區網中架設GigaByte(1000Mbps=100MB/s)網路環境。Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0tag:blogger.com,1999:blog-7372198357691557642.post-49592059242425963992009-01-18T03:40:00.000-08:002009-02-01T02:34:22.768-08:00第一篇~~測試zoome的影片<br /><script type="text/javascript" src="http://circle.zoome.jp/cmt/swmcmedp?cod=de3d1686fffdf7f5db4410227ae5ae3c72836cd15f5624837a6f6877a2569e7963597f5318e8c1da6529616483d24447f9f1976f&width=320&height=256"></script><br /><br />測試Flickr<br /><a href="http://www.flickr.com/photos/34526884@N06/3209958230/" title="3199613950_11b4e48ece_o (by terry0201)"><img src="http://farm4.static.flickr.com/3477/3209958230_3cde6b9a23_m.jpg" title="3199613950_11b4e48ece_o (by terry0201)" alt="3199613950_11b4e48ece_o (by terry0201)" width="218" height="240" /></a>Chia-Hsin Chanhttp://www.blogger.com/profile/17050863012558164414noreply@blogger.com0