Archive for the ‘Mac/OSX’ Category

SSH FileSystem on Mac

Tuesday, September 1st, 2009

You can mount remote directory using ssh protocol using fuse. Fuse is an interesting mechanism to build a filesystem at userspace, i.e., without changing the OS Kernel.
You can install fuse using fink on OSX, but it is convenient to MacFUSE package (usually shipped with VMWare Fusion). And then download statically compiled sshfs-static-XXX from here. I put it under /usr/local/bin, and renamed to sshfs.

Now you can mount remote directory using sshfs onto your local filesystem.

$ /usr/local/bin/sshfs userid@server:/path/to/remote/dir /path/to/local/dir -o auto_cache,reconnect

Unmount is also simple

$ unmount /path/to/local/dir

.

If you see this warning message

warning: ssh nodelay workaround disabled

you may ignore it because recent ssh client that is shipped in Leopard supports TCP_NODELAY by default.

Good thing about sshfs is that you can configure it to reconnect, and locally cache the file. This means that even when your network isn’t fast enough, you will only suffer local disk I/O, and the sshfs will background transfer the changed data (more technically, disconnected operation is supported).

Enjoy!

Scripting Microsoft Excel at OS X

Tuesday, September 1st, 2009

Microsoft has a good reference to their AppleScript support.

http://www.microsoft.com/mac/developers/default.mspx

Script for updating Cell Data on Numbers.app using AppleScript

Monday, August 31st, 2009

I run a bunch of experiments, and have to parse the log file.
I used to keep it in a text file and import it to Excel or use ploticus to create a graph.
However, these are really difficult once you have to run the same experiments over and over again,
calculate confidence intervals, geomeans, and etc.
I found that on OSX, AppleScript can update the data on Excel or Numbers file.
With this feature, whenever I produce an updated data, graphs will be created accordingly.

Here is a code piece that does that.
It basically updates (x, y) to v on table t.

on run argv
  set x to item 1 of argv as integer
  set y to item 2 of argv as integer
  set v to item 3 of argv as integer
  set t to item 4 of argv as integer

  tell application "Numbers"
    tell document 1
      tell sheet 1
        tell table t
          set value of cell x of row y to v
        end tell
      end tell
    end tell
  end tell
end run

How to run the script

  • Open spreadsheet file on Numbers.app. Tables must be in place.
  • Run following commands from the terminal (assuming that above code is store in number.scpt)

    $ /usr/bin/osascript number.scpt x y v t

I’ll add a new post with an AppleScript that works with Excel 2008.

Removing Mobile-Me from the Menu

Wednesday, August 12th, 2009

MobileMe menu appeared out of nowhere.

I do not remember I installed it, or agreed to install it.

I’m sure someone else will complain about it, so I decided to leave a note.

Anyway, the solution is simple.

1) press command key while dragging the MobileMe icon out of the menubar.

Only one step.

However, if you feel mad, and want to remove MobileMe from the preference pane,

Remove /System/Library/PreferencePanes/Mac.prefPane directory.

To be safe, you can change the name to something like Mac.prefPane- so that whenever you have an error, you can rename it back.

Using Java 1.6 on Mac OS X

Friday, July 24th, 2009

1. open /Application/Utilities/Java Preferences.app

2. drag drop the version you want to the top.

Now /usr/bin/java will point to the JVM version you chose at the top.

How to make subclipse plugin working on Eclipse 3.4 Ganymede

Thursday, July 17th, 2008

Recent version of Eclipse 3.4 Ganymede and Subclipse 1.4 plugin doesn’t work out of the box.

I tested on Mac OS X both Leopard and Tiger.

Even after installing <code>svn-javahl</code> package using fink, and adding <code>-Djava.library.path=/sw/lib</code> to eclipse.ini doesn’t work.

Later I installed SVNKit library which was (optional) & “Beta” within Subclipse package, and changed javahl to SVNKit in Preference > Team > SVN.

And it works!

(below note added 7/30)

I realized upgrading svn, svn-client, svn-javahl to version 1.5 or above solve the problem using JavaHL.

Mac OSX에서 PDF reload 해주는 script (latex 쓸때 편함)

Tuesday, June 10th, 2008

