2014-12-26

TCL, INFO exists

info exists 檢查變數是否存在.
例如 incr 指令的使用, 變數需先建立才能為變數進行加法運算. 此時可使用 info exists 先確認此變數是否存在, 再續程式.

if { ![ info exists counter ] } {
         set counter 0
} else {
         incr counter
}

TCL, File - Get file path

[Condition]
  • filename: test.tcl
  • file path: C:/02-MTS/99-Trainning/12-info/

set appPath [ file normalize [ info script ] ]

if { [file type $appPath ] == "link" } {
      set appPath [ file readlink $appPath ]
}

puts $appPath

[Program Output]
  • C:/02-MTS/99-Trainning/12-info/test.tcl

2014-12-10

Disable daemon of Smartd to speed up boot process.


What is Smartd: Smartd does hard drive reliability monitoring.


Turn it to OFF

Example OS: CentOS 4.2 with Kernel 2.6.9-22 EL
  • # chkconfig smartd --list
    • smartd    0:off   1:off   2:on   3:on   4:on   5:on   6:off
  • # chkconfig smartd off
  • # chkconfig smartd --list
    • smartd    0:off   1:off   2:off   3:off   4:off   5:off   6:off

2014-12-04

2014-11-27

Sublime Text 3, How to see her in detail?

Content List:

A. PASTE Multiple Texts
B. MOVE Middle Texts
C. MOVE Forward Multiple Lines

2014-11-25

TCL, MAC address increment

set var_mac 001A6A00001F
set var_incr 000000000001

set var_mac2 [ format %X [ expr "0x$var_mac + 0x$var_incr" ] ]
puts $var_mac2

set mac_next "001A$var_mac2"
puts "Next MAC Address is $mac_next"

[OUTPUT]
6A000020
Next MAC Address is 001A6A000020

[NOTE]
Line 1 to Line 4 產生的值為 Line 5 的 6A000020, 而不是 001A6A00001F, 少了 001A. 很奇怪, 所以才在 Line 7 補上 "001A", 有空再回頭瞭解.
Line 2 $var_incr 也可不用 000000000001, 可以是 1.

2014-11-18

MD5 Checksum - Linux

  • Tool: md5sum
Generate MD5 checksum

Generate a 10M file for test propose.
  • # dd if=/dev/zero of=/tmp/test-10M bs=1048576 count=10
  • 10+0 records in
  • 10+0 records out
  • 10485760 bytes (10.0MB) copied, 0.063248 seconds, 158.1MB/s
  • # ls -la
  • test-10m
Generate MD5checksum
  • # cd /tmp
  • # md5sum test-10M > test-10M.md5
  • # ls -la
  • test-10M
  • test-10M.md5
  • # cat test-10M.md5
  • f1c9645dbc14efddc7d8a322685f26eb  test-10M

Verify MD5 checksum

Copy test file (test-10m & test-10m.md5) to USB flash
  • # mount -t vfat /dev/sda1 /usb
  • # cp -rf test-10M test-10M.md5 /usb
  • # ls -la /usb
  • test-10M
  • test-10M.md5
Verify test file in MD5checksum
  • # cd /usb
  • # md5sum -c test-10m.md5
  • test-10M:  OK

MD5 checksum - Windows 7

  • Tool: MD5 Checksum Tool
  • Vender: NoVirusThanks
Generate MD5 Checksum




2014-11-17

TCL, Switch - Select right one through multi-options

set num 3

switch $num {
              " 1 " { puts "Monday" }
              " 2 " { puts "Tuesday" }
              " 3 " { puts "Wednesday" }
              " 4 " { puts "Thursday" }
              " 5 " { puts "Friday" }
              " 6 " { puts "Saturday" }
              " 7 " { puts "Sunday" }
              " default " { puts "Wrong Value" }
}

[Output]
  • Wednesday

TCL, File and Directory

Establish, Delete, Copy & Rename
Detect existing, Size & Type

[ALL Syntax]
file mkdir "directory_name"

file delete "directory_name"
file delete -force "directory_name"
file delete "file_name"

file copy  source-filename  target-filename
file copy -force  source-filename  target-filename

file rename source-filename  target-filename

file exists  filename
file isdirectory  filename
file isfile  filename

file size  filename
file type filename

TCL, File's Input & Output

[Procedure]
  • Open file --> Read/Write file --> Close file
[Syntax] 
  • Open ==> open filename "access"
  • Write ==> puts filename "content"
  • Close ==> close filename
[Example code]
  • set fd [open "$PATH/$var_sn.tmp.log" a] 
  • puts $fd "[time_str]: $msg"
  • close $fd
