2017年4月24日 星期一

窗仔門 (windows) ê 概念

這馬逐家開電腦, tō 跳出媠 ê 畫面. 普通咱叫伊號做桌面. 桌面頂有一寡細圖,號做 icon [Ai-Khòn, 華語:縮圖]
這寡細圖, 一咧著代表一種應用程式[ìng-īong-tîng-sit](Application). 比如講欲聽音樂, 欲寫文章, 欲畫圖, 欲上網, 你愛用貓鼠仔(Mouse/華語:滑鼠)去揤無仝 ê 圖, 親像這咧圖:


佇這咧桌面, 有三 ê 物件, 有个是, 有个是躼跤, 有个踮頂懸, 有个hőng 佇下跤。論真講, 程式是運行佇電腦內底个電路,咱人是看無--ê. 若按呢生[sinn], 咱人欲按怎和伊溝通咧? 就是倚靠這三个四四角角 ê 窗仔門 (windows, 華語: 視窗)。這三的窗仔門,量其約代表三的應用程式。

現代每一咧應用程式,攏有一咧專門个學問,就是愛設計伊欲按怎和使用人接接[tsih-tsiap], 這種學問, 號做 GUI [ku--i, 華語:使用者介面] 設計. 窗仔門 就是 GUI ê 重要零件.
簡單講, 窗仔門是你佮程式交換資訊 ê 窗仔, 你 uì 窗仔叫伊畫圖, 伊就踮後壁畫圖, 畫好才共圖囥佇仝一咧窗仔, 抑是另外一咧窗仔予你看。會使一咧程式有幾落个窗仔, 嘛會使幾落个程式鬥陣用一咧窗, 看 GUI 欲按怎設計予人感覺好用閣好看!

這馬, 有一間有名个公司號做 Microsoft [mái-ku-lo-so (莫閣囉嗦),華語: 微軟], 伊 ê 產品攏號名 Windows, 像 窗仔 8 (windows 8), 窗仔 10 (windows 10). 毋過, 咱講个窗仔毋是伊!

2017年4月21日 星期五

Python 紹介

Python 是一種電腦語言.
伊簡單學, 閣有夠力來解決問題和完成你向望伊做个各樣工課

伊是荷蘭(Nederland) 人  Guio van Rossum (Gí-To-Huan-Ló-Siān?Google 翻譯)所起造 ê 電腦語言. 踮 1989 年 12 月, Guio 佇欲過 Christmas 時感覺無聊, 著決定欲寫一咧新 ê 語言. 伊 Python 這咧名, 是因為伊是彼時一咧號做 Monty Python's Flying ê 馬戲團 ê 戲迷.

Python ê 英文意思是一種大蟒蛇[Bóng-Tsuâ]. 這就變做伊 ê 標誌.

咱講 Python 是好用 ê 家私頭仔, 有幾落个角度來看:
首先, 伊簡單學. 佮這馬較出名个幾咧電腦語言比並, 親像 Perl, C, C++, Java. 伊是語法簡單好學. 欲入手嘛真簡單。

紲--落來, 伊有真濟捌人做好 ê 工具. 咱做啥物代誌,無法度逐件攏uì頭家己來. 捌人若有好勢 ê 物件, 著佮伊抾來用. 囥這寡好物 ê 所在, 號作程式(tshng). Python 有蓋濟用途無仝 ê 程式. 無論你有想著抑是想袂到, 人攏攢便便(tshuân-piān-piān) 佇遐. 巧人就會先去程式揣合用 ê 工具.

落尾, Python 佇網路頂, 有真濟活跳跳个社團佇維護, 使用, 和討論. 伊本身嘛閣佇咧進步,你欲問問題(m̄ng-būn-tê) 嘛有通人回答, 討論。

對初學者來講, 伊是簡單入門. 毋過, 伊毋是耍物niâ-niâ, 嘛會使來賺食(tsuán-tsia̍h). 無論是耍趣味抑是袂賺食, 伊攏是一咧袂䆀 ê 選擇




2017年4月16日 星期日

Python ê 安裝

佇這篇,咱介紹普通套件 ê 安裝。閣有另外這種有人共你攢便便 ê 方式,號做 Anaconda,你會使揀你較佮意ê

若佇 Linux 頂安裝 Python, 愛先佇命令窗(Terminal) 下跤, 字(key)

