2.02.2013

tortoisegit: git did not exit cleanly (exit code 128 or code 1)解法

用tortoise git,出現git did not exit cleanly (exit code 128),

但是用git卻成功。我發現移除後,再重灌無效。

但是 

1. 移除tortoise git後,

2. Open 'regedit', 再手動search 'tortoisegit'機碼,

全部刪除後。

3. 再重灌,重灌選git default的ssh,

就不會有錯了。enjoy~

 Note: 有試過這樣也無效,後來就放棄tortoise git,直接改用Git了。 

 也有可能是Git的路徑多了空白的問題:

B

Hmmm....

I unzipped the portable version into the typical install dir: "C:\Program Files (x86)\Git", and got the same errors.
Unzipped into "C:\git2", and it worked as expected.
Perhaps the problem is with the spaces in the path?

(But why does it work on the other computer....?!)

 

9.26.2012

Don't always declare global variable in C/C++

If you always declare global variable instead of local,
Once you using recursive call, you may get run time error.
See

SPOJ Problem 1436: Is it a tree – PT07Y

if you move

list<int>::iterator it;
 
 from local variable to global variable, you will get run time error 
by input following:
3 2
1 3
3 2 




4.09.2012

Random Go program ~ Brown

幾天前想寫一個GTP(Go Text Protocol) base的隨機下棋程式,
不過看了一下GTP Spec. 雖然不是很複雜,但真正要寫,
也需要一些時間,所以一直沒有實際下去寫。
今天重看GTP spec. 的網站,突然發現一個叫Brown的程式,
正好符合我的需求,很快地就下載source回來看看能否Build win版…
首先用wxDevC++,開啟一個C++的console專案,
將main.cpp的內容換成brown.c的內容,並且加入剩下的檔案到專案中,
結果在Build時,有一些錯誤,
在interface.c加上#include "string.h"就OK了。
Build成exe後,發現用Panda-glGo還是不能玩,
就去下載Drago, 稍微設定一下,
It's work!

後記:
我改了一下,使Brown go可以在Panda-glGo上玩,
下載檔案及source code

8.27.2011

Python: assign list to all zero

我學python 一陣子了,但一直不知道如何一次assign給list同一個值,
之前都是用range()來assign給list的,查了一下google,但似乎沒相關的說明,
原來我要問的問題太基本了,後來終於發現,原來很簡單,
如果要assign給list a,10000個0,那就:

a = [0] * 10000

同理,如果要assign給list a,9999個1,那就:

a = [1] * 9999

7.12.2011

Renpy 與 python

renpy可以用'$'或'python:'來插入python的程式碼,
不過注意,不要用來'import' pyhon的library,
否則很容易造成 遊戲存檔失效,
如果要'import'一些額外的library,
請在'init python:'中加入即可。

7.09.2011

Renpy 6.12.1: How do I show a variable in the text?

要怎麼在對話的text中秀出變數,Renpy 官網提供以下三種方法:
$ food = "apple sauce"

"I would like to try some %(food)s, please."
"I would like to try some %s, please." % food
"I would like to try some " + food + ", please."
 不過,我在Renpy 6.12.1試的結果,目前只支援第一種:
"I would like to try some %(food)s, please."

其它兩種,不確定以前有沒有支援,目前看來是不行用的。

7.02.2011

Renpy 6.12.1: Drag and Drop

Renpy 6.12.1支援滑鼠托拉(Drag and Drop)的功能,
官網有範例,不過若直接複製貼上範例code,
會發現有些小錯誤:
1. 請將drag_group改成draggroup
2. 去下載圖片,裡面的圖記得改成自己圖片的名稱

修改後範例如下:

init python:

    def detective_dragged(drags, drop):

        if not drop:
            return

        store.detective = drags[0].drag_name
        store.city = drop.drag_name

        return True

screen send_detective_screen:

    # A map as background.
    add "europe.jpg"

    # A drag group ensures that the detectives and the cities.
    draggroup:

        # Our detectives.
        drag:
            drag_name "Ivy"
            child "ivy.png"
            droppable False
            dragged detective_dragged
            xpos 100 ypos 100
        drag:
            drag_name "Zack"
            child "zack.png"
            droppable False
            dragged detective_dragged
            xpos 150 ypos 100

        # The cities they can go to.
        drag:
            drag_name "London"
            child "london.png"
            draggable False
            xpos 450 ypos 140
        drag:
            drag_name "Paris"
            draggable False
            child "paris.png"
            xpos 500 ypos 280

label send_detective:
    "We need to investigate! Who should we send, and where should they go?"

    call screen send_detective_screen

    "Okay, we'll send %(detective)s to %(city)s."