HTML/Javascript區塊

最近文章
星期二 三月 01, 2011
vi 文字編輯器練習
星期二 三月 01, 2011
輸出入導向練習 及 Logical AND / Logical OR 判斷
星期二 三月 01, 2011
Shell 內變數定義練習 及 命令代換練習
星期二 三月 01, 2011
使用 history 指令觀察指令歷程

標籤雲

android cloud_computing hadoop java linux nagios network other solaris vmware weka windows

文章分類與RSS
文章搜尋

vi 文字編輯器練習

vi 文字編輯器練習 [Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

輸出入導向練習 及 Logical AND / Logical OR 判斷

輸出入導向練習 及 Logical AND / Logical OR 判斷[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

Shell 內變數定義練習 及 命令代換練習

Shell 內變數定義練習 及 命令代換練習[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

使用 history 指令觀察指令歷程

使用 history 指令觀察指令歷程[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

使用 grep 指令過濾檔案內容

使用 grep 指令過濾檔案內容[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

在 Linux 系統內搜尋檔案練習

在 Linux 系統內搜尋檔案練習[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

基礎指令練習 複製檔案, 刪除檔案 建立 Link

基礎指令練習 複製檔案, 刪除檔案 建立 Link[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

基礎指令練習 建立檔案 及列出檔案內容

基礎指令練習 建立檔案 及列出檔案內容[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

基礎指令練習 cd 及 ls 指令

基礎指令練習 cd 及 ls 指令[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

Lab: man, info 指令練習

Lab: man, info 指令練習[Read More]

Filed under Linux認證 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

使用mmencode 回復編碼

使用mmencode 回復編碼 mime64 及 quote-print 兩種常用格式
先安裝含有mmencode的套件

實作範例
mime64編碼
#echo "104 速配快報,這樣可不可以呢 ?" | mmencode

quote-print 編碼
#echo "104 速配快報,這樣可不可以呢 ?" | mmencode -q

解回來 mine
#echo "MTA0ILN0sHSn1rP4LLNvvMulaaSjpWmlSKlPID8K" | mmencode -u

解回來 qp
#echo "104 =B3t=B0t=A7=D6=B3=F8,=B3o=BC=CB=A5i=A4..." | mmencode -q -u

Filed under 網路管理先修 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

Java 上課小記

Loop 迴圈
  • 讓某個語法重複執行
  • for 的後面沒有 ; 所以要執行的指令如果超過兩句, 要寫大括號確定執行範圍,不然只執行第一個指令.


for(變數初值設定條件; 變數增量運算)
{
        敘述
}

while迴圈
  • 條件成立時執行,直到條件被破壞


while(條件)
{
     
敘述
}


Lab: while
public class WhileLoop {
   
   public static void main(String[] args) {

       int i=0;

       while(i<10)
       {
           System.out.print("*");
           i++;
       }

   }

Lab: while

import java.util.Scanner;

public class Input2 {

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);

       int w,h,ans=1;

       while(ans == 1)
       {
    System.out.print("Height:");
    h = sc.nextInt();
    System.out.print("Weight:");
    w = sc.nextInt();

    double bmi = w / Math.pow(h/100.0,2);
    System.out.println("BMI="+bmi);
       System.out.println("continue ?: (Type 1:continue 0:exit)");
       ans = sc.nextInt();
       }
   }

}


do  while
  • 先敘述再判斷


語法
do
{
    敘述
}while(條件);

Lab: do  while

import java.util.Scanner;

public class Input2 {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);

       int w,h,ans=1;

       while(ans == 1)
       {
   System.out.print("Height:");
   h = sc.nextInt();
   System.out.print("Weight:");
   w = sc.nextInt();

   double bmi = w / Math.pow(h/100.0,2);
   System.out.println("BMI="+bmi);
           do
           {
           System.out.println("continue ?: (Type 1:continue 0:exit)");
           ans = sc.nextInt();
           }while( !(ans == 0 | ans == 1));
       }
    }

}


Lab:  骰子

public class Loop {
   public static void main(String[] args) {
       //Math.random() 產生 0 ~ 1 之前的浮點數
        // *6 -- 6 為間距,  1 為 起始值
       int d = (int)(Math.random()*6)+1;
       System.out.println(d);
    }
}


Lab: 四顆骰子

public class Loop {
   public static void main(String[] args) {
       //Math.random() 產生 0 ~ 1 之前的浮點數
        // *6 -- 6 為間距,  1 為 起始值
       int d;
       
           for(int i = 0; i<4; i++)
           {
           d = (int)(Math.random()*6)+1;
           System.out.println(d);
           }
    }
}


Lab: 四顆骰子 並統計總數

public class Loop {
   public static void main(String[] args) {
       //Math.random() 產生 0 ~ 1 之前的浮點數
        // *6 -- 6 為間距,  1 為 起始值
       int d,s=0;
       
           for(int i = 0; i<4; i++)
           {
           d = (int)(Math.random()*6)+1;
           System.out.println(d);
           s += d;
           }
      System.out.println("Sum="+s);
    }
}


Lab:


public class Loop {
   public static void main(String[] args) {
       //d 用來產生點數, s用來加總, c 用來算次數
       int d,s=0,c=0;
        
        //計算 丟幾次骰子, 才丟到 16, 沒有丟到16 就繼續
       while(s != 16)
       {
               //每丟完一次, s 都要歸零
               s=0;
               //利用 for 迴圈 丟四個骰子
               for(int i = 0; i<4; i++)
               {
                    //Math.random() 產生 0 ~ 1 之前的浮點數
               // *6 -- 6 為間距,  1 為 起始值
               d = (int)(Math.random()*6)+1;
               //列出骰子點數
               System.out.println(d);
               //加總 骰子 的點數
               s += d;
               }
               //每丟完一次, 累積丟骰子的次數
               c++;
           //列出 骰子的總數
          System.out.println("Sum="+s);
           //列出第幾次丟骰子
          System.out.println("第"+c+"次");
           }
     //列出 總共丟幾次
    System.out.println("總共:"+c+"次");
    }
}

if 判斷式

語法
if(條件)
{
    敘述
}
else
{
    敘述
}

Lab: if 判斷式

import java.util.Scanner;
public class Ex_If {
   public static void main(String[] args)
   {
       //利用 Scanner 產生一個輸入
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter Number:");
       //定義 n 為使用者輸入的數字
       int n = sc.nextInt();
       if(n == 0)
           System.out.println("Zero");
       else
           
               //將 n 除以2 判斷 餘數是否為 0
           if(n % 2 == 0)
               //如果餘數為 0 就是偶數
               System.out.println("偶數");
           else
               //如果餘數不0 就是奇數
               System.out.println("奇數");
   }
}

Filed under 程式/資料庫先修 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

module blacklist /etc/modprobe.d/50-blacklist.conf 相關小記

module blacklist /etc/modprobe.d/50-blacklist.conf 相關小記

隨著 floppy 的沒落, 現在一般的家用 PC 已經慢慢預設沒有內建 floppy

但是如果沒有在 BIOS 設定內 disable floppy

就會在開機的時候出現相關 log

kernel: [   31.784003] end_request: I/O error, dev fd0, sector 0

解決方式

1.  至 BIOS 設定 disable floppy

或是

2.  將 floppy 列入模組掛載的 blacklist ( 黑名單)

OS: openSUSE 11.3

#vi   /etc/modprobe.d/50-blacklist.conf

加入


blacklist   floppy



^___^

Filed under 網路管理先修 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

Java 學習小記

Notes
  • - System.out.println
    • 顯示文字並換行
  • - System.out.print
    • 顯示文字但是不換行,緊接下去顯示
  • - main() 方法
    • Java 以 main() 作為程式的主體
    • 在大括號{ } 所涵蓋的所有程式, 稱為程式區塊 (block), 又稱為main()方法 (main method)
    • 在Java程式中, 一個小的處理"工作"的單位,稱為敘述(statement), 以 ; 分號為結束. 會根據順序執行
  • - 縮排(indent)
    • 可以使用空白鍵或是Tab按鍵
    • 有助於程式的可讀性
  • - 註解
    • // 以後視為註解
      /* 到
      也是視為註解
      */
  • - 類別(class)
    • Java 程式當中, 最少必須有一個類別
    • 撰寫Java程式都會在程式的一開始加上class,作為程式區塊的開始
  • 字面值(literal)
    • 泛指字元,字串,數字等各種資料型態
    • 可以分為
      • 文字literal
        • 字元literal(character literal)
          • 由單一字母所構成
          • 使用單引號' ' 表示
        • 字串literal
          • 由2個或是2個以上字元連接所構成
          • 使用雙引號" " 表示
      • 數值literal
        • 整數literal(整數常數)
          • 除了使用10進制以外,也可以使用 8進制(在數字最前面加上0,或是16進制(在數字最前面加上0x))
        • 浮點literal(浮點數常數)
  • 單字(token)
    • Java語言由一個一個單字元件所構成
    • 具有特定意義的文字
    • 可以細分為
      • literal (字面值)
      • 關鍵字(keyword)
      • 識別字(identifier)
      • 運算子(operator)
      • 間隔字(例如逗點)
  • - 跳脫字元
    • 單一字元無法表示的特殊文字, 前面加上 \ 符號
    • 用來顯示特殊字元, 或是進行一些動作
    • \b backspace
    • \t  tab
    • \n  換行
    • \f  換頁
    • \r  歸位(return)
    • \'  單引號
    • \"  雙引號
    • \\  倒斜線
    • \uhhhh  以16進位hhhh所表示的文字碼(Unicode)
  • 字元碼(character code)
    • Java 採用Unicode
    • 如果是 Big5, 在Linux可以使用 iconv來轉碼. 例如 iconv -c -f Big5 -t utf-8 Sample6.java > Sample6utf8.java

Filed under 程式/資料庫先修 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg

動畫桌布xwinwrap with openSUSE 11.3

動畫桌布xwinwrap with openSUSE 11.3

今天看到 zenix 在展示動畫桌布
覺得很有趣, 感覺上在推廣上面很有幫助, 就馬上跟他請教製作方式

zenix 也馬上在聚會結束後, 使用mail 教授大家方式

需求 compiz, xwinwrap, mplayer, zenity

安裝 xwinwrap  使用 OneClick Install

# OneClickInstallUI http://software.opensuse.org/ymp/home:malcolmlewis:Miscellanous/openSUSE_11.3/xwinwrap.ymp

檢查 zenity 是否安裝 
# zypper search zenity
Loading repository data...
Reading installed packages...

S | Name                | Summary                           | Type   
--+---------------------+-----------------------------------+--------
  | octave-forge-zenity | ZEnity                            | package
i | zenity              | GNOME Command Line Dialog Utility | package
  | zenity-lang         | Languages for package zenity      | package

以一般使用者建立 script
>vi ~/.gnome2/nautilus-scripts/動畫桌布


#!/bin/bash
function XWINWRAP
{
   FILE_NAME=$1
   if [ -z $FILE_NAME ];
   then
       exit;
   else
       killall xwinwrap
       xwinwrap -ni -o 0.3 -fs -s -st -sp -b -nf -- mplayer -loop 0 -wid WID  -quiet "${FILE}" &
       # -nosound加在mplayer後可以關掉聲音
       # -- 後面為執行的指令, smplayer 不適用, 所以使用 mplayer來播放
       # -o 0.4是透明度,可以自己調 數字越小越透明
   fi
}
ZENITY=$(which zenity)
select_file="請選取影片檔"
error_nofiles="未選取檔案"

FILE=`$ZENITY --file-selection --title="$select_file" --file-filter="videos | *.wmv *.avi *.mkv *.flv *.mp4 *.rmvb"`
#只要是mplayer可以播的,都可以加進去這後面(我只加常用格式)

case $? in
   0)
       XWINWRAP $FILE
       ;;
   1)
       echo "$error_nofiles"
       killall xwinwrap
       ;;
   -1)
       echo "$error_nofiles"
       ;;
esac

給予適當的權限
> chmod a+x ~/.gnome2/nautilus-scripts/動畫桌布




之後只要按滑鼠右鍵
命令稿 --> 動畫桌布 ,選取影片檔案
就可以有動畫桌布

要停止影片
就再按滑鼠右鍵
命令稿 --> 動畫桌布 ,不選取影片檔案
點選取消

動畫桌布就會停止

Filed under 網路管理先修 | 0 迴響 | Permalink funP udn Yahoo! Delicious Digg