$ sudo apt-get install python3

抑是

$ sudo yum install python3

頂懸命令內底 apt-get 是 Debian 款个 Linux ê 家私頭, yum 是 Fedora 款 ê Linux ê 家私頭,是去雲頂 (Cloud) 去掠套件 (Package, 毋知會使講包袱仔無?) 轉來裝。佇遮,咱是掠 Python/Python3 轉來。

安裝好, 試看莫好勢無:
$ python3
若出現
>>>

按呢著完成阿!
若佇 Windows 頂安裝 Python, 愛先去 Python 个官網 轉來安裝. Windows ê 安裝應該真簡單, [下一步] 揤揤 niâ-niâ. 若是有人需要,後擺才另外寫一篇來專門講。

現此時, 有 python 2 和 python 3 兩的主流版本.

python 2 目前閣真. 你若干焦起 (key) "python", 目前大部分電腦本底就是去叫 python 2, 愛特別加一咧 "3", "python3" 才會叫 python3 起來運行.

毋過, 時代是向前行。緊慢攏會行向 Python 3. In 有小可無仝, 咱若是拄開始學, 就直接 uì Python 3 學起! 若有拄著和 Python 2 無仝个所在,我會佇特別點醒。

2016年10月24日 星期一

無眠

以下是蘇打綠 ê 無眠, 用教育部 ê 標準用字,  小可校正.口音盡量按照 Youtube 內, 我聽著 ê 青峰 ê 口音!

今仔日月娘那遐爾光                   kin-á-ji̍t   gue̍h-nîu  ná    hiah-nī kng

照著阮歸暝攏袂當睏                   tsìo-ti̍oh  gún  kui-mî  lóng   bē-tàng  khùn
連頭毛都歇睏                          liân  thâu-m̂ng  tōo    hioh-khùn
(親像魚死佇花園)                   tshin-tshīunn  hî  sí  tī  hue-hn̂g

你敢知阮對你的思念                  lí   kám  tsai  gún  tuì  lí  ê  su-liām
希望你有的夢                     hi-bāng  lí  ū  kāng-khún  ê  bāng
咱兩人做陣轉來一工              lán  nng  lâng  tsuè-tīn  tńg--lâi  hit   tsi̍t  kang
互相依的情愛                         hōo-sìong  i-  ê  tsîng-ài

佇你的心肝內                             tī  lí  ê  sim  kuann  lāi
是不是有我的存在                  sī  m̄  sī  koh  ū   guá  ê  tsûn-tsāi
永遠攏等                                íng-uán  lóng  teh  tán
有時陣嘛會甘願                     ū-sî-tsūn  mā  ē  m̄  kam-guān

想講要作飛                            siong  kóng  beh  tsuè-hué  pue
去一个心中美麗的所在             khí  tsit-ê sim-tiong  bí-lē  ê  sóo-tsāi
所有的一切                               sóo-ū  ê  it-tshè
攏總作夥                        lóng  tsóng  kah  lí  khǹg  tsò-hué 
希望你 會當了解                       hi-bāng  lí  ē-táng  liáu-kái
(為著你 我一定等)                  uī  ti̍oh  lí guá it-tīng táng

偌濟時間偌濟目屎         guá m̄-kuán guā-tsuē sî-kan guā-tsuē bo̍k-sái 
  偌濟失望來忍耐                     guā-tsuē sit-bōng lâi lím-nāi
管你當時會轉來                guá  m̄-kuán  lí  tang-sî  ē  tńg-lâi
其實我嘛知影為怎樣            kî-si̍t guá mā m̄-tsai-iánn uī-tsuánn-īunn
  為怎樣憨憨等待                     uī-tsuánn-īunn gōng-gōng lâi tán-thāi

你 是我唯一的愛                      lí  sī  guá  uî  i̍t  ê  ài

懷春曲


以下是根據林英美所唱 ê 懷春曲, 儘量以教育部所定的標準台文來重寫歌詞
另外 A-Lan 所演唱的版本, 嘛真好聽!



日落西天色黃昏     馬車跑山侖
 li̍t lo̍k sai thinn-sik hông-hun         bé-tshia pháu suann-lūn

咱二人真有緣份     相會在這陣
 lán nn̄g-lâng tsin ū iân-hūn           siong-huē tsāi tsit-tsūn

