2013年1月1日星期二

Install and Setup Gcc 4.1(g++4.1) in Ubuntu 10.04


How to Install and Setup Gcc 4.1(g++4.1) in Ubuntu 10.04/10.10

Published in Posted by Meilin in General


The default gcc version in Ubuntu 10.04 LTS and 10.10 is gcc 4.4. However some programs depend on gcc 4.1.1 or gcc 4.1.2. Here? how to install and setup gcc 4.1.3 in Ubuntu 10.04/10.10 which also works if one program need gcc 4.1.1/4.1.2 to run.

Install Gcc 4.1

gcc 4.1.3 is available default in Ubuntu 10.04/10.10 official repository, just run the command in Applications -> Accessories -> Terminal:

sudo apt-get install gcc-4.1
If you absolutely want gcc 4.1.1, refer to ubuntuforums.org.

Set gcc 4.1 as default version

After that, use this command to list installed gcc in your Ubuntu:

ls /usr/bin/gcc*
and use this command to check which is default:

gcc -v
1.) Now, add alternatives for gcc:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 30
run this command which lists available versions, then type a number to set default.

sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status

0 /usr/bin/gcc-4.4 40 auto mode
* 1 /usr/bin/gcc-4.1 30 manual mode
2 /usr/bin/gcc-4.4 40 manual mode

2.) add alternatives for g++, i486-linux-gnu-gcc, and i486-linux-gnu-g++ and set 4.1 as default:

update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.1 30
update-alternatives --config g++
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.4 40
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.1 30
update-alternatives --config i486-linux-gnu-gcc
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.4 40
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.1 30
update-alternatives --config i486-linux-gnu-g++

source

2012年12月30日星期日

Useful command / sites

export LD_LIBRARY_PATH=/lib

ldd       #find dependencies

getlibs   #auto install missing libraries
https://launchpad.net/~jcollins/+archive/jaminppa/+build/1482994/+files/getlibs_2.06-0ubuntu1%7Eppa2_all.deb

du  #Size of a directory & Free disk space
source

ps -eO user -H

will show the process tree along with the process status (to determine if it is a zombie -Z- or an uninterruptable sleep -D-)

strace -p pid

pstree

xkill

要強制手動釋放或清除Linux中的Cache Memory可以使用下面的指令
echo 3 > /proc/sys/vm/drop_caches

https://code.google.com/p/nekodrive/    (Mount NFS on windows)

http://tldp.org/LDP/tlk/ipc/ipc.html    IPC

http://tw.myblog.yahoo.com/hughes-blog/article?mid=105   IPC - fork and shared memory

http://developer.android.com/tools/help/proguard.html    Android, prevent reverse engineering

Solve ^M problem
If you get a “dos2unix: not found” error on Ubuntu 10.04 Lucid Lynx, there is the solution:
Install a “tofrodos” package and add two symlinks
root@ramune:/usr/bin# ln -s fromdos dos2unix
root@ramune:/usr/bin# ln -s todos unix2dos

2012年12月18日星期二

sqlite multi index


SQLite prefers to use a multi-column index such as this:
CREATE INDEX pg1_ix_all ON pg1(a,b,c);
If the pg1_ix_all index is available for use when the SELECT statement above is prepared, SQLite will likely choose it over any of the single-column indexes because the multi-column index is able to make use of all 3 terms of the WHERE clause.
You can trick SQLite into using multiple indexes on the same table by rewriting the query. Instead of the SELECT statement shown above, if you rewrite it as this:
SELECT d FROM pg1 WHERE RowID IN (
    SELECT RowID FROM pg1 WHERE a=5
    INTERSECT
    SELECT RowID FROM pg1 WHERE b=11
    INTERSECT
    SELECT RowID FROM pg1 WHERE c=99
)
Then each of the individual SELECT statements will using a different single-column index and their results will be combined by the outer SELECT statement to give the correct result. The other SQL database engines like PostgreSQL that are able to make use of multiple indexes per table do so by treating the simpler SELECT statement shown first as if they where the more complicated SELECT statement shown here.


NFS ans Samba


Network File System (NFS)

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.
Some of the most notable benefits that NFS can provide are:
  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

Installation

At a terminal prompt enter the following command to install the NFS Server:

sudo apt-get install nfs-kernel-server

Configuration

You can configure the directories to be exported by adding them to the /etc/exports file. For example:

/ubuntu  *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)

