2013年1月4日 星期五
[軟體工程]如何寫出意圖使人犯錯的程式碼
這段code的規格是
初始化玩遊戲後,確保有一個使用者在遊戲裡面,所以要在init結束前呼叫join。
至於規格為什麼要這樣設計,不要問我XD
原本的code是python的。我把python的code轉成用c++來表達,所以function前面都會有virtual,以符合python情形。
2012年2月11日 星期六
report service 動態欄位寬度
經過研究之後,發現依照目前 Reporting 現有的功能,很難達成您的需求,需要客制化,因此目前有兩大類的做法:
Note:以下作法需需啟用 Reporting Services 中 [My Reports] 功能
1) 修改原有報表的 RDL 檔案的 XML,依據欄位的數量,平均分配每個欄位的寬度。修改完之後,需要另透過程式碼發佈至 Reporting 上,然後產生報表。如以下的做法:
· Here's a simple workaround if you absolutely need to get this working.
It's a hack, and you'll have to run this program every time you change the report, but it works.
1. You've probably already changed the visibility of all your dynamic columns to be an expression.
1. Make all your column widths in your table a weird number that doesn't occur elsewhere in your report: i.e. "1.23456in"
2. Save your report
3. Figure out the min and max number of dynamic-width columns, say 1 to 5 columns
4. Figure out the cumulitive width of dynamic-width columns: say 5 inches
5. Write a simple program (or just use the code below) to open the RDL or RDLC as a textfile, loop 5 times, do the text replace of "1.23456in" to (MAX_WIDTH / i), save as "dudeguy" + i + ".rdlc", where i is your loop counter
6. Change the logic of your interface program/webapp to reference "dudeguy" + num_columns
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Const MAX_WIDTH As Double = 5
Dim contents As String = File.OpenText("c:\dudeguy.rdlc").ReadToEnd
For i As Integer = 1 To 5
File.WriteAllText("c:\dudeguy" & i & ".rdlc", _
contents.Replace("1.23456in", FormatNumber(MAX_WIDTH / i, 5) & "in"))
Next
End Sub
End Class
以下是討論群組的文章:
Dynamic change of the column size and location of a matrix
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/446dfbf5-b5d5-43b8-8e2e-18691c0e1cdf
Dynamic Column width for a report
http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/9e6043f1-c458-4540-be59-d37b02feab8a/
2) 進階作法:直接根據報表資料來源的欄位多寡,動態產生整個 RDL 檔案,包含設定每個欄位的寬度等屬性,發佈至 Reporting Services,然後產生報表(可是用於多份報表)。詳細製作的細節如下,請參考:
使用报告服务 (Reporting Services) 创建即席报告应用程序 (Ad Hoc Report Application)
http://msdn.microsoft.com/zh-cn/library/aa902634(v=sql.80).aspx
用reporting service创建动态报表
http://blog.csdn.net/shankaipingo/article/details/590583
以下節錄片段程式碼:
' Table Columns
writer.WriteStartElement("TableColumns")
For i = 0 To m_Fields.Count - 1
writer.WriteStartElement("TableColumn")
Select Case m_Type(i)
Case "Decimal", "Int16", "Int32", "Int64", "Boolean"
writer.WriteElementString("Width", ".5in")
Case "DateTime"
writer.WriteElementString("Width", ".75in")
Case Else
writer.WriteElementString("Width", "1.5in")
End Select
writer.WriteEndElement() ' TableColumn
Next 'fieldName
writer.WriteEndElement() ' TableColumns
Best Regards,
2012年1月21日 星期六
ASP .net 客製化錯誤畫面
有時候你是在維護之前人寫得程式,如果要在事後為那些程式碼加上try ... catch這樣工程很浩大。因此,ASP.net提供了一個機制,當你的網站發生未處理的錯誤時,則會自動呼叫Global.asax的
Application_Error函數。 Application_Error函數裡要取得程式發生錯誤的例外,只要呼叫Server.GetLastError().GetBaseException()即可。exception中有用的資訊大概就message和StackTrace這兩個屬性。要取得發生錯誤的網址則用Request.RawUrl。要取得cookie或者form等資訊,則可以利用Request.Params。程式碼大概就像下面那樣
voidApplication_Error(objectsender, EventArgs e)
{ writeErrorLog(Server.GetLastError().GetBaseException(),Request,Session);
Response.Redirect("error.html")//轉到你要去的錯誤畫面
}
void writeErrorLog(Exception ex,System.Web.HttpRequest Request,System.Web.SessionState.HttpSessionState Session)
{
//這邊你可以做你想做的事情,如紀錄錯誤到資料庫之類的。
}
2010年10月15日 星期五
SketchUp 簡介
SketchUp 是製作3d模型的軟體
google SketchUp 是免費軟體,可以拿來做入門學習用
官方網站: http://sketchup.google.com/intl/zh-TW/
影片教學:http://sketchup.google.com/intl/zh-TW/training/videos.html
影片雖然講英文,不過看畫面基本上就知道他要幹嘛了
我聽不懂英文,都是看畫面來學的
有些影片有字幕
2010年9月22日 星期三
GIMP去背教學
http://portableapps.com/apps/graphics_pictures/gimp_portable
點擊 Download 就可以下載了
GIMP去背教學
https://www.youtube.com/watch?v=SoSxBeFsEkQ
備註:jpg格式不支援透明色,請存成png
2010年5月31日 星期一
2010年4月26日 星期一
如何在win7的字型改成droid 字型
這篇的主題有兩個,一個是如何改字型,一個是如何安裝droid字型
droid字型為google android所使用的字型,好不好看就見仁見智囉。
首先,先講怎麼下載安裝字型,先去下載http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=data/fonts;hb=HEAD 裡面所有的ttf檔
在字型檔點擊右鍵選取安裝,你應該無法安裝DroidSansFallback.ttf這字型檔,所以你要到http://hyperrate.com/thread.php?tid=5235 搜索(ctrl + f)DroidSansFallbackt.ttf.bz2下載解安裝,這個檔案是修正後的檔案。應該可以正常安裝。安裝完後,只要是名字開頭是droid的字型都是droid字型。
如何在win7更改字型?參考http://windows.microsoft.com/zh-TW/windows7/Change-Windows-fonts
如何修改firefox字型?工具->選項->內容->字型(進階那邊也有一些設定)
如何修改opera字型?設定->功能設定->進階->字型(多國語言字型也要設定)
如何修改chrome字型?選項->進階選項->變更字型
如何修改ie字型?工具->網際網路選項->一般->字型(在最下面)
2010年4月23日 星期五
如何開啟firefox3.7 GPU加速
- 進入about:config
- 搜索gfx.font_rendering.directwrite.enabled並把他設成true
- 點擊右鍵新增一個integer,把它命名成mozilla.widget.render-mode,其值設定成6
- 重新啟動瀏覽器
使用GPU加速有啥好處?就減輕CPU的工作
停用firefox工具列預覽
browser.taskbar.previews.enable=false
攝影筆記1
大光圈--淺景深
快門慢--深景深
物體近、背景遠、長焦距、--淺景深
快門快、大光圈--深景深
Tv: 快門優先,運動
Av: 光圈優先,只設定光圈
P: program , 只設定ev
ISO: 感光度,越高雜訊越多
井字構圖:放線上
地平線,水平
利用框物,如樹
利用線條
陰天比較好
人物攝影:光源、角度、色溫
多拍
預覽結果
同時段使用同一種拍攝模式評論chrome os
很多人都嫌chrome os 很爛,比不上windows。事實上,那兩個系統的定位根本不一樣,不能相比。windows是全能的作業系統。chrome os 則只負責讓使用者能夠使用網路,其他功能以輔助上網為主。他所有的應用程式都是在網路上執行,並無法在本機端執行應用程式。