[Access Parameter List]
  • r : Reading a existing file
  • r+ : Reading & Writing a existing file
  • w : Empty a existing file,  and Writing the content.
  • w:  Establish a new file, and Writing the content.
  • w+ : Empty a existing file, and Writing & Reading the content.
  • w+ : Establish a new file, and Writing & Reading the content.
  • a : Append the content into the end of existing file, or Establish a new one.
  • a+ : Append (Read & Write) the content into the end of existing file, or Establish a new one.
End.

2014-11-05

yEd - Flow Chart tool

Payment: Free
Download place on Official web: http://www.yworks.com/en/downloads.html#yEd

This is a green software that so no need to install it into the Windows and Linux platform.
And JAVA JRE is required before the software installation.


2014-10-16

TCL, TroubleShooting

Trouble-141016a]

輸入的字串無法被餵入 Console.

Example

  • puts -nonewline $Cmd "q"
  => 輸入 q 欲離開播放程式, 但指令並沒有被下到播放程式

TCL, 特殊字串使用 e.g. Ctrl+C 的字串為 \x03

US-ASCII 控制字元

Ctrl + C ... (^C) ==> \x03 .. 字元名 End of Text(正文結束)
Ctrl + X ... (^X) ==> \x18 .. 字元名 Cancel(取消)
Ctrl + [ ... (^[) ==> \x1B .. 字元名 Escape(跳脫)

2014-09-12

Disable Sublime Text 3 version update.

Way 1: Works
Under Windows 7 64bits

Fill this in "Preferences / Settings - User


=========================
Way 2: Looks not work sometimes.
Under Windows 7 32bits

Modify "hosts" file on path C:\Windows\System32\drivers\etc

Fill 2 lines into hosts file to STOP SUBLIMETEXT UPDATES.
  • 127.0.0.1 sublimetext.com 
  • 127.0.0.1 www.sublimetext.com


2014-08-22

partition Mount & Format

MOUNT SAMBA as a Disk
  • # mkdir /mnt/smbdisk
  • # mount //10.1.1.15/public /mnt/smbdisk

Mount a Read-Only partiation to writable.
  • mount -o remount,rw /system
New a auto mount partition as format EXT3
  • fdisk /dev/hdc
    • n --> t --> w
  • reboot
  • mke2fs -j /dev/hdc1       ( Linux Debian Format: mkfs.vfat -n "name" -I /dev/hdc1" )
    • format as EXT3
  • mkdir /var2
  • e2label /dev/hda1 /var2
  • vi /etc/fstab
    • LABEL=/var2     /var2     ext3     defaults     1    2
  • mount /var2
  • reboot
Format USB disk in FAT32
  • fdisk -l  ==> find out the USB disk where is it.
  • mkfs -t vfat /dev/sda1
Format USB disk in EXT4
  • mke2fs -T ext4 /dev/sda1

2014-08-04

GreenFingers

薄荷 (Peppermint) 的種植
  • 喜戶外, 喜水多, 喜蔭涼.
  • 給水: 每天澆, 盆底多水也無害.
  • 向光: 放在有遮蔭的地方避免高溫的強光直射.
  • 生長: 只有莖, 也可另長出根. 所以生長力極強.
  • 修剪: 葉子長得不好看, 可剪掉讓它重長.
  • 施肥: 非常需要養分, 越多越飽滿漂亮.

2014-07-24

TCL, expr 判斷表示式的真假 & 值

EXPR (expressions) 判斷表示式 數學表示式 & 關係式表示式 的真(True) 假(False) 和 值(Value)

[Example Code]
  • set value1 [ expr 0==1 ]
  • puts $value1

  • set value2 [ expr 2 >=1 ]
  • puts $value2

  • set value3 [ expr 2+3 ]
  • puts $value3
[Output]
  • 0    ---> false
  • 1    ---> true
  • 5    ---> value
[說明]
  • Value 1: expr 去判斷 0 是否等於 1, 結果 0 不等於 1 的. 判斷為 假/ false.
  • Value 2: expr 去判斷 2 是否大或於等於 1, 結果 2 是大於 1 的. 判斷為 真/true.
  • Value 3: expr 去求得 2+3 的結果, 其結果為 5.

2014-06-25

Remove Bridged eth0/eth1 binding within br0

Show Binding list under br0
  • # brctl show
Remove Binding
  • # brctl delif br0 eth0
Add Binding
  • # brctl addif br0 eth0


2014-06-20

Sublime Text 3, Package - TrailingSpaces

Update:
TrailingSpaces not work on new SublimeText 3.2.2.
qasm_highlighting: Could be use this for the same function.

[ Purpose ]

  • Highlight unused Space
  • 顯示多餘空白字元.  移除可 resize file to smaller.
Combination Key [ Ctrl + Shift + P ] to call the function.


SHOW Unused SPACEs
  • Choose "Trailing Spaces: Toggle Trailing Spaces Highlighting"


REMOVE Unused SPACEs
  • Choose "Trailing Spaces: Toggle Trailing Spaces"


2014-06-18

Remove AD & ToolBar on Browsers


移除網頁綁架, 工具列 和 廣告軟體.

Tool needed: AdwCleaner

Download 1: from official link
Download 2: here

Notification
1-
FileZilla FTP Server, 從 Source Forge 下載來的安裝檔會有此類綁架網頁 (e.g. Sweet Page ) 的爛招數. 如果在安裝的過程中, 只一味的按 Next, Next. 則這些垃圾就在你沒注意時給放到電腦裡了.





2014-06-06

TCL, string trim 字串剔除

剔除所需字串前後的字元.

[Syntax]
  • string  trim  string1  char  --> 刪除 string1左右char字元.
  •                                                    不指定, 則刪除空白無效字元 \t \r \n \s
  • string  trimleft  string1 char  --> 刪除 string1左邊含有char字元
  • string  trimright  string  chars  --> 刪除 string1右邊含有char字元

[ExampleCode 1]
  • set text2 "HelloWorldPapa 111 abc 222 PapaWorldHello"

  • puts $text2\n
  • puts [ string trim $text2 "Hello"]
  • puts [ string trimleft $text2 "Hello"]
  • puts [ string trimright $text2 "Hello"]
[Output]
  • HelloWorldPapa 111 abc 222 PapaWorldHello
  •  
  • WorldPapa 111 abc 222 PapaWorld
  • World Papa 111 abc 222 PapaWorldHello
  • HelloWorldPapa 111 abc 222 PapaWorld

2014-06-03

TCL, Date & Clock

[Syntax]
  • clock  format  [ clock  seconds ]  -format  "%Y%m%d%H%M%S"  ]
  • %Y - Year with century (e.g. 1990)
  • %y - Year without century (00 - 99).
  • %m - month
  • %d - Day of month (01 - 31).
  • %H - Hour in 24-hour format (00 - 23).
  • %I - Hour in 12-hour format (00 - 12).
  • %M - Minute (00 - 59).
  • %S - Seconds (00 - 59).

2014-05-29

TCL, string map 字串取代

[ExampleCode]
  • set WiFiMAC "5C:F3:70:0F:27:A1"
  • set ReMAC [ string map { : "" } $WiFiMAC ]
  • puts "After re-MAC = $ReMAC"
[OUTPUT]
  • After re-MAC = 5CF3700F27A1

2014-05-23

TCL, eval

用途: 執行字串裏的 TCL 指令.

[ExampleCode]
  • set mama "puts iLovePaPa"
  • puts $mama       #  這裡會輸出成 puts iLovePaPa

  • eval $mama       #  這裡則會輸出  iLovePaPa
[Output]
  • puts  iLovePaPa
  • iLovePapa

2014-05-14

TCL, 變數

變數
01- 存進 變數值 裏的資料都用雙引號夾 "  " 起來.
02- 變數值 裏的資料如沒有包含空白字元, 則可以不用雙引號.
03- Set 後面只能有兩個參數.
04- 變數名子前多加一個 $ 符號, 就取用變數內容.
05- 區分英文大小寫.

2014-05-13

TCL, regexp 字串比對擷取

[Scenario A]
  • 以下例為只擷取 0 ~ 9 的數字.
set a "M28SPLL1024X40R2011VTES35D121BSIRLQF"
set result [regexp -all -inline {[0-9]+} $a]
puts [concat [lrange $result 1 end-2] [lindex $result end]]

[Output]
  • 1024  40  2011  121

2014-05-02

Sublime Text 3, Package Control


Have a useful package into Sublime Text.

Package source: http://wbond.net/sublime_packages

There are so many packages supported Sublime Text.
Have a first package installation for example.


Sublime Text 3 of Package Control installation

Turn on the Console mode on bottom of Sublime Text.

2014-04-16

VLC, Server & Player for multicast streaming.

VLC Server
version: 2.1.3 (for MS-Windows)

Configure Server to support multicast streaming.

STEP-01
  • Choose [Media] --> [Stream...]

STEP-02
  • On Open Media menu, select tab [File] and [Add...] to choose your pattern file where located on your PC HDD.

Win7, 重整硬碟, 提升系統效率百百.


WINDOWS 7

step-01:
  • 點選桌面左下角的 "開始" --> "控制台".

step-02:
  • 待 "調整電腦設定" 頁面開啟, 如下圖.
  • 選擇 "系統及安全性".

WinXP, 重整硬碟, 提升系統效率百百.


WINDOWS XP

step-01:
  • 點選桌面左下角的 "開始".
  • 滑鼠右鍵 "我的電腦".
  • 點擊 "管理".

step-02:
  • 待 "電腦管理" 頁面開啟, 如下圖.

2014-04-15

TCL, string, compare & equal 字串處理/比對

比對字串是以 Unicode 逐一比對 string1 & string2.

compare: string1 內含字元大於 string2, 則回傳 1
compare: string1 內含字元相同 string2, 則回傳 0
compare: string1 內含字元小於 string2, 則回傳 -1
equal: string1 完全等於 string2, 則回傳 1, 反之回傳 0

syntax]:
  • string  compare  string1  string2
  • string  equal  string1  string2
parameter]:
     - nocase | 比對時不分大小寫
     - length | 決定比對的長度 "length  len"