阮心內真正興奮     佮著貼心
 gún sim-lāi tsin-tsiànn hing-hùn      kah tīo tah-sim kun

手牽手做陣游賞     快樂當青春
 tshíu khan tshíu tsuè-tīn îu-síunn   khuài-lo̍k tng tshing-tshun



戀花開又媠又芳     花心一點紅
 luān hue khui īu suí īu phang         hue-sim tsit tiám âng

在等待蝴蝶飛來     守阮的花欉
 tsai tán-thāi ôo-tia̍p pue-lâi              síu gún ê hue tsâng

為著伊心情茫茫     日頭直直暗
 uī ti̍oh i sim-tsîng bâng-bâng         li̍t-tâu ti̍t-ti̍t àm

提紙筆來寫情批     寄乎伊一人
 thê tsuá-pit lâi siá tsîng-phue        kià hō i tsit lâng



在眠夢佮伊相見     散步溪仔墘
 tsāi bîn-bāng kah i sann-kìnn         sàn-pōo khue-á kînn

夢見伊對阮講起     婚緣的代誌
 bāng-kìnn i tuì gún kóng-khí          hun-iân ê tāi-tsì

初戀味情意真甜     見笑暗歡喜
 tshoo luân tshîng-ì tsin tinn           kiàn-siàu àm huann-hí

醒來才知影都是     夢見見著伊
 tshínn--lâi tsiah tsai-iánn to-sī       bāng-kìnn kìnn tio̍h i



想彼時自由自在     談情相意愛
 sīunn hit-sî tsū-uî-tsū-tsāi             tâm tsîng sio ì-ài

心對心談情說愛     歡喜無人知
 sim tuì sim tâm tsîng suè ài          huann-hí bô lâng tsainn

求神明替阮想覓     佮阮鬥催排
 kîu sîn-bîng thè gún siūnn-māi          kah gún tàu tshui-pâi

保庇阮達成希望     幸福的將來
 pó-pì gún ta̍t sîng hi-bāng            hīng-hok ê tsiong-lâi

2010年4月18日 星期日

Using BlackBarry Bold 9000 as 3G modem on Linux

Recently I got the BlackBerry Bold 9000 and it can work as 3G modem by using the BlackBerry Desktop Software. Since I used to work under the environment of Linux, I want to make it work on Linux.

In ubuntu 9.10, I do the following steps
$ sudo apt-get install pkg-config libusb-dev libssl-dev libboost-serialization-dev libtar-dev libgtkmm-2.4-dev libglibmm-2.4-dev libglademm-2.4-dev zlib1g-dev

And then download and install the "libbarry" and "barry-util" from Source Forge: http://sourceforge.net/projects/barry/files/

But it could not work.

After trial for awhile, I finally make it works from the recompiling and debug from the ppp package.

In the debugging, I found that it looks when using the IPCP to get the local IP adderss, BlackBerry cannot provide it immediately and pppd daemon polling for many times, so that ppp get the many NAK's from Barry. Finally it provides but the pppd complains and exit.

The quickfix to it is to increase the max number of IPCP NAK tolerance to reject the NAK's information. From the the ppp source tree:

vi pppd/ipcp.c

and the line:

f->maxnakloops = 100;

and change it to larger number, I use the 2000;

And it works well,

Also, my telecom company is Taiwan Mobile, attach the ppp script and chat for reference:
/etc/ppp/peers/barry-taiwan_mobile:

-------------
pty "/usr/sbin/pppob"
connect "/usr/sbin/chat -f /etc/chatscripts/barry-taiwan_mobile.chat"
#noauth
user ""
password ""

defaultroute
usepeerdns
noipdefault
nodetach
novj
nocrtscts
nomultilink
ipcp-restart 7
ipcp-accept-local
ipcp-accept-remote
lcp-echo-interval 0
lcp-echo-failure 999
mtu 1492
ipcp-max-configure 100
nopcomp
noaccomp
nomagic
--------------
/etc/chatscripts/barry-taiwan_mobile.chat:
------------
ABORT ERROR
OK ATZ
OK ATI
OK AT+CGDCONT=1,"IP","internet"
OK ATD*99#
CONNECT
------------
The workable command is:

pppd call barry-taiwan_mobile


-- Enjoy

2008年4月3日 星期四

Using script to Write Notes - (我用 Script 寫筆記)

