上禮拜五跟這裡拜五整理了一下花圃,因為這花圃是大家網路組共同維護的,但是目前是由我的老師負責維護,好像其他老師都不太會管這方面的事情,所以我們老師很熱心的每個禮拜都跟我們一起整理花圃,這學期呢,交接給我們碩一這群學生,不過現在還是只有我們老師的學生下來整理花圃,希望以後可以號招更多人下來幫忙,底下就是我們的花圃照片 宗翰在整理花圃
我們的花圃跟後面的不太一樣吧,我們的比較整齊
我的老師在那邊整理,哈哈,被我偷拍
[Ubuntu] 安裝 apache php5 遇到的問題
很奇怪的,今天在安裝 apache2 跟 php5 想說很簡單,可是安裝好,寫測試檔測試的時候,發現當會變成下載 php5 的檔案,然後我看了一下 apache2.conf 觀察到如下
檢查 /etc/apache2/mods-enabled 內有沒有php5.conf , php5.load若沒有, 請 sudo a2enmod php5 重新啟動 apahce2 sudo /etc/init.d/apache2 restart http://www.ubuntu.org.tw/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=5298&forum=9
[phpBB2] 2.0.22 -> 2.0.23 安全性修正版本釋出
我在竹貓星球看到這個消息的,自己本身有在玩 phpBB2 的系統,其實這套是我學 php 的開始,當初架設漫畫網站,就是提供給大家一個漫畫平台,不過後來倒了,因為自己 php 功力沒有像今天有基本的基礎,所以就沒在繼續經營了,不過我想這不會影響我用 phpBB 這套免費的系統,然而我還在這系統開發跟 Gene6 FTP Server 整合的外掛,自己無聊亂寫的,不過這不是正題,底下就是轉錄自竹貓星球的文章。
[Fix] Correctly re-assign group moderator on user deletion (Bug #280) [Fix] Deleting a forum with multiple polls included (Bug #6740) [Fix] Fixed postgresql query for obtaining group moderator in groupcp.php (Bug #6550) [Fix] Selected field on first entry by default for font size within posting_body.tpl (Bug #7124) [Fix] Adjusted maxlength parameters in admin/styles_edit_body.tpl (Bug #81) [Fix] Fixed html output in make_forum_select if no forums present (Bug #436) [Fix] Fixed spelling error(s) in lang_admin.php (Bug #7172, #6978) [Fix] Correctly display censored words in admin panel (Bug #12271) [Fix] Do not allow soft hyphen \xAD in usernames (reported by Bander00) [Fix] Fixed the group permission system’s use of array access [Fix] Simple group permissions now work properly [Fix] Fix inability to export smilies (Bug #2265) [Fix] Fixing some problems with PHP5 and register_long_arrays off [Sec] Fix possible XSRF Vulnerability in private messaging and groups handling 資料來源: http://www.phpbb.com/community/viewtopic.php?f=14&t=772285 http://phpbb-tw.net/phpbb/viewtopic.php?f=2&t=50362
[Read More]
[Java] 判斷字串是否是整數
有時候必須知道輸入的字串是否是整數,如果不是的話,就要重新輸入,這有兩種作法 第一種是使用 try … catch … finally 的方法,如下
public class test
{
public static void main(String args[])
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.print("請輸入你要的數字:");
int test = Integer.parseInt(buf.readLine());
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e.toString() + "陣列程式發生錯誤");
}
catch(ArithmeticException e)
{
System.out.println(e.toString() + "數學發生錯誤");
}
catch(Exception e)
{
System.out.println(e.toString() + "程式發生錯誤");
}
finally
{
System.out.println("執行成功");
}
}
}
另外一種方法,是利用 while 然後利用 Character.isDigit 的方法public class test2
{
public static void main(String args[])
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
String price;
boolean num = false;
try{
while(!num)
{
System.out.print("請輸入你要的數字:");
price = buf.readLine();
char[] price_array = price.toCharArray();
for(int index=0; index < price.length(); index++)
{
if(!Character.isDigit(price_array[index]))
{
System.out.println("您不是輸入數字");
break;
}
else
{
System.out.println("您輸入正確的數字了");
num =true;
}
}
}
}
catch(Exception e)
{
System.out.println(e.toString() + "程式發生錯誤");
}
}
}
[/code]
PTT 的 java 版的 TonyQ 提供另一種寫法
public class test3
{
public static void main(String args[])
{
try
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("請輸入數字:");
String inputStr = input.readLine();
while (inputStr == null || !inputStr.matches("[0-9]+"))
{
System.out.print("輸入錯誤,請重新輸入數字:");
inputStr = input.readLine();
}
int num=Integer.parseInt(inputStr);
System.out.println("輸入的數字是:"+num);
}
catch (IOException e) //for readLine()
{
e.printStackTrace();
}
}
}
然後在 javaworld 版,看到有人介紹 String與基本資料型態(int byte...等)之間的轉換 如下轉錄自java連線版 發信人: TAHO, 看板: java 精華區 標 題: String與基本資料型態(int byte…等)之間的轉換 發信站: 140.126.22.6 竹師風之坊 Origin: Local 1. 由 基本資料型態轉換成 String String 類別中已經提供了將基本資料型態轉換成 String 的 static 方法 也就是 String.valueOf() 這個參數多載的方法 有下列幾種 String.valueOf(boolean b) : 將 boolean 變數 b 轉換成字串 String.valueOf(char c) : 將 char 變數 c 轉換成字串 String.valueOf(char[] data) : 將 char 陣列 data 轉換成字串 String.valueOf(char[] data, int offset, int count) : 將 char 陣列 data 中 由 data[offset] 開始取 count 個元素 轉換成字串 String.valueOf(double d) : 將 double 變數 d 轉換成字串 String.valueOf(float f) : 將 float 變數 f 轉換成字串 String.valueOf(int i) : 將 int 變數 i 轉換成字串 String.valueOf(long l) : 將 long 變數 l 轉換成字串 String.valueOf(Object obj) : 將 obj 物件轉換成 字串, 等於 obj.toString() 用法如: int i = 10; String str = String.valueOf(i); 這時候 str 就會是 “10” 2. 由 String 轉換成 數字的基本資料型態 要將 String 轉換成基本資料型態轉 大多需要使用基本資料型態的包裝類別 比如說 String 轉換成 byte 可以使用 Byte.parseByte(String s) 這一類的方法如果無法將 s 分析 則會丟出 NumberFormatException byte : Byte.parseByte(String s) : 將 s 轉換成 byte Byte.parseByte(String s, int radix) : 以 radix 為基底 將 s 轉換為 byte 比如說 Byte.parseByte(“11”, 16) 會得到 17 double : Double.parseDouble(String s) : 將 s 轉換成 double float : Double.parseFloat(String s) : 將 s 轉換成 float int : Integer.parseInt(String s) : 將 s 轉換成 int long : Long.parseLong(String s) : 將 s 轉換成 long 用法如:
[Read More]
[中正大學] 上課無聊拍
[java] 在 linux 底下使用 java 來執行 Linux 指令
其實可以在 linux 底下去寫 shell script 然後去執行 java 程式,而並非用 java 去執行 Linux 指令,不過java也是可以做到執行 shell command,底下就是我寫的 java 測試 code,去列出自己所在的目錄底下的檔案 ls 這個指令
import java.io.*;
import java.net.*;
import java.util.*;
public class runstart{
public static void main(String a[]) throws Exception{
Process pl = Runtime.getRuntime().exec("/bin/ls");
String line = "";
BufferedReader p_in = new BufferedReader(new InputStreamReader(pl.getInputStream()));
while((line = p_in.readLine()) != null){
System.out.println(line);
}
p_in.close();
}
}
參考http://debut.cis.nctu.edu.tw/~ching/Course/JavaCourse/05_input_output/02_input_output.htm
[C/C++] 判斷字串是否為數字
常常在寫 C 語言,有時候想判斷輸入的是否為數字,如果不是的話,要重新輸入,所以寫一下怎麼判斷的,ptt提供了下面很多函式
[Read More]isalnum ctype.h 測試某一整數值是否為’A’-‘Z’,’a’-‘z’,’0′-‘9’等文數字之一。 isalpha ctype.h 測試某一整數值是否為’A’-‘Z’,’a’-‘z’,等字母之一。 isascii ctype.h 如果ch的值判於0-127,則傳回非零整數(0x00-0x7F)。 iscntrl ctype.h 如果ch是一刪除字元或一般控制字元,則傳回非零整數(0x7F或0x00-0x1F)。 isdigit ctype.h 如果ch是一數字,則傳回非零整數。 isgraph ctype.h 如果ch是為可列印字元,則傳回非零整數。 islower ctype.h ch若為小寫字母,則傳回非零整數。 isprint ctype.h ch若為可列印字元,則傳回非零整數。其功能與isgraph相似。 ispunct ctype.h ch若為標點符號,則傳回非零整數。 isspace ctype.h ch若為空白字元或定位字元(Tab),歸位字元(Enter鍵),新列字元,垂直定位字元,換頁字元,則傳回非零整數。 isupper ctype.h ch若為大寫字母,則傳回非零整數。 isxdigit ctype.h ch若為一個十六進位數字,則傳回非零整數 用程式去判斷會更快,因為上面的函式,都是要單一字元去檢查,非常不方便,所以就寫了底下的程式
[C/C++] 判斷年份是否閏年
無聊幫同學寫作業,其實這還蠻簡單的,判斷閏年的方法如下
1、可以被4整除但不可以被100整除。 2、可以被400整除。
程式碼如下
| |
[blog] 部落格線上傳送訊息到 google talk
這個訊息是在 重灌狂人 那邊看到的,我用起來相當不錯,所以套用了我的 電腦blog 跟 生活blog,那底下就來介紹怎麼把這個功能用在部落格上面 目前我是弄在 wordpress 上面,有可以達到我的需求,首先登入 網頁版的Google Talk聊天面板,然後自己設定一下名稱按送出,他會給你一段 frame 的程式碼,然後你要把他寫到 wordpress 的 theme 程式裡面 到 /wp-content/your_theme/sidebar.php 檔案裡面,每個 theme 設計方式不同,所以大家注意一下
[Java] 安裝好 Jdk 設定 path 跟 classpath 路徑
今天剛裝好 jdk 新版 jdk1.6.0_04,如要下載請到 這裡 下載,裝好之後當然底下要找編譯檔案,就是要去 bin 這個資料夾,然後找到 javac 跟 java 執行檔就可以了,不過如果你要在任何地方都要使用這個執行檔,就要去修改 path,設定方法如下
我的電腦右鍵->內容 k