TCL, string, worldstart & worldend 字串處理/取出想要的範圍

*字串處理, 找尋單字的開頭和結尾
syntax]:
  • string  wordstart  string1  charIndex
  • string wordend string1 charIndex
example]:
     set s1 "Tcl is a powerful programming language."
     set idx1 [string wordstart $s1 12]    #<第12個字元是落在 powerful>
     set idx2 [string wordend $s1 22]     #<第22個字元是落在 programming>
     puts [string range $s1 $idx1 $idx2]

output]:
     powerful programming

2014-04-14

TCL, string, first & last 字串處理/搜尋

字串搜尋

* FIRST - 找到第一個 (Find first one which be captured)
syntax]:
  • string  first  string1  string2  startIndex?
example]:
  • set s1 "where tcl is, here tcl is"
  • puts [ string first "tcl" "$s1" ]
  • puts [ string first "tcl" "$s1" 7 ]
output]:

  • 6          #<第1個 tcl 在哪? 由 w 開始算且含空白字元, 是落在 6>
  • 19        #<由第7個字元開始算第1個 tcl 在哪? 是落在 7>

* LAST - 找到最後一個 (Find last one which be captured)
syntax]:
  • string  last  string1 string2  lastIndex?
example]:
  • set s1 "where tcl is, here tcl is"
  • puts [ string last "tcl" "$s1" ]
  • puts [ string last "tcl" "$s1" end-6 ]