I am a firmware engineer and I often write notes to record my trial and experience on installation of software, tools, and some other things! These notes help me a lot because I can redo any thing after a long time!!

Recently, I tried the Ubuntu Hardy with version Alpha 5 and got some problem with my amd64 machine. I have to re-install it several times! The installation of Ubuntu is quick, but it takes me a lot of time to tune it to fit the my used environment! I have to install a lot of other software and re-write the configuration files!!

If I have write down the steps by script, I can save a lot of my time after each installation!!

The second experience is: When I try the building of Glibc, I keep on write down the notes. And suddenly I think: Since it is step by step, why don't I use the script to note it instead of simply text?

For a software / firmware notes, such as software and program build, the notes style is something like:
---------------
Description
....
Commands
....
Description
...
Commnads
...
---------------
You describe something, and then show up your command or program!!


if what you note down can not be realized step by step, the information must be obsolete or outdated!!! So I have to revise my old notes frequently!! If that is true, why do I not to make my note runnable? This can save my time a lot for the second round!!!

This is not a new idea!

I am not very sure, but I did know there are some tries and maybe some useful tool available. For example, to embedded the notes in the program, such as C or others!! You write the remark by some tags or format such that you can extract your notes by utilities!!

Or the XML that can do almost anything!!

After consideration, there are some choices:
1. Search for some ready tools
2. Write my notes with the commands with some special tags so that I can use utilities to extract and run
3. Write more remark and use more "echo" in the Bash Script

For item 1, First, I have no time to learn if the grammar or tags are complicated. Second,it maybe hard to trim it for my used usage. and third and also the major reason: I don't know any ready tools and I don't search the Web. If anyone have good suggestion can tell me!!

For item 2, I think it is workable! But I think it would be more complicated to parse the runnable commands out of a plain text!! And it is not flexible or it would be more complicated if you want flexibility!!

For item 3, it is good, but it is not intuitive!! Although it is closest to our notes, but for flexibility sake, we often use the function call, indirect reference, and many flow control that make your remark trivial!!

1 Easy to note down
Not too much tags or grammar!!
2 No need more utilities or tools
As simple as good!!
3 Flexibility
Sometimes I want to just run parts of my script for some tests!! And I can turn on/off the notes when execution, or I simply want to know the usable steps to do it and don't really run

I choose the Bash Script because I often work on it and I used to it. Although I am not familiar with script programming, this is the chance that I can learn it. And it has the following benefit:

1 Its function is easy
2 Its file management is easy
3 It is easy for it to execute program
Thanks to the Unix Design, it can call almost any program to help the job

