2011/07/30

Ubuntu安裝Oracle Java JDK

Ubuntu預設套件庫來源是安裝OpenJDK
對於習慣用Oracle Java JDK(原Sun JDK)的人來說
可以參考下面這篇文章來替換

如何於Ubuntu安裝Oracle Java JDK?
http://single9.net/2011/05/how-to-install-java-jdk-in-ubuntu/

爬了一下網路上的設定方法
個人感覺上面是最簡單直覺的作法
唯一的小發現是編輯完JDK的路徑之後
必須先登出一次再登入
系統才能正確抓到Java的設定

2011/07/28

利用stringstream進行字串與數值的轉換

以往都用atoi()、atof()來將字串轉成整數或是小數
這邊也可以用stringstream來實做

下面是把字串轉成數值
當然反過來也可以把數值轉為字串
簡單的實作了以下code

2011/07/24

2011/07/14

[轉貼] Windows 7 安裝後開啟 AHCI

參考資料:
http://iphonedaily.com/windows-7-ahci-enable-ahci-after-install/ Windows 7 AHCI-安裝後開啟 AHCI 的方法

※其他關於AHCI的參考資料:
何謂AHCI?如何在AHCI系統上正確安裝作業系統
在已安裝的作業系統上開啟AHCI傳輸模式
在現有的xp中打開ahci並安裝驅動程式 (Xp使用者請參考這篇)


P.S 在Linux系統kernel中已經包含AHCI的驅動,只要在BIOS中開啟AHCI功能即可。

C++指定路徑讀檔

在Windows、Linux底下實做過
其實可以這樣寫

假設輸入檔叫做input.txt
在Windows下,輸入檔放在D:\
輸入檔路徑給 D:\input.txt

在Ubuntu下,輸入檔放在使用者家目錄 /home/kevin
輸入檔路徑給 /home/kevin/input.txt