output]:
  • 19        #<最後1個ˋtcl 在哪? 是落在第 19 個字元>
  • 6          #<由倒數第6個字元起始, 已越過第2個 tcl, 所以是第1個 tcl, 也就是第 6 個字元>

2014-04-12

TCL, Library replace

Path: C:\Tcl\lib

覆蓋 lib 時, 最好是先砍掉原安裝後內有的後, 再Copy過來, 可避免相同套件且不同版本間互相干擾.

如上圖, 原來舊有的 Lib 裡只有 sqlite3.7.17, 如果直接覆蓋原有的 Lib 資料夾, 則新舊將會同時存在, 會造成原有 TCL 程式在呼叫 Library 時, 撈到不相容的 SQL 版本, 而產生錯誤.

2014-04-11

smp8654, two three things


AP Code Boot up time.
Condition:
  • version: 2.9.29.11
  • Time record till Login shows up.
1 min -- Without HDD Scan
9 min -- With HDD Scan

Enable Debug mode

Enable detail event on console
# mount -o remount,rw /flash
# vi /flash/apps/TelstraClear/run
   On line 21 there should be LOG_MODE=null
   Change this line to LOG_MODE=console
   Save the file

Get more application event on console.
1. Edit /flash/apps/TelstraClear/conf/xlet.properties
2. On line 3 if debuggingLevel=INFO, change this to debuggingLevel=DEBUG
3. On line 6 if logging=false, please change this to logging=true

Reboot unit, You should see more logging in the log console.

Important note that
Above settings should return default to disable the DEGUGGING MODE.
DEBUGGING causes STB busing and A/V lag.


TCL, string 字串處理

STRING parameters
  • append: 字串串接
  • length: 取字串長度
  • bytelength: 取自串的位元數
  • index: 擷取單一字元
  • range: 擷取字串中的一段字
  • tolower: 將字串裡的英文由大寫轉換為小寫
  • toupper: 將字串裡的英文由小寫寫轉換為大寫
  • totitle: 將字串裡的第一個字母轉為大寫, 其他轉為小寫
  • map: 字串取代
  • trim: 剔除空白字元
  • repeat: 字串重製
  • split: 字串轉清單
-APPEND
syntax]:  append  varName  string1  string2 .... stringN
example]:
     set s1 "Hi!Everyone"
     append s1 "... Good morning."
     put $s1

output]:
     Hi!Everyone... Good morning.

2014-04-10

