2013年1月31日 星期四

將raspberry pi改成bt下載器


raspberry pi 是一台價值美金$25美元的電腦。處理器是ARM1176JZF-S (armv6k) 700 MHz,記憶體規格有256MB和512MB的版本。可以安裝Linux上去。

雖然他是在arm板子上,可是能跑Linux,自然而然可以跑許多Linux上的應用。以下內容是基於Raspbian “wheezy”作業系統。Transmission 是一個網頁介面的BT下載器,讓你可以遠端操控你的BT下載電腦,而不用特地為BT下載器電腦加裝螢幕或是使用switch。

2013年1月24日 星期四

MSP430_LaunchPad在ubuntu使用教學



安裝指令
sudo apt-get install gcc-msp430 msp430-libc mspdebug msp430mcu
編譯用的指令,記得加-mmcu,不然會發生一些變數無法link的情形,我的板子是msp430g2553,所以用下面的指令。

2013年1月20日 星期日

程式語言分析



這篇文章是當初我找工作時,履歷的附加檔案。基本上只是我個人的主觀意見。每種語言都有各自的愛好者,且每個人的偏好也不一定相同。選擇自己最喜歡的語言即可。



2013年1月5日 星期六

[程式語言] 淺談Python的預設參數

這篇文章是要討論python的預設參數


def fun1(a=0):
        print a

def fun2(a=[]):
        a.append(1)
        print a
        print 'address: ', id(a)

class DefaultObject:
        def __init__(self):
                print 'call me'

def fun3(a=DefaultObject()):
        print 'address: ', id(a)

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 客製化錯誤畫面

當你在撰寫ASP.net的程式時,有時候程式會發生你不預期的例外,因而沒有去try .. catch去處理。這時候錯誤畫面就會傳到前端。這對使用者而言不是一個很好的使用經驗。因此,讓使用者看到統一而一致的錯誤畫面會比那ASP.net的黃色畫面好多了。
有時候你是在維護之前人寫得程式,如果要在事後為那些程式碼加上try ... catch這樣工程很浩大。因此,ASP.net提供了一個機制,當你的網站發生未處理的錯誤時,則會自動呼叫Global.asax的Application_Error函數。


   Application_Error函數裡要取得程式發生錯誤的例外,只要呼叫Server.GetLastError().GetBaseException()即可。exception中有用的資訊大概就message和StackTrace這兩個屬性。要取得發生錯誤的網址則用Request.RawUrl。要取得cookie或者form等資訊,則可以利用Request.Params。

程式碼大概就像下面那樣



void Application_Error(object sender, 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去背教學

GIMP portable載點
http://portableapps.com/apps/graphics_pictures/gimp_portable
點擊 Download 就可以下載了
GIMP去背教學
https://www.youtube.com/watch?v=SoSxBeFsEkQ


備註:jpg格式不支援透明色,請存成png