yichao firstname, zeaster nickname, zhang lastname

Showing posts with label apple. Show all posts
Showing posts with label apple. Show all posts

统一Mac OS X,Windows XP/Vista以及linux的系统时间

Windows把BIOS时间作为系统时间,而Mac OS X把BIOS时间作为GMT+0时间,所以对于生活在GMT+8时区的中国用户来说,这两个系统共存时系统时间是不一致的。
即:如果windows时间为12:00,则到Mac OS X下就变成了20:00,在Mac OS X下改过来后,再回到windows下就又错了。

之前看过这篇blog,讲了通过修改windows注册表,使得windows也把bios时间作为GMT+0时间,这样就可以解决这个问题了,具体操作如下:
在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\中加一项DWORD,RealTimeIsUniversal,把值设为1即可。

这个办法是靠调整windows时间设置来解决问题的,但是当系统中有linux时,因为linux也是使用bios时间作为系统时间,所以这时linux系统的时间就又不一致了。
最好的办法就是调整Mac OS X的时间。于是想到了强大的Bash Shell,先写脚本1用来开机时自动把时间校对准,然后关机时再运行脚本2,把时间调整回去。
脚本1:
#!/bin/bash
d=$(date "+%d")
H=$(date "+%H")
M=$(date "+%M")
S=$(date "+%S")
let "H=$H-16"

z=0
if [ "$H" -lt "$z" ]
then
  let "H=$H+24"
  let "d=$d-1"
fi

z=10

if [ "$d" -lt "$z" ]
then
  d=0$d
fi

if [ "$H" -lt "$z" ]
then
  H=0$H
fi

sudo date -u $d$H$M.$S

脚本2
#!/bin/bash
ss=$(date "+%d%H%M.%S")
sudo date -u $ss

那么如何实现自动开机运行以及关机自动运行呢?
1 开机自动运行
写shell,然后在applescript中调用shell,再把applescript保存为app,添加到login items中
注:我的.sh文件和textmate做绑定了,这样直接添加.sh文件不会执行shell,而是被textmate打开

2 关机自动运行
使用launchbar的restart和shutdown applescript,因此只需在这两个script中添加调用shell的一句即可了。

bash shell修改系统时间需要root权限,那么如何在applescript中调用时输入root密码呢?
使用如下命令:
do shell script "sudo date -u 1200" password "mypwd" with administrator privileges

Spoofing the User Agent with Safari for cmwap

In Mac OS X terminal:
chao:~ mac$ defaults write com.apple.Safari CustomUserAgent "\"hicmwapiamcomingnow\""

Now your safari user-agent has been changed to "hicmwapiamcomingnow".
OK, go internet surfing with cmwap on Mac OS X!

P.S:
of course, you can go with gprsproxy tool without changing anything for safari.
see this for details:
http://zeaster.blogspot.com/2007/02/mac-os-xdopod-696-wm50-cmwap.html

cmwap is a wap service provided by China Mobile.

Windows XP/Vista vs Mac OS X 软件对比清单

自从切换到Mac OS X平台下,就被吸引了,也不想回windows了。
不过刚开始发现windows上还是有几个软件是Mac OS X下没有的,不过现在这种软件越来越少了
现列举几个和我密切相关的说明一下:

1 Microsoft Office for Mac 通过!pass
这个是没用过Mac的人不能想象的,不过它真的有,微软自己给Apple Mac OS X 做的Office 套件
现在版本是Microsoft Office for Mac 2004,和Microsoft Office 2003功能一样
另外,Microsoft已经公布Microsoft Office for Mac 2008也将马上发布。这版的功能和Microsoft Office 2007是一样的
详见:http://www.microsoft.com/mac/products/office2004/

2 ipmsg 通过!pass
实习时公司内使用的即时聊天工具,一个很小的exe程序。
不过也有Mac OS X下的版本,详见我这篇blog:
http://zeaster.blogspot.com/2007/01/translate-ipmsg-into-gbk-on-mac-os-x.html

3 ActiveSync / Windows Mobile Device Center 通过!pass
我用的手机是dopod 696,Windows Mobile的操作系统,同步工具在XP下是ActiveSync,Vista下是Windows Mobile Device Center
不过也有Mac OS X下的类似软件Missing Sync for Windows Mobile,详见:
http://www.markspace.com/missingsync_windowsmobile.php

4 Dopod 696 USB Modem 无线modem 通过!pass
在Mac OS X 下用Windows Mobile 2003/wm5.0手机连接cmwap或者cmnet上internet?!
没错!这是可以成功!详见我的这篇blog:
http://zeaster.blogspot.com/2007/02/mac-os-xdopod-696-wm50-cmwap.html

5 智能手机工作室 Jeyo 没通过,failed
就是在Mac OS X连接手机发短信,这个功能目前我还没找到可替代的软件