TCL, get version (8.4, 8.6 or latest one)

Under tclsh
# tclsh
% puts $tcl_version
% 8.4

Version include build info.
# tclsh
% puts $tcl_patchLevel
% 8.5.18

Under DOS
# echo "puts $tcl_version;exit 0" | tclsh
invalid command name "puts 8.4; exit 0"

2014-04-03

TCL, PROC

Syntax:  proc name args body

name - 給新程序一個名子
args - 參數清單. 不帶參數也可, 放一組空大括號 {} 即可.
body - 呼叫程序時要被執行的程式碼
proc add {op1 op2} {
     puts [expr $op1 + $op2]
}

add 5 6
add 3 2
add 1 2

Output:
11
5
3

2014-03-27

TCL, While / For / Foreach

Example code for While, For

WHILE

package require Tk
set i 0
while {$i < 10} {
button .btn$i -text "Button$i" -command "puts $i"
pack .btn$i
incr i                                                 # 每執行一次就將變數值+1
}

TCL, the List ( lindex, lrange, linsert, llength & lappend )

Syntax: lindex, lrange, linsert, llength, lappend, lsort & lsearch.

Example:
set list1 [list motocycle car bus truck airplane cablecar]

puts $list1
# output:  motocycle car bus truck airplane cablecar

puts [lindex $list1 end-2]
# output:  truck

puts [lrange $list1 1 3]
# output:  car bus truck

puts [linsert $list1 2 taxi]
# output:  motocycle car taxi bus truck airplane cablecar

puts [llength $list1]
# output: 6

lappend list1 all, I don't like
puts $list1
# output:  motocycle car bus truck airplane cablecar all, I don't like

2014-03-13

Callback Windows Desktop

Windows Desktop is gone!!!
([顯示桌面] , 不小心誤刪了, 這時 怎麼辦?)

OS: Windows XP

Fix it:
Step1- Go to following path.
           C:\Documents and Settings\User\Application Data\Microsoft\Internet Explorer\Quick Launch
step2- New a text file contains below, and named that file as “Show Desktop.scf”.
           [Shell]
           Command=2
           IconFile=explorer.exe,3

           [Taskbar]
           Command=ToggleDesktop       

See, it is there.

F.A.C.K Skype AD remove be


Block a web "https://apps.skype.com" through IE.
  • On Internet Explorer (version 11 or previous) 
  • Go to Internet Options --> Security --> Limited Web Site
  • Click "Web site" and then insert "https://apps.skype.com" to block list.
  • Done



2014-03-11

Ericssion/MS MediaRoom

History

01- Ericssion deployed the Microsoft Mediaroom service to Taiwan CHT in 2013 April. YouTube

02- Telfornica's mediaroom also deployed by Ericssion.

03- Microsoft Mediaroom (IPTV) department be merged by Ericession in Mid 2013.

04- Then the Microsoft can pay more attention with their XBox business.

05- Midiaroom already deployed to Telecoms of AT&T, Deutsche Telekom & Telefonica for VoD service.

06- Amount 2200 million STBs are subscribed for 11 million users around worldwide.

07- Taiwan Taichung MSO 威達電訊 deployed Mediaroom STB of VeeTV in 2010 October.

Feature

a- 3D EPG

b- Multi-Screens

c- Multiview

d- Picture in Picture

e- TV sharing over different devices with single account.

f- Interactive Gaming

g- Social network through MS Windows Live on TV.

h- Booking

i- VeeTV function. YouTube



2014-03-10

GPU-z

Version: 0.7.7

Purpose: Detect Graph Card detail and show you all the information your desktop/laptop running.
Following captured from my laptop Acer TravelMate 8371. As you saw, do not play the 3D game with this one.

To see maximum performance your Graph Card supported.
Package required: DirectX SDK

  • Install DirectX SDK before execute GPU-z.
  • Click a "Question" button beside "Bus Interface".
  • Wait a while moment, real data will show. 

GPUz, Get it form here
DirectX SDK, Get it from here

Linux CentOS-5.3 mounted NTFS

Operated under System: CentOS 5.3


Source code request:
01- fuse mount: fuse-2.7.3.tar.gz
02- ntfs-3g-2009.4.4.tgz


step-01: Software of "Fuse" installation
     # tar xzvf fuse-2.7.3.tar.gz
     # cd fuse-2.7.3
     # ./configure
     # make
     # make install
     # /sbin/modprobe fuse
        (no wrong message shows up)


step-02: Software of "ntfs-3g" installation
     # tar ntfs-3g-2009.4.4.tgz
     # cd fuse-2.7.3
     # ./configure
     # make
     # make install


step-03: Mount NTFS
# ntfs-3g /dev/hda1 /mnt/hddidk -o locale=zh_TW.UTF-8