To do it, first I create two simple function:
-------------------
n() {
if [ "$NOTE" != "n" ];then
echo "$*"
fi

p() {
if [ "$VERBOSE" != ];then
echo "executing $*"
fi
if [ "$GO" = "y" ];then
eval "$*"
fi
}
------------------------------
and then you can use them in your following script!!
------------------------------

n your notes
p ls
------------------------------
So that I can write down your note and command nearly as easy as my notes in plain text!!

You can see your notes on the standard output, and you can also see the execution command and result! I use some variables to switch the notes, execution command line, and the real execution on / off

To improve the flexibility, I use the program style used by the scripts in /etc/init.d/*. Which has the following pattern:
-----------------------
#!bin/sh
..
..
..
case $1)
start)
...
stop)
...
restart)
...
*)
;;
esac

exit
--------
It uses the CASE execute different work in one script! And I can use it o divide your stream-like flow into separate segment so that I can test them separately!!

Follow this idea, I use the compilation of glibc on PC as an experiment!! If you are using the Ubuntu Hardy and have the internet conncetion, just download the two attached files my_methods and glibc_build in the same directory and run:

./glibc_build go=y

and it would download the glibc-2.17 source package and build the source automatically. Please notes: it doesn't use the dpkg-related utilities!!

you can show the basic options by

./glibc_build show=basic

you can the basic information by

./glibc_build act=preface

you can show the building steps

./glibc_build

and it would show your notes and your steps, but not run:

########### Do Preface
Platform: Ubuntu Hardy i386 20080401
The Glibc version-glibc-2.7.tar.gz
Based on the book: The Definitive Guild To GCC, 2nd, Chapter 12


########### Do Download
$----- apt-get source glibc -----'
$----- cd glibc-2.7 -----'


########### Do Unpack
Note: We use the GNU tar so that we can use the following commands, if not, please reference the book!!
The official downloaded version is glibc-2.7.tar.gz


########### Do Intaling Tools
Install the required tools
$----- aptitude install -y autoconf automake -----'
Install the gawk to prevent the erors:mawk: scripts/gen-sorted.awk: line19: regular expression make failed
No rule to make target xxx/Versions.all, needed by ..../abi-version.h
If you do not use the gawk, it would use the mawk and casuse this error
You will needs to re-run configuration if you face this error in make
$----- sudo aptitude install -y gawk -----'


########### Do Configure
Configuraing the glibc-2.7.tar.gz
The best way to build the Glibc is to create a separate directory for buiild
The glibc is default to be installed in /usr/local
The Glibc search and load search path is determined by
LD_LIBRARY environment varialbes or configuration file /etc/ld.so.conf
Set the installation directory by --prefix= option
run the configure --help to get more configuration options
Optimize for kernel --enable-kernel=, --enable-kernel=current>


Creating a directory
$----- mkdir /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- mkdir /home/black/workarea/glibc-2.7/ttglibc-installed -----'
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- /home/black/workarea/glibc-2.7/tt/glibc-2.7/configure --enable-add-ons --prefix=/home/black/workarea/glibc-2.7/ttglibc-installed -----'


########### Do Make
Compiling the glibc-2.7.tar.gz
Fix the __stack_chk_fail_local fail by adding the -fno-stack-protector
However it would overlap the -O2 options so that glibc would complain
#error: glibc cannot be maked without optimization
So I add the -O2 together and succeeded
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'
$----- LANG=C LC_ALL=C make -j2 CFLAGS+='-O2 -fno-stack-protector' -----'


########### Do Check
do the check
$----- cd /home/black/workarea/glibc-2.7/tt/glibc-build -----'

You can look a piece of my code:

do_configure() {
n "$SEP Do Configure"
n Configuraing the $PKG
n The best way to build the Glibc is to create a separate directory for buiild
n The glibc is default to be installed in /usr/local
n The Glibc search and load search path is determined by
n LD_LIBRARY environment varialbes or configuration file /etc/ld.so.conf
n Set the installation directory by --prefix=\ option
n run the configure --help to get more configuration options
n Optimize for kernel --enable-kernel=\, --enable-kernel=current\>
n "\n"
n Creating a directory
BUILD_DIR=$(pwd)/glibc-build
INSTALL_DIR=$(pwd)glibc-installed
PKGDIR=$(pwd)/glibc-$VER
p mkdir $BUILD_DIR
p mkdir $INSTALL_DIR
p cd $BUILD_DIR
p $PKGDIR/configure --enable-add-ons --prefix=$INSTALL_DIR
}

do_make() {
n "$SEP Do Make"
n Compiling the $PKG
n Fix the __stack_chk_fail_local fail by adding the -fno-stack-protector
n However it would overlap the -O2 options so that glibc would complain
n "\t\t"\#error: glibc cannot be maked without optimization
n So I add the -O2 together and succeeded
.......
.......

case "$ACT" in
preface)
do_preface
;;
download)
do_download
;;
tools)
do_tools
;;
usage)
do_usage
;;
patch)
do_patch
;;
restart)
do_restart
;;
precheck)
do_precheck
;;
addon)
do_addon
;;
unpack)
do_unpack
;;
addon)
do_addon
;;
configure)
do_configure
;;
make)
do_make
;;
check)
do_check
;;
install)
do_install
;;
clean)
do_clean
;;
summary)
do_summary
;;
*)
do_preface
do_download
p cd $PKGNAME-$VER
do_unpack
do_tools
do_configure
do_make
do_check
do_summary
;;
esac
exit 0

I use the function to group each step, and write the note and script inside them. Of course I want more robust and flexibility so many variables are added and many skill used. If you just want it run in your own limited situation, you can just write it serially and you can modify it if you have free time!!

佇 Linux 來看GPX 檔案

最近定定有戶外活動。使用𤆬路機 (GPS) 來記錄行過的路線。普通我記錄路線,攏是用手機仔抑是專門个𤆬路機,罕得用電腦來看。 毋過,"仙人拍鼓有時錯,跤步踏差啥人無"。有一擺我無細膩,袂記得共一擺活動的路線收煞起來,閣直接開始記錄下一擺的活動,按呢共幾落...