2011-06-03

Ubuntu 安裝 PostgreSQL 8.04

安裝 postgresql
sudo apt-get install postgresql postgresql-client postgresql-contrib
如需要 GUI 管理工具可以安裝 pgadmin3
sudo apt-get install pgadmin3


更改資料庫 postgres 預設密碼 方法一
sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'newpassword';
template1=# \q

更改資料庫 postgres 預設密碼 方法二
sudo su postgres
postgres@local:/$ psql
psql (8.4.8)
Type "help" for help.

postgres=#
select * from pg_shadow;
密碼欄位應該是空值
postgres=# alter user postgres with password 'newpassword';
postgres=# \q
離開psql
postgres@local:/$ exit
離開 postgres 帳號


更改系統帳號 postgres 密碼
sudo passwd -d postgres
sudo su postgres -c passwd
輸入新密碼

經過上面步驟之後就可以透過 command-line 和 pgAdmin 使用新的密碼連入資料庫伺服器。但在使用pgAdmin之前還應該將 PostgresSQL admin pack 設定好,以啟用 pgAdmin 更好的 logging 和 monitoring 工具,使用下面命令設定:
sudo su postgres -c psql < /usr/share/postgresql/8.4/contrib/adminpack.sql



修改設定,讓資料庫能接受遠端連線(Access from Remotely)(非必需)
sudo vi /etc/postgresql/8.4/main/postgresql.conf

#listen_addresses = 'localhost'
to
listen_addresses = '*'


#password_encryption = on
to
password_encryption = on

儲存並關閉檔案


設定誰可以連線

Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file. (The following advice can also be given to you - plus you don’t even need to figure out IP addresses and subnet masks - from the latest versions of pgAdmin (1.6.x). But it doesn’t hurt to know how things work).
sudo vi /etc/postgresql/8.4/main/pg_hba.conf

Comment out, or delete the current contents of the file, then add this text to the bottom of the file:
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host    all         all         [ip address]          [subnet mask]  md5

and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 125.232.82.46). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 125.232.192.0 would allow all machines with an IP address 125.232.192.x to use the database server).

That’s it, now all you have to do is restart the server:

to
sudo /etc/init.d/postgresql restart

And all should be working.


原文:
http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/

2011-06-01

Ubuntu 設定 PPPOE 播接 ADSL

輸入以下指令設定 ADSL 播接帳號、密碼
$sudo pppoeconf

2011-05-31

Ubuntu Server i386 安裝完 CLI 中文顯示亂碼

修改
$sudo vi /var/lib/locales/supported.d/local
改為
en_US.UTF-8 UTF-8

修改
$sudo /etc/default/locale
改為
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"

2011-05-11

Android 多國語系

Environment:
Win2003 + Eclipse + SDK Platform Android 2.2, API 8, revision 2

語系資源檔路徑:Project/res/[values]

[values]語系目錄名對應如下:
預設:values
英文: values-en
繁體中文: values-zh-rTW
簡體中文: values-zh-rCN
日文: values-ja
美式英文: values-en-rUS
英式英文: values-en-rUK

當程式執行時會依據手機的語系設定載入對應的語系資源,

測試的時候可在 onCreate() 中加入以下程式碼測試不同的語系執行結果
Resources res = getResources();
Configuration conf = res.getConfiguration();
conf.locale = Locale.TRADITIONAL_CHINESE;//中文
DisplayMetrics dm = res.getDisplayMetrics();
res.updateConfiguration(conf, dm);

======Code=============================
package tw.cww.tipcalculator;

import java.util.Locale;

import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;

public class TipCalculator extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Resources res = getResources();
Configuration conf = res.getConfiguration();
conf.locale = Locale.TRADITIONAL_CHINESE;//中文
DisplayMetrics dm = res.getDisplayMetrics();
res.updateConfiguration(conf, dm);


setContentView(R.layout.main);
}
}

======Code End=============================

==2011/05/11==

2011-04-28

記住這8句話,你至少成熟5歲!