You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.
To start the NFS server, you can run the following command at a terminal prompt:

sudo /etc/init.d/nfs-kernel-server start

NFS Client Configuration

Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt:

sudo mount example.hostname.com:/ubuntu /local/ubuntu

[Warning]
The mount point directory /local/ubuntu must exist. There should be no files or subdirectories in the /local/ubuntu directory.
An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted.
The general syntax for the line in /etc/fstab file is as follows:

example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

If you have trouble mounting an NFS share, make sure the nfs-common package is installed on your client. To install nfs-common enter the following command at the terminal prompt:
sudo apt-get install nfs-common


Windows NFS Connect
https://code.google.com/p/nekodrive/

Samba

sudo apt-get install samba samba-common
sudo apt-get install python-glade2
sudo apt-get install system-config-samba
To setup samba - GUI > System > Administration > Samba
sudo smbpasswd -a username (same as your desired share folder owner)

create ram drive

mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/

#edit /etc/fstab
tmpfs /tmp/ramdisk tmpfs size=256M 0 0

2012年12月9日星期日

install subclipse 1.8.x



1. search subclipse from eclipse markerplace.

2. apt-get install libsvn-java


3. modify eclipse.ini.  add the below red line.  (source)

-showsplash
org.eclipse.platform
-framework
plugins/org.eclipse.osgi_3.4.0.v20080605-1900.jar
-vmargs
-Djava.library.path=/usr/lib/jni
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m



if it shows "incompatible javahl library loaded. 1.7.x or later required."

Remove your existing libsvn-java:

sudo apt-get purge libsvn-java
Then, add the following software source and re-install:

sudo add-apt-repository ppa:dominik-stadler/subversion-1.7
sudo apt-get update
sudo apt-get install libsvn-java
(source)

2012年9月18日星期二

掛羊頭賣狗肉的QE3


2012年9月18日

掛羊頭賣狗肉的QE3

