2013-08-12

Path.Combine could be very useful

0 comments

In winfrom program if you want to get a folder path name "Process" under exectue application folder.
you can use this function => Path.Combine(Application.StartupPath, "Process")

Please DON'T put "\" Like this => Path.Combine(Application.StartupPath, "\Process")

You will only get string "\Process".... Read more.

2013-05-18

QNAP Subversion newest Firmware (3.8.3 Build 20130426) fixed Autorun.sh problem

0 comments


Step 1:
find /share -name "Optware.sh"

vi /etc/config/qpkg.conf

press a to edit

Add the following lines to the end of /etc/config/qpkg.conf:
[Optware_Autorun]
Name = Optware_Autorun
Version = 1.0
Enable = TRUE
Shell = /share/MD0_DATA/.qpkg/Optware/autorun.sh
Install_Path = /share/MD0_DATA/.qpkg/Optware
Author = Geoff Clements
Date = 2012-06-18

Press esc key
And key in :wq then enter
chmod +x /etc/config/qpkg.conf

Step 2:

vi /opt/autorun.sh

press a to edit

paste the code follow:
#!/bin/bash

shopt -u nullglob

# Change these to adjust the timeout
# timeout(secs) = (maxtries - count) * delay
count=0
declare -r delay=5 maxtries=12

# Default action is "start" as this file is called with
# no parameters on NAS startup but you can, for
# example, do a "./autorun.sh stop" to stop all Optware
# services
action=${1:-start}

LOG=/sbin/log_tool

${LOG} -t 0 -a "Starting Optware_Autorun."

# Wait for /opt to come online
# use ipkg as a test
while [ ! -f /opt/bin/ipkg ]
do
  if ((count++ >= maxtries))
  then
    ${LOG} -t 1 -a "Optware_Autorun time out."
    exit 1
  fi
  sleep ${delay}
done

# Run all executables beginning with S in /opt/init.d/Optware/
for f in /opt/etc/init.d/Optware/S*
do
  [ -x ${f} ] && ${f} ${action}
done

exit 0

Press esc key
And key in :wq then enter
chmod +x /opt/autorun.sh


Step 3:
mkdir /opt/etc/init.d/Optware/
chmod +x /opt/etc/init.d/Optware/
vi /opt/etc/init.d/Optware/S10svnserve

paste the code follow:
#!/bin/bash

# Full path to executable
runfile=/opt/bin/svnserve

# Parameters to pass to runfile
params="-d --listen-port=3690"

# Need exactly one parameter
((${#} == 1)) || exit 1

# Must have a runfile
[ -z "${runfile}" ] && exit 1

service=$(basename "${runfile}")

LOG=/sbin/log_tool
DMGR=/sbin/daemon_mgr

waitfor () {
  # $1 = service
  # $2 = maximum time to wait (secs) - default 30

  local pid=$(pidof ${1})
  local count=${2:-30}
  while [ -n "${pid}" ]
  do
    sleep 1
    if ((--count <= 0))
    then
      return 1
    fi
    pid=$(pidof ${1})
  done

  return 0
}

start () {
  ${LOG} -t 0 -a "Starting ${service}."
  pid=$(pidof ${service})
  if [ -z "${pid}" ]
  then
    ${DMGR} ${service} start "${runfile} ${params}"
    pid=$(pidof ${service})
    if [ -n "${pid}" ]
    then
      ${LOG} -t 0 -a "${service} started."
    else
      ${LOG} -t 2 -a "${service} failed to start."
    fi
  else
    ${LOG} -t 1 -a "${service} already running."
  fi
}

stop () {
  ${LOG} -t 0 -a "Stopping ${service}."
  pid=$(pidof ${service})
  if [ -n "${pid}" ]
  then
    ${DMGR} ${service} stop "${runfile}"
    if waitfor ${service}
    then
      ${LOG} -t 0 -a "${service} stopped."
    else
      ${LOG} -t 2 -a "Cannot stop ${service}."
    fi
  else
    ${LOG} -t 1 -a "${service} already stopped."
  fi
}

case "${1}" in
  start)
    start
    ;;
  
  stop)
    stop
    ;;
  
  restart)
    stop
    start
    ;;
  
  reload)
    pid=$(pidof ${service})
    [ -n "${pid}" ] && kill -s SIGHUP ${pid}
    ;;
esac

exit 0

Press esc key
And key in :wq then enter

chmod +x /opt/etc/init.d/Optware/S10svnserve
/opt/autorun.sh start

... Read more.

2012-01-10

程式設計師勸敗 QNAP RAID 1 檔案伺服器管理

0 comments

最近筆者買了一個QNAP TS-212來當家裡的檔案伺服器

會選擇QNAP當然是下了不少功課,基本上RAID 1就已經非常厲害了

當然會買的理由是因為有在維護網站程式,所以保護原始碼也是Programmer的工作之一啊^^

這一台可以裝上Subversion簡稱svn,這樣就能把所有的原始碼commit進這一台機器內,

是不是很棒呢!!不不不!是非常棒,想像一下一台24小時不關機的svn在運作,又非常省電環保,真的是想到作夢都會笑耶。呵呵呵

關於svn怎麼運作可以參考有一系列的文章,看完就會http://demo.tc/Post/715
關係Qnap怎麼設定svn也不難,可以上Google找找。

真心勸敗啊^_^... Read more.

2011-12-21

TortoiseSVN 使用,使用分支Branch開發新功能

0 comments

版本控管真的可以提高效能,花個時間學會一定值得,一輩子受用。

看看這一篇文章我想所有的程式設計師看完一定心有戚戚焉
http://demo.tc/Post/715

以下是文章大意:

某日B工程師正在開發一個驚天地動鬼神的功能,扯到了專案的最核心,眼看大概再三個工作天就可以完成了,正在沾沾自喜的時候客戶來了一通電話。

客戶:「我想要改變一下流程你幫我把A功能和B功能中間差一個確認頁面,避免使用者一直打來說他不小心刪除了,叭啦叭啦...」

(這時你聽到需求感到相當簡單,不就是加個 Confirm 就可以解決的小事,於是你很有信心的回)

B工程師:「喔~這樣阿,沒問題阿我馬上幫你改好」

客戶:「嗯!快點阿,不然總機小姐快忙死了」

電話掛掉後你很自然的開啟A功能修改一下馬上就完成了客戶要的東西,你正要上傳的時候卻發生了悲劇!因為你正在修改的大功能是在主線(Trunk)中修改的,即使現在只是要一個那麼小那麼容易的功能你卻因為大功能尚未完成而卡住了你所有的修改。這時候電話又來了...

客戶:「阿不是說一下就改好?三個小時過去了電話還是一直來阿」

B工程師:「嗯…..這功能可能還要三天才可以上去…….」

客戶:「你以為我不會寫程式阿!!這麼簡單的功能你也要做三天,我去找你老闆說... Read more.

2011-08-02

Toad For SQL 5.5看到Description (描述)了

0 comments

之前一直覺得Toad For SQL好用歸好用,可是就是少了一點什麼!
因為有用過Toad For Oracle比較之下,就是有Descrition欄位可以看
從Toad For SQL 3x版一直等啊等,終於盼到5.5版把此欄位納進去了
說了一堆!看圖最清楚~




補充:
原來4.1版就內建Description了,哈哈
5.5版試用一天的心得,速度有變快,所以直接衝最新版吧^^... Read more.