Linux CentOS TFTP Server bring up


Enable TFTP server
1- # vi  /etc/xinit.d/tftp
       disable =yes          -----> default is NO


2- # mkdir  /tftpboot     -----> create a directory for TFTP, default is /tftpboot.


User Login
$  tftp  [Server IP]
    tftp>  get  /tftpboot/filename

Linux CentOS TestLink v1.9.2 installation

Requirement:
testLink version 1.9.2
php -5.2.0 or higher


Reference: http://farwill-linux.blogspot.com/2011/03/install-testlink.html

Install TestLink

1. yum install mysql
yum install mysql-server


2. Add CentOS-Testing repo


3. yum install php
yum install php-mysql
yum install php-gd
yum install php-ldap


4. service mysqld start
chkconfig mysqld on
5. service httpd start
chkconfig httpd start


6. cp testlink-1.9.1.tar.gz /var/www/html/
cd /var/www/html/
tar zxvf testlink-1.9.1.tar.gz
mv testlink-1.9.1 testlink
rm testlink-1.9.1.ta.gz


7. edit /etc/php.ini
session.gc_maxlifetime = 2400
max_execution_time = 120
memory_limit = 64M


8. service httpd restart


9. go to "http://localhost/testlink/


10. step by step install 

TCL/TK v8.6 installation

Requirement:
ActiveTcl 8.5.7.0 ==> http://www.activestate.com/activetcl/downloads/
OS Linux & MS-Win

With MS-Windows7
Step-1 Environment Variable modification (設定環境變數)

  • Right-click [My Computer] --> [Advanced System Settings] --> [Environment variable]
  • Focus on System variable field
  • Modify "Path" within column Variable, and insert ";C:\Tcl\bin" into the end of line.
  • Such as "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\SecureCRT;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Tcl\bin"
Execution:
C:\> tclsh [*.tcl source code] --> for Text mode
C:\> wish [*.tcl source code] --> for GUI

2014-03-07

dupeGuru, find out all duplicate/garbage files

Web site: http://www.hardcoded.net/dupeguru/
OS supported: Windows 32/64bits, Mac OS X & Linux Ubuntu

Main GUI


2014-03-06

Linux IR - Transmitter & Receiver


Chapter: IR - Transmitter

Java print UTF8 in Traditional Chinese

Compile Java source in Command Prompt Mode (Dos mode)

Command:
# javac -encoding UTF8 JungleTest1.java
# java JungleTest1



//===== Example Code =======



2014-03-05

Java assignment operator

Code Example1
//===============================
public class AssignTest {
public static void main(String [] args) {
int a = 1;

System.out.println( a += 2 );
System.out.println( a -= 1 );
System.out.println( a *= 22 );
System.out.println( a /= 7 );
System.out.println( a %= 3 );
}
}
//===============================

Output
//===============================
3          // a=1, 1 與等號右邊的 2 相加後的值指派給變數 a, 此時 a 為 3.
2          // a=3, (3-1=2), 所以此時 a 為 2.
44        // a=2, (2*22=44), a = 44.
6          // a=44, (44/7=6), a = 6.
0          // 餘數???
//===============================

Note: 單一等號 (=) 為表示指派, 連續兩個等號 (==) 表示相等性.


Code Example2
//===============================
public class ForDemo1 {
public static void main( String [] args ) {
int sum = 0;
int i;

for ( i = 1; i <= 10; i++ ) {
sum += i;
}
   System.out.println("1+2+...+99+10=" + sum);
}
}
//===============================

Output
//===============================

1+2+...+9+10=55

//===============================

算式拆解 ( sum += i )

???



Sublime Text v3056, Turn OFF the Auto Upgrade Feature.

Important note that do not upgrade the version from SublimeText own upgrade function.
"Help --> Check for updates...", due to nothing is free.

Software needed
a- OS Windows 7 with SP1.
b- Original SublimeText 3056 installation package.
c- A unlimited SublimeText 3059 execution file, like "sublime_text_sled_2_x86.exe".

Process
1- Assume you have done the SublimeText 3056 installation, so you can ignore above items a & b.
2- Rename "sublime_text_sled_2_x86.exe" to "sublime_text.exe.
3- Move it to folder "Program File / Sublime Text 3" and then replace original one.
4- Your SublimeText version also move to v3059.
5- Den Den... You will not see any upgrade message pop up anymore.


2014-03-04

Remove AVG Safeguard Toolbar

