2012年3月29日 星期四

Objective-C 數學函式

pow(x,y) : x 的 y 次方
sqrt(x) : x的平方根
floor(x) : 小於 x 的最大整數
ceil(x) : 大於 x 的最小整數
exp(x) : e 的 x 次方
log(x) : 以 e 為底 x 的對數值
log10(x) : 以10為底 x 的對數值
abs(x) : 整數 x 的絕對值
fabs(x) : 浮點數 x 的絕對值
srand(x), rand() : 產生亂數

2012年3月17日 星期六

用Windows 7的筆電 - 設定softAP分享WIFI

可以再裝win7的筆電上,打開wifi分享網路

要以下在筆電上面無線網路卡型號才能開啟此功能

  • Atheros AR5xxx/AR9xxx cards, driver version 8.0.0.238
  • Broadcom 4310-series (in many Dell laptops)
  • Broadcom 4321AG/4322AG/43224AG WLAN Adapter, driver version 5.60.18.8
  • D-link AirPlus G DWL-G510 Wireless PCI Adapter, driver version 3.0.1.0
  • D-Link DWA-140 RangeBooster N USB Adapter, driver version 3.0.3.0
  • Dell 1510 Wireless N adapter, Broadcom version,driver 5.60.18.8
  • Intel 5100/5300, WiFi Link 1000 BGN, driver version 13.0.0.107
  • Linksys Dual-Band Wireless-N USB Network Adapter(WUSB600N), driver version 3.0.10.0
  • Netgear 108 Mbit WG311T
  • Ralink RT2870 (in many 802.11n USB dongles)
  • Realtek RTL8187B (Win7 driver ver.1178)
  • Realtek RTL8187SE (with the drivers that came with Windows 7)
  • Realtek RTL8192u with 1370(Beta)
  • Sitecom Wireless USB Adapter 54g WL-608, with Ralink RT2870 drivers, version 3.0.9.0

首先要設定一下
先打開你的筆電上的無線網路

Setp 1
按開始,點搜尋程式及檔案,輸入cmd,找到之後對他選右鍵
選擇系統管理員身分執行,之後會開啟cmd.exe
























Minecraft Server

要架設Minecraft Server有分官方版本或Bukkit版本
以這兩個版本的伺服器檔案,來提供架設伺服器的服務
現在遊戲版本是1.23版,要注意一下Server的版本
不然就會進不去遊戲了
-
官方版本下載網頁
Bukkit版本下載網頁
-
或是直接點下面的連結直接

官方版本:Server檔案 遊戲版本是:1.23
Bukkit版本Bukkit Server檔案 Bukit遊戲版本還是1.1版,可能還要等等才會有新版本

2012年3月16日 星期五

Diablo III - 05月15日上市!!












等了8~9年了,重國中到現在,總算推出了~
不用等到子孫燒給我們了XDD
預購網址

英文典藏版《暗黑破壞神 III》將於限定通路銷售,建議售價為新台幣2,999元
一般預購版本是1,499

2012年3月14日 星期三

Linux

cd
cd ..
cd /

mkdir file_temp
cp -r /home/user1/Desktop/test.zip /file_temp

rm -ir

Android CheckBox

另外一種Listener的方法,偵測是否點下checkbox的Listener方法

private void Button() {
cb1 = (CheckBox) findViewById(R.id.checkBox1);
cb2 = (CheckBox) findViewById(R.id.checkBox2);
vt = (TextView) findViewById(R.id.textView1);

CheckBox.OnCheckedChangeListener cbx = new CheckBox.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton arg0,
boolean arg1) {
// TODO Auto-generated method stub
String str = null;
if(cb1.isChecked() == true&& cb2.isChecked() == true){
str = cb1.getText() + "," + cb2.getText();

}
Toast.makeText(Testex.this, str, Toast.LENGTH_SHORT).show();
}
};
cb1.setOnCheckedChangeListener(cbx);
cb2.setOnCheckedChangeListener(cbx);
}

JAVA TimeTask

TimerService class程式

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

public class TimerService {
Timer timer = new Timer();
public TimerService() { };

public void start() throws Exception {

Calendar date = Calendar.getInstance();
date.setTime(new Date());
date.add(Calendar.DAY_OF_MONTH,1); // 驅動此程式的後一天
date.set(Calendar.AM_PM,Calendar.AM); // 上午
date.set(Calendar.HOUR,11); // 11點
date.set(Calendar.MINUTE,0); // 0分
date.set(Calendar.SECOND,0); // 0秒
date.set(Calendar.MILLISECOND,0); // 0毫秒

// timer.schedule(param1,param2,param3)
// param1: 就是要定時驅動執行的程式
// param2: 設定開始執行的時間,如上面的Calendar設定
// param3: 執行間隔時間(單位: 毫秒)
timer.schedule(
new DailyRun(),
date.getTime(),
1000 * 60 * 60 * 24
);
} // end of method

public void stop() throws Exception {
timer.cancel();
} // end of method
} // end of class

程式二 被TimerService 定時驅動執行的程式
public class DailyRun extends TimerTask {
public DailyRun() {
}

public void run() {
// 這裡是要執行的程式內容
} // End of method

} // end of class

參考至: Link

2012年3月13日 星期二

phpMyadmin