6 招商银行专业版客户端 通过!pass
最近发现原来Windows Mobile下又招商银行客户端,而且可以cmwap连接,本人已试,好用!
成功登陆后使用cmwap进行各项操作均没有问题。不过也有几点需要主要:
1)不要用cmwap恢复专业版证书,会很慢,常常会失败,可以先手机连pc机,恢复完证书,再用cmwap登陆就没问题了!
2)打开招商银行掌上版前,一定要先连同gprs,例如,先打开pie,连个网。
否则招商银行掌上版会找不到网络,它不会自动开启gprs。也许这是为用户安全考虑吧。
另外也督促招商银行尽快出Mac OS X版的客户端。
掌上版详见:
http://www.cmbchina.com/PDAbank/PDADownload.htm


7 蓝牙棒的驱动 没通过,failed
实际我用的Mac OS X是装在IBM Thinkpad上的,没蓝牙驱动

8 三耳可视数字复读机 没通过,failed
我练习听力的软件,可以自动把mp3按句子分割,然后一句一句复读听。没找到Mac版的
详见:http://www.3estudy.com

Mac OS X上成功使用dopod 696 wm5.0 连 cmwap上网

哈哈!
也是使用dopod 696/himalaya wm5.0 的“internet共享”方式上网
1 在Mac OS X 下,安装Missing Sync for Windows Mobile
2 去掉Missing Sync连接方式中的usb,以下和我上篇blog中的说明一样,详见:
http://zeaster.blogspot.com/2007/02/dopod-696-wm50-cmwap.html

蓝牙方式我没试,因为偶是在IBM thinkpad 上装的Mac OS X 10.4.7,没蓝牙驱动,不过道理是一样的,应该也能成功。

Translate ipmsg into GBK on Mac OS X

在公司使用ipmsg作为即时通讯工具,不过那是windows版的,用了Mac后自然无法使用了。
最近发现不用ipmsg,好多公司的通知都收不到了,虽然偶现在实习写论文,也没什么大事儿,但还是有点不方便。
于是google之:
惊喜!ipmsg竟然有unix,Mac OS X,java等诸多版本。
立马下了个Mac的版本,装上一看,都是日文!原来ipmsg是日本人开发的,除了windows版有国人azhi做了汉化,并改名为飞鸽传书,其他版本均不支持中文。

无奈!只好试试java版的了,发现使用swt写的,于是自己汉化之。
汉化还是比较容易的,有源代码,这点上还是要赞一下那位日本作者!
主要改了3个地方,
一是把界面显示的文字汉化
二是把消息传递时的字符编码改为GBK,本想改为UTF-8的,但这样和windows版的又不兼容了,所以只好改为GBK。
三是把保存日志时的字符编码改为GBK。

另外,java版的ipmsg每次都会弹出个login的对话框,需要点一下才可以登陆,麻烦!于是改代码,把这个对话框去掉了,每次都只从ipmsg.properties文件中读取用户以及分组信息。

接下来要赞一下eclipse!
这个swt工程可以直接export成苹果的应用程序,app格式,帅呆了!
另外,程序中使用了当前目录下的文件,如icon.gif或ipmsg.properties等。通过自己建了个"./testfile.txt"的文件后,知道原来打包成.app后的当前目录就是.app所在的目录。于是把icon文件夹以及ipmsg.properties放到和ipmsg.app平级的位置就可以了!

哈哈,这下在Mac OS X下也可以使用ipmsg了,虽然java版的不支持文件传输,但以后接收公司通知是没问题了。
文件传输的问题也可以通过苹果自带的ftp服务器方便的解决。哈哈

PS - 2009-02-16:
应网友的请求, 把原来打好包的ipmsg放到了这里, 方便有需要的朋友下载
http://blogsync-java.googlecode.com/files/ipmsg-macosx.zip

另外, 如果有朋友想继续完善ipmsg for Mac OS X 的功能, 可以下载这个eclipse项目.
http://blogsync-java.googlecode.com/files/ipmsg_eclipse_project.zip

install subversion on Mac OS X

DO NOT use *.zip file, that's for windows!
decompress *.tar.gz and *-deps.tar.gz and just run:
./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-ssl --without-berkeley-db

simple shell to compress and decompress .tar.gz on Mac OS X

compress:
tar -czf dirname.tar.gz dirname

decompress:
tar -xzf dirname.tar.gz

parameter -z means .gz

Install apache 2.0.x, mysql 5.0.*, php 5.2.0 on Mac OS X

1 install apache
./configure
make
sudo make install


apache installed on /usr/local/apache2

2 install mysql
cp -Rf mysql-5.0.* /System/Library/Frameworks/Mysql.framework/
ln -s /System/Library/Frameworks/Mysql.framework/mysql-5.0.* /usr/local/mysql
ln -s /usr/local/mysql/data /Volumes/WRK/mysql-4.1.22/data