There you could also refer this AVG web page to remove "AVG Safeguard Toolbar" through a tool that provided by AVG themselves. (an evil company, everyone know what they thinking.)

  1. Download the AVG Browser Configuration Tool.
  2. Run the downloaded file AVG_Browser_configuration_tool.exe.
  3. Click Accept to confirm the license agreement.
  4. Click Continue to start the removal process.
    Note: This will close all your browser windows.
  5. You may receive a prompt from Internet Explorer or other browsers about your preferred search engine.
  6. Click Exit to close the tool.
Or download that tool from here.


Java Reserved Word (保留字/關鍵字)


abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while

2014-02-27

Java example code for "For Loop"

編解碼的轉換

公式:
y = a * x + b
m = y % n
r = m + diff


y: a * x + b
x: 字元的原始編碼.
a: 為 unicode 編碼 97 ( Variable a ), 隨機整數 0~9.
b: 依次遞增 1 ( Variable b ), 隨機整數 0~9.

m: 餘數, 由 y 除以 n 的餘數取得, 值應在 0~25 之間的整數.
n: 所要轉換的字元數量, 值為 26 (英文字母數). n 為重複 26次.

r: 結果
diff: unicode 編碼系統的差值 97, 因為英文字由 a 取得開始.

由上, 因此餘數 0 的字元會為 a, 餘數 1 的字元會為 b, 餘數 2 的字元為 c, ...., 依此類推.
到餘數 25 字元應為 z.








Unicode

Unicode 編碼中 "a" 為 97. Why???

bin (Binary): 二進位 / 0.1
oct (Octal): 八進位 / 0.1.2.3.4.5.6.7
dec (Decimal): 十進位 / 0.1.2.3.4.5.6.7.8.9
hex: (Hexadecimal): 十六進位 / 0.1.2.3.4.5.6.7.8.9.A.B.C.D.E.F

依下表得知 unicode 的 "a" 為十進位的  "97"

unicode 和 dec 的轉換

Reference Web:  Unicode Character Table



Java 的二三事 - 迴圈 loop

迴圈要項
  • 設定控制變數 Control Variable
  • 條件 Condition
  • 調整控制變數值 Control Value
Example for While:
//========== -begin- =============
public class WhileTest {
   public static void main (String [ ] args) {
         int i  = 10;                                                 //==> 設定控制變數
         while (i > 0) {                                            //==> 條件
              System.out.println (i);
              i --;                                                      //==> 調整控制變數 (由 i 值遞減)
          }
    }
}
//========== -end- ==============

Example for For:
//========== -begin- =============
public class ForTest {
     public static void main ( String [ ] args ) {
           for ( int i = 10; i > 10; i-- ) {                    //==> 要項全寫在小括弧內.
                System.out.println ( i );
           }
      }
}
//========== -end- ==============

Example output:
10
9
8
7
6
5
4
3
2
1

習慣於 While 與 For 的使用

for 迴圈通常用於具有明確重複次數的迴圈.
      因為全部的控制機制都放在 for 之後的小括弧中.

while 迴圈用法為較不明確的重複次數.
        程式通常被設計成一直等待使用者的輸入, 迴圈才會結束.




2014-02-25

Java 的二三事 - 運算子 operator

07- 等號 ( = ), 屬於指派運算子, 就是把等號右邊的值給左邊的 variable (變數), 如果右邊是 object (物件) , 變數就會得到物件的參考.

  • int a = 11;
  • a += 33;  // 11+33, a 等於 44.
  • a -= 22;  // a 為 44, 故 44-22=22, a 等於 22.
  • a *= 11;  // a 為 22, 故 22 * 11 = 242 , a 等於  242.
  • a /= 44;  // a 為 242, 故 242 / 44 = 5.5, a 取得的整數為 5.
  • a %= 55;  / a 等於 5 (% 是餘數, 但不曉得怎求得 ???)

06- boolean 與 關係運算子的 true & false
  • int a = 11;
  • int b = 22;
  • boolean c = a >= b; // a 非小於或等於 b, 所以 c 等於 false.
  • boolean d = a <= b; // a 是小於或等於 b, 所以 d 等於 true.
  • boolean e = c == d; // c 是 false, 而 d 是 true,  故 c 不等於 d, 所以 e 等於 false.
  • boolean f = a != b; // a 確實是不等於 b, 所以 f 等於 true.
05- ( ! ) 邏輯補數運算子, 會把 true 變成 false, false 變成 true.
  • boolean a = true;
  • boolean b = !a // a is true --> b becomes false
  • boolean c = !b // b becomes false --> c is true
04- 每一行程式皆以分號 ( ; ) 結尾, 以分號結尾的程式碼稱為 statement (陳述).

03- variable 變數 - 同 method 方法.

02-  method 方法 - 以英文小寫開頭, 若有多個英文單字組成, 則採取小寫駝峰型撰寫 (lower camel case). example: hellowWorld.