1. 如果你不喜歡現在的工作,要麼辭職不幹,要麼就閉嘴不言。 初出茅廬,往往眼高手低,心高氣傲,大事做不了,小事不願做。 不要養成挑三揀四的習慣。 不要雨天煩打傘,不帶傘又怕淋雨,處處表現出不滿的情緒。 記住,不做則已,要做就要做好。 ­

2. 每個人都有孤獨的時候。 要學會忍受孤獨,這樣才會成熟起來。 年輕人嘻嘻哈哈、打打鬧鬧慣了,到了一個陌生的環境,面對形形色色的人和事,一下子不知所措起來,有時連一個可以傾心說話的地方也沒有。 這時,千萬別浮躁,學會靜心,學會忍受孤獨。 在孤獨中思考,在思考中成熟,在成熟中昇華。 不要因為寂寞而亂了方寸,而去做無聊無益的事情,白白浪費了寶貴的時間。 ­

3. 不要像玻璃那樣脆弱。 有的人眼睛總盯著自己,所以長不高看不遠;總是喜歡怨天尤人,也使別人無比厭煩。 沒有苦中苦,哪來甜中甜? 不要像玻璃那樣脆弱,而應像水晶一樣透明,太陽一樣輝煌,鑽石一樣堅強。 既然睜開眼睛享受風的清涼,就不要埋怨風中細小的沙粒。 ­

4. 管住自己的嘴巴。 不要談論自己,更不要議論別人。 談論自己往往會自大虛偽,在名不副實中失去自己。 議論別人往往陷入雞毛蒜皮的是非口舌中糾纏不清。 每天下班後和你的那些同事朋友喝酒聊天可不是件好事,因為,這中間往往會把議論同事、朋友當做話題。 背後議論人總是不好的,尤其是議論別人的短處,這些會降低你的人格。 ­

5. 機會從不會“失掉”,你失掉了,自有別人會得到。 不要凡事在天,守株待兔,更不要寄希望于“機會”。 機會只不過是相對于充分準備而又善於創造機會的人而言的。 也許,你正為失去一個機會而懊悔、埋怨的時候,機會正被你對面那個同樣的“倒楣鬼”給抓住了。 沒有機會,就要創造機會,有了機會,就要巧妙地抓住。 ­

6. 若電話老是不響,你該打出去。 很多時候,電話會給你帶來意想不到的收穫,它不是花瓶,僅僅成為一種擺設。 交了新朋友,別忘了老朋友,朋友多了路好走。 交際的一大訣竅就是主動。 好的人緣好的口碑,往往助你的事業更上一個臺階。 ­

7. 千萬不要因為自己已經到了結婚年齡而草率結婚。 想結婚,就要找一個能和你心心相印、相輔相攜的伴侶。 不要因為放縱和遊戲而戀愛,不要因為戀愛而影響工作和事業,更不要因一樁草率而失敗的婚姻而使人生受阻。 感情用事往往會因小失大。 ­

8. 寫出你一生要做的事情,把單子放在皮夾裏,經常拿出來看。 人生要有目標,要有計劃,要有提醒,要有緊迫感。 一個又一個小目標串起來,就成了你一生的大目標。 生活富足了,環境改善了,不要忘了皮夾裏那張看似薄薄的單子。

作者: 王寶露

2011-04-22

奶奶說怎麼當個好女人︿︿(太棒ㄌ要收藏起來) .