#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char *argv[])
{
    string Loc;
    string LineData = "";
   
    cout << "請輸入檔案路徑:";
    getline(cin,Loc);

    ifstream infile(Loc.c_str(),ios::in);
 
    if(infile)
    {
        cout << "Succeeded..." << endl;
        while(!infile.eof())
        {
            getline(infile,LineData);
            cout << LineData << endl;
            LineData = "";          
        }
    }
   
    else
    {
        cout << "Failed..." << endl;
    }
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

2011/07/13

C++在Widows下指定讀檔路徑



#include <iostream>
#include <fstream>

using namespace std;

int main()

{
    string InFile;
    int SlashNo = 0;
    string LineData = "";

    cout << "Input File Location:";
    getline(cin,InFile);

    for(int i=0; i<InFile.length(); i++)
    {
        if(InFile[i] == '\\')
        {
            SlashNo++;
        }
    }

    cout << "SlashNo = " << SlashNo << endl;


    int TotalLength = InFile.length()+SlashNo+1;
    char RealInputFile[TotalLength];
    int jdx  =0;

    for(int i=0; i<InFile.length(); i++)
    {
        if(InFile[i] == '\\')
        {
            RealInputFile[jdx] = InFile[i];
            jdx++;
            RealInputFile[jdx] = InFile[i];
        }

        else
        {
            RealInputFile[jdx] = InFile[i];
        }
        jdx++;
    }

    RealInputFile[TotalLength-1] = '\0';
    cout << "Current File Location : " << RealInputFile << endl;

    ifstream Source(RealInputFile,ios::in);

    if(Source)
    {
        cout << "Read Secceeded" << endl;
        while(!Source.eof())
        {
            getline(Source,LineData);
            cout << LineData << endl;
            LineData = "";
        }
    }

    else
    {
        cout << "Read Failed" << endl;
    }

    return 0;
}



2011/07/12

Ubuntu將CD/DVD存成.iso

在Windows底下
要將CD/DVD製作成.iso來儲存
常用Alcohol 120%、Daemon Tools等軟體來達成

在Linux底下
只要用一行指令就可以達到相同的功能~

dd if=/dev/cdrom of=輸出檔名


例如:

dd if=/dev/cdrom of=Ubuntu.iso
即從CD-ROM裝置讀取資料存成Ubuntu.iso

2011/07/11

在Ubuntu安裝hifree

hifree官方只有釋出Windows平台的版本
因此在Linux系統中需要藉由Wine模擬出運作的環境
相關的設定可以參考這篇:
http://jclin.blogspot.com/2011/04/linux-hifree.html  "在Linux上裝hifree"

解決Windows 7 出現「無法載入遠端連線管理員」的問題

剛剛打開Windows7
預設自動撥號連線出現了「無法載入遠端連連現管理員」的對話框
Google之後找到解法如下:

1.到控制台→系統管理工具→服務
2.找到Remote Access Auto Connection Manager,按右鍵→【啟動】
3.按右鍵→【內容】,將【啟動類型】欄位改為【自動】
4.重新啟動電腦

2011/07/10

Install Ubuntu One Client On Kubuntu

How do I install the GNOME Ubuntu One client on Kubuntu?

Although less than ideal, you should be able to get the GNOME Ubuntu One client working in KDE (Kubuntu) running these commands at a terminal session:

1. sudo apt-get install ubuntuone-client* 
2. u1sdtool -c


That will install GNOME dependencies and then kick off the process to setup your computer with Ubuntu One.

Note, you may notice getting prompted twice for your keyring password. To work around this, please try the following:

1.In a terminal session run:
 rm ~/.gnome2/keyrings/default*

2.Add the following lines to /etc/pam.d/kdm: 
auth optional pam_gnome_keyring.so try_first_pass session optional pam_gnome_keyring.so auto_start

3.Logout / login

4.In a terminal session run: 
u1sdtool -c

2011/07/09

Ubuntu安裝字型

有時候在Ubuntu下會需要一些在Windows上的字型
這時候可以先在Windows下把字型檔拷貝出來放到同一個資料夾內
例如:字型檔全部放入叫作「windows」 的資料夾,存到家目錄內
(家目錄路徑:/home/使用者名稱)

接著到Ubuntu,打開終端機

1.取得root權限,由於Ubuntu的字型檔路徑在/usr/share/fonts/truetype底下
需要有root 的權限才能夠進行變更。                  

sudo -i

接著輸入密碼


2.接著把檔案複製到/usr/share/fonts/truetype之下

cp -rp /home/使用者名稱/windows /usr/share/fonts/truetype
就可以將字型檔案複製到Ubuntu系統中


3.重新載入系統字型檔
fc-cache -f -v

收工!

Ubuntu為套件庫加入來源公鑰

當我們在Ubuntu的Source List加入新的來源
執行sudo apt-get update更新套件資訊時
有時候會碰到
「由於無法取得它們的公鑰,以下簽章無法進行驗證NO_PUBKEY 一串代號

只要在終端機輸入
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 上面出現的代號



就可以成功加入公鑰了

2011/07/03

Ubuntu下的簡易轉檔軟體-Mobile Media Converter

提供簡單的轉檔功能
還可以從Youtube抓取影片
有點類似Windows下的YoutubeDownloader HD

參考下列網址
http://it-easy.tw/ubuntu-mobile-media-converter/
出自 電腦不難

將Ubuntu 11.04下的OpenJDK換成Sun JDK

1.安裝JRE
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin


2.安裝JDK
sudo apt-get install sun-java6-jdk


3.手動切換到Sun JDK
update-java-alternatives -s java-6-sun




※2011/08/13更新
可以參考這篇:ubuntu平台上用eclipse開發java或android程式

2011/07/02

Kubuntu下將輸入法換成gcin

依照版本將下列來源加入 /etc/apt/sources.list

lucid 10.04

deb http://ppa.launchpad.net/elleryq/gcin/ubuntu lucid main
deb-src http://ppa.launchpad.net/elleryq/gcin/ubuntu lucid main



maverick 10.10 

deb http://ppa.launchpad.net/elleryq/gcin/ubuntu maverick main
deb-src http://ppa.launchpad.net/elleryq/gcin/ubuntu maverick main



natty 11.04 

deb http://ppa.launchpad.net/elleryq/gcin/ubuntu natty main
deb-src http://ppa.launchpad.net/elleryq/gcin/ubuntu natty main



可以在終端機下命令
sudo -i (取得管理員權限)vim /etc/apt/sources.list (透過vim文字編輯器來編輯套件來源)

接著把來源加入到檔案中(自己是加到檔案的最底端)

儲存後把來源更新一下
sudo apt-get update

切換輸入法
im-switch -s gcin


登出再登入後即可使用gcin


P.S 在Kubuntu 11.04上面實作,gcin已經解決和特效衝突的「小灰」(殘影)bug了