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