美國聯儲局出了一個名不副實的QE3,名副其實的購買資產計劃。原因是這趟的資產膨脹,發生在MBS,即所謂無了期每月購買400億美元的MBS。
嘩!400億美元,好多錢呀!而且無了期,勁呀!股市大牛,樓市更牛!執輸行頭,慘過敗家。
等等,請冷靜一下:
1. 買的是MBS,又不是香港股票和樓,除卻短暫興奮外,跟你我有什麼關係?
2. 每個月400億美元,意思真小哉!美國政府每周拍賣短債都起碼約600億美元、長債每月也有1400億美元。聯儲局一般包銷約四成計,亦有1520億美元。以上是非常保守的財政下計算,以最近兩三年計,則每月約2675億美元左右(尚未包含MBS,ABS及其他資產),每月增加400億美元,實在算不了什麼。
3. 就算以MBS計,QE1和QE2的時期,最厲害的一次,一周買入1670億美元的MBS;「水皮」點的一次,剛剛就是每個月400億美元;平均每個月都有買入650億美元的MBS。
4. 至於所謂無了期,語言藝術也。原文沒有提過「無限期購買」,只是沒有提出明確日期和上限。但是,原文清楚講明目的:改善失業同時卻又防範通脹失控。沒有日期和上限,只不過提供靈活性;開始和停止都毋須再交代。所謂增加透明度,就是那麼一回事。
5. 最後,別忘了,如果同月聯儲局賣了400億美元國債,剛好打和。此事在QE和OT的「休息期」時有發生,沒什麼大不了。
日日食鮑魚會不會厭
有3個問題更值得思考:
1. 為什麼只「大買」MBS,國債卻只談「扭曲」?而且只「扭曲」到本年年底?
2. 買MBS和救活勞動市場有什麼關係?
3. 日日食鮑魚,會不會厭?月月買MBS,會不會悶?
簡單講,聯儲局是「巧婦難為無米炊」。離國債上限只差1000億美元、短期浮息按揭的斷供沒有改善,致使各存貸銀行、房利美和房貸美尚有大量黑洞擴張,而市場又不斷要求聯儲局注資,「勉為其難」地利用信息威力,弄了個掛羊頭賣狗肉的QE3,查實只不過延續扭曲操作和標靶治療,規模實際上遠沒有「你想」中大。
更簡單說:QE3,是心理戰術。聯儲局的「願景」:眾市民和機構一聽到「QE3到」,就「大使」起來,無論日用品、奢侈品、金融產品和房產都消費個樂此不疲。誠如此,則房產復興、建築大旺、消費大振。建築好、建築工人好;建築工人好、消費好;消費好、美國經濟好;美國經濟好、全世界都好(咦,何以「熟口熟面」……)。
問題是:市民和機構可不是看政策消費,而是看荷包內有多少錢、物價多少和銀行肯給多少信貸來消費的。美國自2009年至今年6月,QE1、QE2、和OT1、OT2齊出,CPI累計增長7.91%,年化每年複式增長2.2%;而GDP只有年化每年複式增長1.98%。市民的荷包的確上漲了,可惜物價更高,點大買特買?!
中高檔市場續萎縮
滯脹繼續下,中高檔市場只能繼續萎縮,依賴廉宜資本高槓桿生意如銀行和房地產在預期息差繼續收窄和通脹蠶食利率回報下也不會好過。
講起中高檔消費的困難,除前文曾經介紹過的中外公司,最近還有如已發盈警的Burberry和表面上仍然賺錢的I.T.(999)。Burberry的問題,觀察一下中國遊客的消費模式:最緊要係人人皆知的「尊貴名牌」,質量如何不甚了了。如此一來,為求催谷業績,公司只着重用媒體、大招牌、名模名星等宣傳,加上價格為貴而貴,製造尊貴形象,而把質量扔在一邊。如此一來,真正對質量有要求的顧客會捨Burberry而去;中國遊客一旦「另覓更尊貴新歡」,Burberry還剩下什麼?
I.T.而言,簡單觀察一下其財務報告,有以下可疑之處:如
1. 銷售在2010/11年和2011/12年度分別上升約28%和50%,但是其庫存卻分別上升了87%和68%,遠超其銷售上升的水平,顯示庫存上升,銷售的增長未如理想。
2. 毛利率在2010/11和2011/12年度分別是63.9%和61.2%,下跌了2.7個百分點。無論是因為滯銷減價,還是單純的來貨價格上升。其貨品是買家市場,而且定價能力下跌已是事實。也就是說,其品牌價值不過爾爾,而且下跌中。
3. 其綜合現金流量表的投資活動現金流中,有一筆「向共同控制實體提供股東貸款」。細目不明。
其實I.T.的定位,是以年輕人中的有一定消費力的潮人為主,而並非普通市民或者講求名牌的人士。潮人的口味變換極快,忠誠度不高,難以期望他們能長期為I.T.店帶來穩定的生意。而潮服亦不適合一般人上班或平日逛街便服之用。再說潮服不便宜,在滯脹環境下,有誰願意用過千元買一件質地普通剪裁不宜普通人日用的服裝?
至於國內遊客,買廉宜貨固然不光顧;買貴價名牌又嫌I.T.賣的牌子太普通,均沒有興趣。觀乎其在銅鑼灣的店舖,人流不多,尤其操普通話的國內遊客亦不常見,亦簡單驗證此想法。
不過,對投資者而言,聯儲局和其他央行這種以為用增加貨幣就可以增加信貸,推動經濟增長的態度,也帶來了中長期機會。當然就是黃金。
看看金價:黃金兌美元1772.01、兌歐羅1356.69、英鎊1093.71、澳元1356.69、瑞士法郎1628.52、日圓138018,和一個月前相比,分別上升了10.25%、 3.89%、 6.84%、9.48%、5.19%,和8.43%。
咦,睇睇下,不論公布了泵錢的歐羅和美元,還是沒有泵錢兼坊間所謂的「商品貨幣」澳元,對着黃金,都齊齊跌watt,何解?
債即是錢 錢即是債
因為重點不在於某個別的措施;而是在於法幣系統本身的「原罪」:債即是錢,錢即是債(玄!)。而當社會發展至去槓桿化,尤其是在怕清算爛資產的後遺症,而採取印更多銀紙填氹,而非壯士斷臂的話,則債產生的錢愈來愈少,而需要的債卻愈來愈多,終至大眾對債錢的信心不斷減弱,並突顯了黃金作為替代貨幣的角色(儘管以今日的經濟活動量,回復金本位不現實,對經濟也帶來混亂)。
技術上看,黃金已一枝箭衝過幾個阻力位,直達1772.7美元,由期金的未平倉合約量看,遲入者聚頂,恐怕177X水平已是短期頂部,「窮寇莫追」,等候回落至兩個量度幅度後約1670美元再買未遲。