奶奶說,生氣的時候不要吵架,可以不說話,不洗他衣服,但是,不要和他吵架。 奶奶說,和男人吵架了不要跑到外面去張揚,他向你邁進一步,你就向他走兩步。 奶奶說,家是女人的大本營,發生什麼事情都不要走。因為,回來的路很難。 奶奶說,兩個人在家不要老想著面子,兩個人過日子,面子很重要?那在外面怎麼生活? 奶奶說,不管一個男人多有錢,他還是希望可以看到乾乾淨淨的你在乾乾淨淨的家等他。 奶奶說,好男人很多,他不會去抱別的女人。但是這社會,很多壞女人會伸手去抱你的男人。 奶奶說,女人一定要出去工作,不管錢賺得多或是少,工作就是自己人生價值的體現。 你一直在家,就讓男人有機會在你面前說:“是我在養你。” 奶奶說,你在外面工作,家裡的事情再忙也要做,不然就花錢請個工。 家裡的事情一定要好好做,小孩也要好好教。 奶奶說,他為你做了意想不到的事情,你可以感動,可以誇獎,千萬不要嘲諷的說“太陽從西邊出來了”, 如果這樣,也許以後他不會為你做任何事情。 奶奶說,誰都不是誰的另一半,你的想法不說出來誰會了解? 需要什麼感受,討厭什麼事情,你告訴別人,別人才會懂。 奶奶說,他的父母也是你的父母,就算他的父母對你不是很好,你也要對他們好。因為他們是他的父母。 奶奶說,決定和什麼人在一起了,就不要去埋怨苦日子,既然你選擇了他,就不要去埋怨他。 奶奶說,那麼有錢有什麼用,人呢?人在哪裡? 奶奶說,我們這輩子能花多少錢?不要買什麼奢侈品,過得幸福就好。 奶奶說,不要唬小孩“ 媽媽不要你”,不要生氣地時候把小孩推出門,如果他真的不見了,你會很痛苦。 奶奶說,盡量不要打小孩,更不要在外面打。 奶奶說,什麼都是緣分。 奶奶說,生命無常,要好好珍惜每一天,珍惜自己的家庭。 奶奶說,她年輕的時候,她外婆總是教她怎麼做好一個女人。 奶奶和爺爺在一起有五十多年。她說,她是先結婚後戀愛的。 奶奶說,爺爺年輕的時候很窮,別人給他一顆糖,他都小心翼翼帶回來,拗一半給她吃。 奶奶說,她年輕的時候不懂什麼是好,覺得爺爺本來就應該這樣。 奶奶說,有一次有人想欺負爺爺,她生氣的衝過去拿掃把打人一頓。 她說的時候哈哈大笑,我感動得雙眼模糊…… E(網路轉載,歡迎分享)

2009-09-24

如何在Windows 2000 使用 Windows XP 的 schtasks.exe?

XP 的 schtasks.exe 命令行工具是管理排定工作的很好的工具,Win2K 沒有提供類似功能的命令行工具。如果你在 Win2K的作業系統執行 schtasks.exe 會收到執行的作業系統版本不正確的錯誤訊息,但是可以透過下列方式修改 schtasks.exe 讓它能在 Win2K 的作業系統執行。

 1. 在 hex 編輯器(例如:Hex Workshop)開啟 schtask.exe
 2. 尋找到 CB2A 的位址,將 Hex 值從 75 改成 EB
   如果是使用 XP SP1 則位址在 CC50
   如果是使用 XP SP2 則位址在 E3F8
   如果是使用 XP SP3 則位址在 E391
 3. 儲存,離開編輯器

如果想要美化顯示結果,可以使用 Visual C++ 或其它資源檔編輯器例如 Angus Johnson 的 Resource Hacker 編輯錯誤訊息

ERROR: The Target system must be running Windows XP or above.

to

ERROR: The Target system must be running Windows 2000 or above.

這個錯誤訊息在字串表編號 344.


資料來源:
http://windowsitpro.com/article/articleid/25186/how-can-i-use-windows-xps-schtasksexe-tool-under-windows-2000.html


English:

The XP schtasks.exe command-line tool is great for managing scheduled tasks. Win2K doesn't have an equivalent command-line tool. If you attempt to run schtasks.exe on a Win2K machine, you'll receive an error message indicating that you're using the incorrect OS version. You can modify schtasks.exe to work under Win2K by performing the following steps.

  1. Open schtasks.exe in a hexadecimal editor such as BreakPoint Software's Hex Workshop 3.1.
  2. Find code location CB2A, and change the hex value 75 to EB. If you're using Windows XP Service Pack 1 (SP1), the code location is 0x0000CC50 (not CB2A); if you're using XP SP2, the location is 0x0000E3F8. Updated 12-5-08: If you're using XP SP3, the location is 0x0000E391.

For cosmetic purposes, you can use Visual C++ or a resource editor such as Angus Johnson's Resource Hacker to change the error message

ERROR: The Target system must be running Windows XP or above.

to

ERROR: The Target system must be running Windows 2000 or above.

This error message is located in String Table 344.

adsense