Thursday, September 27, 2007

Install Vista in Bootcamp

NOTICE: The home editions are not allowed for visualization use, such as parallels and fusion.
1. Pre-Install
1.1. Remove old partition using bootcamp assistant. Reboot.
1.2. Download latest bootcamp assistant. (Mine 1.4beta.)
1.3. Install bootcamp assistant.
1.4. Create bootcamp drivers CD.
1.5. Create new windows partition in bootcamp assistant, Vista at least 20G (I used 25G).
1.5.1. If partition failed, use disk utility to repair.
1.5.2. If failed, try to use OS X disk, boot from CD, use disk utility to repair.
1.5.3. If failed, boot into single-user mode. (Shut down, press power, press CMD+S.)
1.5.4. /sbin/fsck -fy
1.5.5. Press Enter after five phases are done, and reboot.
1.5.6. Create new windows partition in bootcamp assistant.
1.6. Insert Windows Disk, and press Start Installation button.
1.6.1. To open fancy vista retail box, first remove the certificate of authorization sticker on the top, then remove the sticky seal on the side, finally pull the red pulley on the top. So complicated...

2. Installation, about 40 min.
2.1. Chose Language etc and click start install.
2.2. Type the product key. (when you open the vista box, on one side of the plastic box.)
2.3. Chose custom install, select the correct disk.
2.4. The Installing Windows Panel, expect restarts and black screens.
2.5. Set up account, password, time-zone, etc.
2.6. Waiting for the initial set up and log in.

3. Post Installation, about 50 minutes.
3.1. Eject Vista DVD, and insert Bootcamp drivers CD. Note we don't have right click on macbook yet, so goto Computers->Select Optical Drive->Eject. Also, no sound, no internet yet.
3.2. Automatically brings up a choice, and select install the exe file. Grant Access.
3.3. Go through all the Boot Camp Installation, which will happen automatically. Expect the resolution will change during installing the drivers. About 20 minutes, reboot.
3.4. Activate Vista (Control Panel->System and Maintenance->System).
3.5. Install Vista Updates (already 30 on Sep 14), about 30 minutes! Reboot.
3.6. Install other softwares.

xbox XP sharing

Set up windows sharing folders, and then modify, e.g.
F/Apps/xbmc/XboxMediaCenter.xml

with

Name In Xbox Memu
smb://WindowsMachineName/FolderName

at
user:password@IpAddress

Also, the xml in C/Dashboard can be customized.

FTP server on XP

  1. Install Filezilla Server.
  2. Start up the default server at port 14147.
  3. Set up groups, users. Name, password, folders and privileges. Set up connect, upload, download preferences.
  4. Change the ftp port from 21 (being used for ISP in XP) to, e.g. 1025, and it may use 1024=1025-1.
  5. Write the IP address in passive mode preference panel, if the server is behind a router.
  6. Use self defined outgoing ports in passive mode preference panel, such as 5000-5020.
  7. Manually write all ports used as Firewall Exceptions in Control Panel of XP. (Note, XP does not support open a range of ports.)
  8. Forward relevant ports in the router, e.g. 1024-1025, 5000-5020.
  9. Test using Filezilla Client. Both local IP, and external IP, on the Windows machine and other machines. Close Firewall if needed in debugging.

Remote Desktop Setting

  1. Set up Remote Desktop in Control Panel of Windows XP.
  2. Open Port in Firewall Exceptions for 3389.
  3. Forward this port in the router.
  4. Download and install client side remote desktop.

Useful links

Install Windows XP

Installing Dell Poweredge Windows XP

1. Install Dell OEM Windows XP in a partition.
Time zone, internet connection settings do not matter.
Installation approximate 30 minutes.

2. Install Network Driver.
My Computer->Hardware->Install Driver for Network.
Insert Dell System Support Bootable CD (light green).
Auto find and Install.
Do not need re-start.

