Warning: include_once(/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php): failed to open stream: Permission denied in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217

Warning: include_once(): Failed opening '/home/nullvoid/blog.mikezhang.com/wp-content/plugins/wordpress-support/wordpress-support.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/nullvoid/blog.mikezhang.com/wp-settings.php on line 217
NullVoid » Mac Tips NullVoid » Mac Tips

Mac Tips

Fixing CrossOver in Snow Leopard 10.6

Wednesday, August 18th, 2010 -- By ET

An update of the system broke my almost-perfect installation of Bakoma Tex in Mac OS X 10.6 through Crossover.

It took me a few months to suffer from this tragedy. Each time when I need to work with LaTeX, I need to load my Windows 7 from bootcamp. I tried to reset the Java Virtual Machine and so on, but it could not fix the problem.

Then today I thought about the error message it gave when I tried to open CrossOver. It says “can’t load ‘/system/library/perl/extras/5.10.0…”, so it strikes me that maybe it is Perl that needs fixing.

I went to /usr/bin to list perl versions:
/usr/bin$ ls -l perl*
lrwxr-xr-x 1 root wheel 9 Aug 18 10:50 perl -> perl5.10.0
-rwxr-xr-x 1 root wheel 86000 Jun 24 2009 perl.old
-rwxr-xr-x 1 root wheel 51200 Jun 24 2009 perl5.10.0
-rwxr-xr-x 1 root wheel 34816 Jun 24 2009 perl5.8.9
-rw-rw-rw- 34 root wheel 807 Jun 24 2009 perlbug
-rwxr-xr-x 1 root wheel 38307 Jun 24 2009 perlbug5.10.0
-rwxr-xr-x 1 root wheel 45068 Jun 24 2009 perlbug5.8.9
-rw-rw-rw- 34 root wheel 807 Jun 24 2009 perlcc
-rwxr-xr-x 1 root wheel 17983 Jun 24 2009 perlcc5.8.9
-rw-rw-rw- 34 root wheel 807 Jun 24 2009 perldoc
-rwxr-xr-x 1 root wheel 255 Jun 24 2009 perldoc5.10.0
-rwxr-xr-x 1 root wheel 254 Jun 24 2009 perldoc5.8.9
-rw-rw-rw- 34 root wheel 807 Jun 24 2009 perlivp
-rwxr-xr-x 1 root wheel 12309 Jun 24 2009 perlivp5.10.0
-rwxr-xr-x 1 root wheel 12304 Jun 24 2009 perlivp5.8.9
-rw-rw-rw- 34 root wheel 807 Jun 24 2009 perlthanks
-rwxr-xr-x 1 root wheel 45068 Jun 24 2009 perlthanks5.8.9

Perl 5.10.0 is a 64 bit version. So I downgraded the perl to perl 5.8.9 by the following commands:

sudo rm perl
sudo ln -s perl5.8.9 perl

Then it worked like a charm.

Unlocked iPhone 4 is Cheapest in HK

Tuesday, August 3rd, 2010 -- By ET

I guess there is no point of not buying it now.


This, however, is related to another psychological bias: people compare options in terms of gains/losses with respect to a reference point, not with respect to wealth. I’m happy to buy the iphone because I learned it is a good bargain in HK, not because I believed it delivers that much utility to me (although probably it will).

I think this figure should be on every HK iphone seller’s ad, I bet the effectiveness would give the highest ROI.

Fully Utilizing My Computing Power

Tuesday, January 5th, 2010 -- By ET

Before tweaking MySQL: it used 5% of the CPU and 250MB of the memory.

After tweaking, it uses 94.3% of the CPU and 2.33GB of the memory.

I could increase the memory use even more if I needed it. :-D

screen-capture9

Join Multiple PDF files to a Single One on Mac

Monday, December 28th, 2009 -- By ET

I downloaded an ebook, it contains hundreds of one-page pdf files.  I certainly don’t want to upload all of these one-pagers to my Kindle. To concatenate these files, there is no simply and easy way.  Commercial software packages are available from $14.00 to 20Euro.

A simply perl hack does the job:

  1. Install the perl module:
    perl -MCPAN -e 'install("PDF::Reuse")'
  2. Create a perl program, call it “catpdf.pl”:

    use strict;
    use PDF::Reuse;

    prFile(“output.pdf”);

    for(@ARGV) {
    prDoc($_);
    }

    prEnd();

  3. To concatenate, call it in two possible ways:
  • perl catpdf.pl a.pdf b.pdf, or
  • perl catpdf.pl *.pdf

————–

As a side note, it is really easy to concatenate mp3 files on mac, just do:
cat *.mp3>output.mp3

Keeping SSH sessions alive with Mac OS X Terminal

Sunday, October 12th, 2008 -- By ET

Need to add the following lines to ssh config (~/.ssh/config or /etc/ssh/ssh_config depending on your desired scope)

ServerAliveInterval 300
ServerAliveCountMax 3

Newton Virus on a Mac

Thursday, March 6th, 2008 -- By ET

[youtube]http://tw.youtube.com/watch?v=qB_K66mrZi4[/youtube]

[Mac Tip] Home/End Keys and “Recent Applications/Documents”

Tuesday, November 20th, 2007 -- By ET

The default key bindings for the home and end keys in Mac OS X are different to any other operating system I’ve ever used. By default, they seem to be bound to the viewport, rather than the line of text you are editing. In a multi-line document, the Home key scrolls up to the top of the document, and the End key scrolls down to the bottom. In each case the caret stays where it was.