start mysql (do NOT start as root):
/usr/local/mysql/bin/mysqld
stop mysql
/usr/local/mysql/bin/mysqladmin shutdown

3 install php
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --prefix=/usr/local/php
make
sudo make install
cp src/php-5.2.0/php.ini-dist /usr/local/php/php.ini

4 config apache
vi /usr/local/apache2/conf/httpd.conf

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
PHPIniDir "/usr/local/php"

DirectoryIndex index.html index.html.var index.php

ln -s /usr/local/apache2/htdocs /Volumes/WRK/Apache2/htdocs

that's all.

show hidden files in mac os x

using AppleScript to show hidden files, switchHidden.scpt

tell application "Finder" to quit
display dialog "Show Hidden Files..." buttons {"ON", "OFF"} default button 1
copy the result as list to {buttonpressed}
try
if the buttonpressed is "OFF" then do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
if the buttonpressed is "ON" then do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
end try
tell application "Finder" to launch

sth about .DS_Store files

from
http://docs.info.apple.com/article.html?artnum=107822
http://docs.info.apple.com/article.html?artnum=301711

1. To delete all the .DS_Stores on your drive (use Terminal.app or xterm to execute this command):
sudo find / -name \.DS_Store -print -delete

2.
this is just a suggested thing for people to do so that their XP drive wont have the .DS_Store files on it everywhere...
Prevent the .DS_Store files from being created
a.    Open the Terminal (Macintosh HD > Applications > Utilities > Terminal)
b.    Type: "defaults write com.apple.desktopservices DSDontWriteNetworkStores true"
c.    Press Return
d.    Type: "cp Library/Prefrences/com.apple.desktopservices.plist /Library/Prefrences/"
e.    Press Return
f.    Type: "sudo chmod 777 /Library/Prefrences/com.apple.desktopservices.plist"
g.    Press Return
h. You will be prompted for your password.
i. Press Return
j.    Restart the computer

Mac OS X 10.4: How to prevent .DS_Store file creation over network connections
This article contains advanced material intended only for those who are looking for information on .DS_Store files. If you do not already have an opinion on this matter, you can disregard this article.

To configure a Mac OS X user account so that .DS_Store files are not created when interacting with a remote file server using the Finder, follow the steps below.
Note: This will affect the user's interactions with SMB/CIFS, AFP, NFS, and WebDAV servers.

Open the Terminal.
Type:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Press Return.
Restart the computer.
If you want to prevent .DS_Store file creation for other users on the same computer, log in to each user account and perform the steps above—or distribute a copy of your newly modified com.apple.desktopservices.plist file to the ~/Library/Preferences folder of other target users.

These steps do not prevent the Finder from creating .DS_Store files on the local volume. These steps do not prevent previously existing .DS_Store files from being copied to the remote file server. Please note that disabling the creation of .DS_Store files on remote file servers can cause unexpected behavior in the Finder (details on the following).

Mac OS X: Get Info Comments May Not Appear for Remote Volumes
When you add or edit a Get Info comment for an item on a server volume, the change is not visible to other clients or at the server itself.   

Mac OS X treats comments as a Finder property, such as icon position and view setting. Writing of these properties is local, which means your changes are not saved back to the server. Thus someone connecting to the server from a different computer may not see the Get Info comments you add to an item on the server from another remote client of the server.

For a comment to be visible to all clients, it may be changed at the server itself (see Note 2).

Notes
Comment changes do not appear to clients immediately, but they will eventually.
Copying a folder to the server yields a different result than editing an existing file or folder. Comments for that folder and items within it will be transferred when you copy it. If you must modify a comment on the server from a client, a user with adequate privileges may do so in this manner.

some info about Intel Pro/Wireless 2200(ipw2200) driver in Mac

links:
http://forum.insanelymac.com/index.php?showtopic=6912
http://www.freebsd.org/releases/6.1R/announce.html
http://sourceforge.net/cvs/?group_id=147845
http://www.seattlewireless.net/MacOS

How to mount filesystem as writable in Mac OS X single user mode

At the Darwin Boot Screen


type: -v -s to boot into single user mode.
Then type "/sbin/fsck -fy" followed by "/sbin/mount -uw /"
(as it says in the text it prints out before the prompt) in order to remount the filesystem as writable.

t42 fn+f5 开关无线网卡

Q: T4X系列 Fn+F5 不能用了,说没有安装无线和蓝牙设备?
A: 去IBM下载最新的驱动程序并安装。 安装的时候要注意一下,驱动里并没有带setup.exe,你必须自己在设备管理器里手动更新。然后还有很重要的一步,在解包后的驱动子目录WLLANINT\APPS\API里有个文件叫SBRNGAPI.EXE,
这是Intel的Sebring API,必须运行安装它,否则Fn+F5会依然无效。