3. Install Sound Driver.
Insert Audigy2 Installation and Application CD.
Select English or Chinese, both applications.
Full installation (don't try configured installation).
Reboot.
Test sound drive installed. Check all holes #3 from the left.

4. Install Display Driver.
Go to ATI website, select support and driver.
Windows XP, Radeon, 9500, driver only, download.
Install the driver.
Reboot.
The resolution should change now.

5. Install Windows XP updates.
Windows update from start->menu.
First batch of 4 updates, reboot.
Second batch of 32 updates (long time), reboot.
Third batch of SP2 (very long time), reboot.
Fourth batch of 40 updates, reboot.
Install IE7 from microsoft, reboot.
Install IE updates (two), reboot.
Install WMP 11 from WMP udpate, reboot.
Install WMP updates (three).

6 Install Softwares.
6.0. Anti Virus software (MacAFee), scan, reboot.
6.1. Acrobat Reader 8.
6.2. WinRar.
6.3. google pingyin (better than ziguang).
6.4. Realplayer, iTunes, PPS, Storm, etc.
6.5. Flashget, Xunlei, Bitcomet, amule, filezilla, etc.

Clear "Open With" Menu

有时Open With菜单里面会出现重复的程序链接,譬如doc文件出现两个Office Word,jpeg文件出现两个Photoshop。修复的办法是在终端里面运行如下命令行:

cd /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/

./lsregister -kill -domain local -domain system -domain user


Using C functions in R

Method:
convert .c file to shared library .so via link ready object file .o, then use dyn.load() in R to call the shared library, and use .C() to convert it to R function.

Example 1, conv
Feature: simple c example without external library.

1.1 C code:
/* conv.c */
void convolve(double *a, int *na,
double *b, int *nb, double *ab){
int i, j, nab=*na + *nb -1;

for (i=0; i<nab; i++)
ab[i] = 0.0;

for (i=0; i<*na; i++)
for (j=0; j<*nb; j++)
ab[i+j] = ab[i+j] + a[i]*b[j];

1.2 Terminal Process:
gcc -c conv.c
R CMD SHLIB conv.o

R CMD SHLIB conv.c

1.3 R code:
# conv.r
dyn.load("conv.so");

conv <- function(a, b){ .C("convolve", as.double(a), as.integer(length(a)), as.double(b), as.integer(length(b)), ab = double(length(a)+length(b)-1))$ab } x <- 1:3 y <- 1:5 z <- conv(x,y)



Example 2, Exp1
Feature: c example with gsl library.

2.1 C code:
/* exp1.c */
#include
void myexp(double *x, int *nx, double *y){
int i;
for (i=0; i<*nx; i++){ y[i] = gsl_sf_expint_E1(x[i]); } }


2.2 Terminal Process:

gcc -c exp1.c
gcc -shared -o exp1.so exp1.o -lgsl -lblas -lm

R CMD SHLIB exp1.o /usr/lib/libgsl.a

2.3 R code:

# exp1.r
dyn.load("exp1.so");

myexp <- function(x){
.C("myexp", as.double(x), as.integer(length(x)),
y = double(length(x)))$y;
}
myexp(1:4);


Example 3, Exp1 in C++
Feature: C++ example with gsl library.
How: just wrap all functions in extern “C”{}.

3.1 C code:
/* exp1.cpp */
#include <gsl/gsl_sf_expint.h>
extern “C”{
void myexp(double *x, int *nx, double *y){
int i;
for (i=0; i<*nx; i++){ y[i] = gsl_sf_expint_E1(x[i]); } } }


3.2 Terminal Process:
g++ -c exp1.cpp
g++ -shared -o exp1.so exp1.o -lgsl -lblas -lm

R CMD SHLIB exp1.o /usr/lib/libgsl.a

3.3 R code:
# exp1.r
dyn.load("exp1.so");
myexp <- function(x){ .C("myexp", as.double(x), as.integer(length(x)), y = double(length(x)))$y; } myexp(1:4);

Make Audiobooks in iTunes

不同类型的媒体使用方式不同,所以iTunes将音乐,电视,电影,电子书和podcast分开是个好的开始。譬如电子书,比方说我的法语课文音频文件,一般来说shuffle音乐的时候不想他们出来,但是把它们变到audiobook目录下面去并不是改一下genre成audiobook就可以了事的,做笔记如下:

首先,得使用苹果电脑。windows机器没有applescript,更加复杂,我也懒得研究了。

  1. 安装Make Bookmarkable。具体说就是去dougscripts的网站下载这个script,然后copy到/User/Library/iTunes/Scripts/目录下面(如果没有这个目录就建立一个),然后重启iTunes。
  2. 将文件convert成acc格式(.m4a后缀),这个可以直接在iTunes里面选好文件右健选菜单convert就好。当然,更加详细一点的转换设置在preference(apple+,)里面advanced->importing->Import Using ACC converter, and setting 64bit, stereo channel, and optimized for voice。
  3. 删除旧文件,保留那些转换好的.m4a文件。
  4. 选好要转换的.m4a文件,在iTunes菜单条里面选下面的make bookmarkable,done!

结果是.m4a变成了.m4b文件,然后这些文件自动出现在audiobook目录下了。

注:直接用机器人把.m4a文件改名字成为.m4b文件不会将文件挪到audiobook目录;而用这个方法改的文件列在audiobook目录下并不一定需要采用genre里面audiobook的tag,譬如可以使用French的tag。

Install R packages locally

在没有权限写R的安装目录的时候,可以在user的目录下局部安装R的软件包,比较方便的做法是如下四步(如果已经完成了前两步,就只需执行最后两步):

  1. 在$HOME下建立一个文件夹存放自己的R package:
    cd
    mkdir .Rlibs
  2. 在$HOME下建立环境文件.Renviron,使得每次启动R的时候自动识别package所在的目录文件。文件.Renviron只有如下一行文字:
    R_LIBS=$HOME/.Rlibs
  3. 下载相应的软件包,比如 gsl_1.6.6.tar.gz

  4. 在下载目录下安装:
    R CMD INSTALL -l $HOME/.Rlibs gsl
如果前两步已经设置好,也可以直接使用如下命令安装
R # and run next line inside R
install.packages("packagename", lib=LIBPATH)

Input French Characters

不需要用法语键盘(输入法)的简单方法:

^ (circonflexe)
option-i followed by the character you want
Example: ô, Î

` (accent grave)
option-grave accent key (the key beside the 1 and above the tab) followed by the character you want
Example: à, è

´ (accent aigu)
option-e followed by the character you want
Example: é

¨ (diérèse or umlaut)
option-u followed by the character you want
Example: ë, ü

˜ (tilde)
option-n followed by the character you want
Example: ã, õ

ç, Ç (cédille)
option-c, option-C

å, Å (circle)
option-a, option-A

For more advanced information, check this pro page at apple.

WWDC 2006

去年的wwdc听到的是ppc到intel的转变,今年的wwdc当然是leopard了。很诧异的是苹果调侃vista的口气,虽说大家都知道这个 industry多多少少有些你抄我的我抄你的,但也没有这么有个性明摆明地第一人称说出来吧。总体感觉还是很不错地,一直都很喜欢steve的keynote,魅力无穷啊,不过这次好像他有些退居二线,而不像以前所有最cool的东西都是Jobs自己来demo,很帅的说。一直怀疑steve是不是刻意栽培小伙子Scott Forestall,今天给了好多个镜头啊,和steve交错上台n次,而且最cool的有技术含量的都是给scott的。说实话,要是steve学bill gates退休,还真的没有人(或者几个人)可以替代他的位置啊,努力培养下一代是正道的说。

最感兴趣的是:top secret。居然不preview,也好,免得给vista学了,它都不敢固定自己发布时间,即使公布了,也没有人信,一推再推已经是家常便饭。希望leopard可以按时推出,用这些top secret来吸引用户吧!

最吸引人的是:time machine。看文字直播不觉得什么,看现场录像发现这个咚咚做得好的话的确是不错,简直是太棒了,不是说它的理念,而是说它的易用性,只是,是不是要个大一点的硬盘了(即使只存版本差异)。我猜要做到这个份上不是一两个月可以搞定的,所以干脆就preview给大家看看,要copy的也不是那么简单可以copy出来。

最刻薄的是:John Hodgman开场白。含有点无可奈何的讽刺,steve看样子是个小性子,从他那封发给员工说股市超过dell就可以看出,虽然很解气和激励人心哈。不知道MS是不是因此生气,今天赶紧发布不弄VPC的消息,还说Office我们接着弄,但是code很长的,不知道什么时候弄好就是了。两边都是小气鬼,竞争对手嘛。反正我也不用MS office,拖就拖吧。

最无聊的是:More than *** configurations。太土了吧,这么无聊的数据也拿出来show?欺负大家开发者(知识分子)没有学过排列组合?!看样子business man的头脑是不太一样,数字大就好?没有质量,很觉得这次steve的头脑有点问题,或者是phil头脑有问题?

当然,mail的改进也是相当可观的,赞,core animation不知道要硬件什么样才能run。ichat是越来越fancy了,可惜没有用武之地啊,除非它苹果market share和PC掉个头,大家都用ichat不用msn或者qq,不现实了。硬件不干我的事情了,现有产品不换Merom估计是输出渠道没有赶上吧,也和WWDC无关,默默改就好了。总之这个keynote还是很不错的,再等就是两个月后法国那个expo了?iPod该更新了。很好奇zune的市场反应如何?

Spotlight indexing

  1. 用鼠标的方法
    在系统预制里的spotlight选项中,只有一个隐私和排列,没有多余的东西,其实实现重新索引,仅仅需要用“+”“-”。点击 “+”添加你的本地磁盘到隐私列表。然后关闭系统预置。等上5分钟,然后再次打开系统预置点击“-”将你的列表清空。稍候spotlight就会对你的硬盘进行重新索引了。

  2. 用terminal的方法
    在终端中,输入:
  3. mdutil -E volume

    就可以对指定的volume进行重新索引了。注:此方法必须在root权限下!