01- class 類別 - 以英文大寫開頭, 若有多個英文單字組成, 則採取大寫駝峰型撰寫 (upper camel case). example: HellowWorld

Java 中英文術語對照

control variable - 控制變數
condition - 條件

infinite loop - 無窮迴圈
for loop - for 迴圈
while loop - while 迴圈

expression -  運算式
operand - 運算元
operator - 運算子

declare - 宣告
identifier - 識別字
statement - 陳述
local variable - 區域變數
method invocation - 方法呼叫

class - 類別
field - 屬性
constructor - 建構子
method - 方法
string - 字串

variable - 變數
object - 物件
literal - 字面常數
subclass - 子類別
superclass - 父類別

boolean value - 布林值
integer - 整數
inherit - 繼承
inheritance - 繼承
thread - 執行緒

Java basic data types, objects

資料型態 Data Type (8)

關鍵字 (keyword) ----- 型態類型 (type) ----- 位元數 (bits) ==> Example

byte ----- 整數 ----- (8bits)
short ----- 整數 ----- (16bits)
int ----- 整數 ----- (32bits) ==> int a = 2;
long ----- 整數 ----- (64bits)

float ----- 浮點數 ----- (32bits)
double ----- 浮點數 ----- (64bits) ==> double a = 2.0;
boolean ----- 布林值 ---- (1bit) ==> boolean a = trun;
char ----- 字元 ---- (16bits) ==> char a = '2';


物件 Object (11)

回傳型態 (return types) ---- 名稱 (name) ----- 功能 (feature)

Object ----- o.clone() ----- 複製回傳 o 本身的拷貝
boolean ----- o.equals(Object obj) ------ 判斷 obj 是否與 o 相同
void ------ o.finalize() ----- 呼叫資源回收者檢查此物件是否應該被回收
Class<?> ----- o.getClass() ----- 回傳類別名稱
int ----- o.hashCode() ----- 回傳物件的雜湊碼
void ----- o.notify() ----- 喚醒等待中的單一執行緒 (thread)
void ----- o.notifyAll() ----- 喚醒等待中的所有執行緒
String ----- o.toString() ----- 回傳物件的字串表達形式
void ----- o.wait() ----- 使 o 的執行緒進行等待
void ----- o.wait(long timeout) ----- 使 o 的執行緒進行等待
void ----- o.wait(long timeout, int nanos) ----- 使 o 的執行緒進行等待


2014-02-17

JAVA 的存取修飾元


[修飾元] - [權限]

public - 皆可存取
private - 在相同的 class 才可以存取
default - 在相同的 package 的 class 才可以存取
protected - 在相同的 package 的 class 才可以存取. 不同的 package, 需有繼承關係才可.

2014-02-13

Eclipse Text Searching

Search the text what you would like to show on workspace.

On menu bar, choose Search --> File to open the Search window.


Unassociate File Types in Windows 7

Purpose: 在 Win7 取消特定附檔名被預設程式開啟

Tool filename: Unassoc (v1.4)
Download from here: https://www.dropbox.com/s/z2pxitiru4md5uf/unassoc_1_4.zip
  • This is a green software, do not need to to the installation.
  • Just run "Unassoc.exe", and that operation UI shows up.

  • Select the file type from the list
  • Click " Delete file type ".
  • The user-specific association for the chosen file type is now removed from the registry. The system will now use the global file association settings.


2014-02-12

Eclipse Basically

Establish your first JAVA project within IDE Eclipse.
  • Choose " File --> New --> Java project ".
  • Fill " lu.ide.first " in Project name field.
  • Make sure a option of " Create separate folders for sources and class file "is checked on Project layout.
  • Press " Finish " button to create your first JAVA project.

2014-02-11

Installing RXTX for Serial Communication with Java in MS platform.



01- Get RXTX from here.

  • Filename: rxtx-2.1-7-bins-r2.zip
  • Link: https://www.dropbox.com/s/gt061ayzxe4kaoi/rxtx-2.1-7-bins-r2.zip
02- Unzip that file, then you will see 3 files on following each path.
Path1: rxtx-2.1-7-bins-r2/Windows/i368-mingw32/
  • rxtxParallel.dll 
  • rxtxSerial.dll

Path2: rxtx-2.1-7-bins-r2/
  • RXTXComm.jar
03- Copy there
2 files rxtxParallel.dll & rxtxSerial.dll to [ C:\Program Files\Java\jdk1.7.0_45\jre\bin ]
1 file RXTXComm.jar to [ C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\ ]



2014-02-06

JAVA Programming Reference from Web


Serial Communication in JAVA with Example Program / Link

Ken Yang 筆記 / Link

Eclipse 簡介與教學 / Link