PDFLatex쓰다가 내용 바꾸고 pdf를 refresh하려면 Mac에서 여간 불편한게 아니다. 
Adobe Reader나 Preview에는 Linux의 gv나 kghostview등에서 지원되는 자동 refresh 기능이 없어서 창을 닫았다가 열었다가 해야 한다. 
아니면 Safari에서 열어서 cmd-R로 refresh해주는 방법도 있는데 

TeXShop이란 놈을 발견했는데 AppleScript가 잘 돌도록 되어 있다. 
(Adobe Reader랑 Preview는 아래 처럼 안됨)

TeXShop이란 프로그램을 fink로 설치 하고 


tell application “TeXShop”
activate
close (every window whose name is “paper.pdf”)
end tell

이렇게 해주니까 paper.pdf를 닫는다. 이 script하나 만들어 놓고
open -a /sw/Applications/TeXShop.app paper.pdf 와 같이 쓰면
script로만 document를 refresh하는 효과를 가져 온다. 

이걸 Makefile에 넣어서 make pdf 하면 refresh하도록 해줬다. 
vimrc에 macro로 넣어주니까 단축키로 모든게 다 되어서 이제 매우 편하다. ㅋㅋ 

Mac OSX Leopard에서 Shift-space로 한영 전환

Friday, May 30th, 2008

보니까 Tiger와 다른 파일을 건드려야 한다.

  1. cmd-space로 한영전환이 되는 상태로 만들어 놓고
  2. System Preferences를 반드시 종료
  3. Terminal에서
    $ open ~/Library/Preferences/com.apple.symbolichotkeys.plist
    (사실 Finder에서 열어도 된다.)
  4. Property List Editor가 뜨면 다음 값을 “131072″로 바꿔준다.
    Root > AppleSymbolicHotKeys > 60 > value > parameters > item 3 : Number 131072
  5. Property List Editor를 저장 & 종료
  6. 로그아웃 & 로그인 하면 이제 shift-space로 된다.

Using gnome-terminal + Monaco font in OS X

Wednesday, November 14th, 2007

I like tab window of terminals, but default xterm doesn’t have tab window feature.
Navigating through xterms using cmd-[1-9] key is not bad but if I start to have many xterms I forgot which one is what.
So I missed Linux’s gnome-terminal or konsole a lot.
I also liked Monaco font in OS X, but Terminal.app has some compatibility issue with Korean input method. Today, I figured out I can use Monaco font and gnome-terminal in OS X.
The configuration is simpler than I thought.

  1. Install gnome-terminal from Fink repository
    If you are not using it I strongly recommend to install it. Check out fink project webpage.
    $ fink install gnome-terminal
  2. Restart X11
  3. Check if fontconfig recognizes Monaco font
  4. $ fc-list | grep Monaco
    Monaco:style=Regular
  5. Turn antialias off for Monaco font. Add following content to ~/.fonts.conf
  6. <fontconfig>
      ....
      <match target="font">
        <test compare="contains" name="family" qual="any">
          <string>Monaco</string>
        </test>
        <edit mode="assign" name="antialias"><bool>false</bool></edit>
      </match>
      ...
    </fontconfig>
    
  7. Refresh fontconfig cache
  8. $ sudo fc-cache -f
  9. Start gnome-terminal
  10. $ gnome-terminal
  11. Choose Monaco font from the Profile menu
  12. Misc terminal setting. Edit ~/.bashrc and add followings. Note that “^?” is one character. If you are on gnome-terminal “Ctrl-V, Delete” key will type ^? to the terminal
  13. if [ "$COLORTERM" == "gnome-terminal" ]; then
      stty erase ^?
    fi
    

It’s that simple :) .
Now you can pinpoint to the tabbed terminal window with Alt-[1-9]
Enjoy!

맥 OSX Tiger shift-space로 한영 전환 (Korean/English keyboard conversion using shift-space)

Monday, February 19th, 2007

맥에서 한영전환을 cmd-space로 해서 실수로 cmd-Q나 cmd-W를 누르는 실수를 하는 경험을 하게 된다.
또 패러랠즈 돌리면 한영전환이 햇갈리므로 일괄적으로 shift-space로 하면 윈도우, 맥, 리눅스 등에서 다
만족스럽게 쓸 수 있다.

  1. Open ~/Library/Preferences with Finder
  2. Open com.apple.universalaccess.plist
  3. Modify Root >UserAssignableHotKeys > 27 > modifier value to 131072
  4. Logout and login