As a programmer I find this behaviour to be just plain wrong— I want Home and End to move to the start and end of the current line.

I have found a way to “fix” this problem by editing the default keybindings file, ~/Library/KeyBindings/DefaultKeyBinding.dict. Create the directory and / or the file if they’re not already there, and make it look like this:

{

        /* Remap Home / End to be correct :-) */

        "\UF729"  = "moveToBeginningOfLine:";                   /* Home         */

        "\UF72B"  = "moveToEndOfLine:";                         /* End          */

        "$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */

        "$\UF72B" = "moveToEndOfLineAndModifySelection:";       /* Shift + End  */

}

If there are already entries in DefaultKeyBinding.dict, just add the 4 new mappings above to the main section of your file.

Add the following line to get a “recent applictions/documents folder” on the dock.

defaults write com.apple.dock persistent-others -array-add '{"tile-data" = {"list-type" = 1;}; "tile-type" = "recents-tile"; }'

Installing MATLAB in Mac OSX with CrossOver

Friday, November 9th, 2007 -- By ET

screen-capture-2.jpg

I have my MATLAB installed in Parallel Desktops for Mac. Since I do majority of my work in Mac now, I hate to open Parallel Desktops very often. So I’m thinking about porting some important packages to use in Mac OS natively.

CrossOver is a good package, I managed to port my BaKoMa TeX into Mac OS, it works fine. MATLAB turned out to be hard. When I install it within CrossOver, it gives an error:”Can not install OLE server”. It is related to Database, so I cleaned up all the extra toolboxes, and only install MATLAB itself. The error message still comes up.

Then I zipped the MATLAB from Parallel Desktop and unzipped the files to the “Drive_C” in CrossOver. Running MATLAB gives an error “License Manager Error -9.”. Checking MATLAB website, it seems that even if I have the serial number, I still need to reinstall, but in CrossOver, I simply can not install.

Here is the solution. Just open %CrossOver_Drive_C/MATLAB7/bin/win32/license.dat, and look for something like this: “HOSTID=DISK_SERIAL_NUM=d8682dc9 PLATFORMS=i86_n SN=0″.

Go to %CrossOver_Drive_C and create a file “.windows-serial” and “echo d8682dc9 > .windows-serial”.

Everything will be fine.

As soon as I can port SAS into CrossOver, I can delete Parallel Desktops and save me 30G hard drive space.

UPDATE: I forgot to mention that I installed the latest JRE in CrossOver before I copy MATLAB.

Full version of MATLAB 2006 for Windows. Java GUI included (_without_ -nojvm).

The new Java Runtime Environment Version 5.0 Update 6 for windows (jre-1_5_0_06-windows-i586-p.exe) must be downloaded from: http://www.java.com/en/download/windows_manual.jsp.

JRE must be installed either in windows or through wine.

Then the jre folder in matlab (../Program Files/MATLAB/R2006a/sys/java/jre/win32/jre) directory must replaced by the newly generated jre1.5.0_06 in ../Program Files/Java/.

After that the ../Program Files/MATLAB/R2006a/sys/java/jre/win32/jre.cfg file must be edited to contain a single line withe: 1.5.0_06

After that, MATLAB 2006a will be fully functional (as far as know). You can either use the windows installed version or copy the whole MATLAB folder to ~/.wine/drive_c/Program Files/ (that way you won’t need the windows partition anymore).

[Mac Tip] Quickly Copy Files from Local to Remote Machine through SSH

Monday, November 5th, 2007 -- By ET

Note the beautiful title bars you see in this blog.


They are on top of the blog, each time you reload the page, you get a different title bar.

I may write a post about these title bars and the stories behind them later, but today, I’d like to record how I can copy them quickly to the title bar directory from my Mac.

There are a few steps:

  1. Create publickey authentication on the remote server, in this case: mikezhang.com
    • Type “ssh-keygen -d” on the local server
    • Then, typ “ssh -l username mikezhang.com ‘test -d .ssh || mkdir -m 0700 .ssh ; cat >> .ssh/authorized_keys && chmod 0600 .ssh/*’ < ~/.ssh/id_dsa.pub”, this creates a new directory on the remote server called .ssh and paste the public key into the file “authorized_keys”
    • Make sure the .ssh created on the remote server is chmod to 0700
    • test if we can directly go there by “ssh -l username mikezhang.com” without typing the password
  2. Create a new directory on the local machine:
    • and a new file at ~/Library/Application Support/Quicksilver/Actions/Copy To Server.sh
    • the content of the file will be
      #!/bin/sh
      #
      infile=`echo $1|tr '"' '\"'`;
      filename=`basename "$infile"`;
      `/usr/bin/scp "$infile" username@mikezhang.com:/home/username/mikezhang.com/wp-content/themes/aura/headerimg/`;
      base="http://mikezhang.com/wp-content/themes/aura/headerimg/";
      echo "$base$filename" | perl -ne 's/ /%20/g; print';

  3. That’s all

To use the shortcut, select the newly created title bars, invoke QS, type “Current Selection..”, then “TAB”, then “Copy to”, the option called “Copy to Server” will show up, press Enter. It’s done.

Here is the newest addition:

Prevent Mac from leaving .DS_Store on Windows Machines

Wednesday, October 31st, 2007 -- By ET

To prevent the creation of these files, open the Terminal and type:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true


BlogTimer
You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2020. All rights reserved.
All trademarks property of their owners.