phpmyadmin官方網頁
http://www.phpmyadmin.net/
下載到目前最新的 phpMyAdmin檔案,輸入指令解壓縮它成為一個名為 phpMyAdmin的資料夾
[root@ns1 /]# tar -zxvf phpMyAdmin-2.8.2.tar.gz
將phpMyAdmin-2.8.2的資料夾改名為 phpmyadmin。
[root@ns1 /]# mv phpMyAdmin-2.8.2 phpmyadmin
將資料夾 phpmyadmin複製到網頁的根目錄 /var/www/html下。
[root@ns1 /]# cp phpmyadmin /var/www/html
將config.sample.php 改名為 config.inc.php,並且複製到/var/www/html/phpmyadmin 目錄中。
[root@ns1 /]# cd /var/www/html/phpmyadmin/libraries
[root@ns1 /]# cp config.default.php /var/www/html/phpmyadmin/config.inc.php
修改 config.inc.php檔案的內容。
[root@ns1 /]# vim /config.inc.php
輸入 MYSQL使用者名稱及密碼及phpmyadmin的認證登入方法後,將 config.inc.php檔案存檔。
$cfg['Servers'][$i]['controluser'] = '';
$cfg['Servers'][$i]['controlpass'] = '';
$cfg['Servers'][$i]['auth_type'] = 'config';
更改成
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'mysql passworld';
$cfg['Servers'][$i]['auth_type'] = 'http';
使用 firefox 或 IE網路瀏覽器中輸入下列網址去使用 phpmyadmin。
http://localhost/phpmyadmin

Java 資料轉換


1.數字轉字串:


1.1 整數轉字串 integer to String
int i = 20;


String str = Integer.toString(i);


String str = "" + i


1.2 雙精度數字轉字串 Double to String :
String str = Double.toString(i);


1.3 長型態數字轉字串 long to String :
String str = Long.toString(l);


1.4 浮點型態數字轉字串 float to String :
String str = Float.toString(f);




2.字串轉數字:


2.1 字串轉整數 String to integer :
String str = "20";
int i = Integer.valueOf(str).intValue();  //第一種方法, ValueOf會傳回一個Integer物件
int j = new Integer(str).intValue(); //第二種方法
int k = Integer.parseInt(str);  //第三種方法


2.2 字串轉雙精度數字 String to double :
double d = Double.valueOf(str).doubleValue();


2.3 字串轉長型態數字 String to long :
long l = Long.valueOf(str).longValue();
long l = Long.parseLong(str);


2.4 字串轉浮點型態數字 String to float :
float f = Float.valueOf(str).floatValue();




3.十進位,二進位與十六進位數字的轉換:


3.1 十進位轉二進位 decimal to binary :
int i = 20;
String binstr = Integer.toBinaryString(i);


3.2 十進位轉十六進位 decimal to hexadecimal :
int i = 20;
String hexstr = Integer.toString(i, 16);
String hexstr = Integer.toHexString(i);
or (含前置零與大寫 with leading zeroes and uppercase)
public class Hex {
  public static void main(String args[]){
  int i = 20;
  System.out.print(Integer.toHexString( 0x10000 | i).substring(1).toUpperCase());
  }
}


3.3 十六進位轉整數 hexadecimal (String) to integer :
int i = Integer.valueOf("B8DA3", 16).intValue();
or
int i = Integer.parseInt("B8DA3", 16);




4. ASCII Code的轉換:


4.1 ASCII碼轉字串 ASCII code to String
int i = 64;
String aChar = new Character((char)i).toString();


4.2 整數轉ASCII碼 integer to ASCII code (byte)
char c = 'A';
int i = (int) c; // i will have the value 65 decimal
4.3 從字串擷取ASCII碼 To extract Ascii codes from a String
String test = "ABCD";
for ( int i = 0; i < test.length(); ++i ) { char c = test.charAt( i ); int i = (int) c; System.out.println(i); }


5.布林(Boolean)值的轉換:


5.1 整數轉布林值 integer to boolean
b = (i != 0);
5.2 布林值轉整數 boolean to integer
i = (b)?1:0;




6.數字轉換的錯誤處理:


使用try/catch來捕捉轉換過程的錯誤
try{
       i = Integer.parseInt(aString);
}  catch(NumberFormatException e) {


}




7.日期與字串的轉換:


7.1 日期時間轉字串 : 顯示預設完整的日期時間格式, 例如 Wed Nov 05 12:05:06 EST 2003




Date dNow = new Date();
String sNow = dNow.toString();

7.2 日期轉字串 Date to String : 顯示特定的日期格式


方法一日期轉成指定格式的StringBuffer, 再將StringBuffer轉成String
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
StringBuffer sbNow = new StringBuffer();
// 將日期dNow以"yyyy-MM-dd"的格式轉存到StringBuffer sbNow中
sbNow = formatter.format(dNow, sbNow, new FieldPosition(0));
// 將StringBuffer轉成String
String sNow = sbNow.toString();


方法二 日期直接轉成指定格式的字串(String) --比較簡單
Date dNow = new Date();


SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String sNow = formatter.format(dNow)
7.3 字串轉日期 String to Date
String sDate = "2005-01-01";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date dDate = formatter.parse(sDate,new ParsePosition(0));




8.數字型態間的轉換


8.1 由短數字型態轉換成長數字型態 (擴大轉換)
如byte 轉成 short, int, long, float, 或 double,short轉成int, long, float, or double, char轉成int, long, float, or double, int 轉成 long, float, or double, long轉成float or double, float轉成double
(數字型態由短至長的順序為 byte, short or char, int, long, float, double)


直接指定就可以自動轉換!
例 :
int a = 50;
long b = a; // widening conversion


8.2 由長數字型態轉換成短數字型態 (縮小轉換,又稱為Casting)
例 :
long a = 100000000L;
int b = (int) a; // narrowing conversion


但是長數字型態的內容長度如果超過較短數字型態可容納的長度,雖然編譯與執行都不有錯誤訊息,但是會造成資料loss的現象。(這種隱含的錯誤,不容易debug,要特別留意)



參考至 :Link