Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

Saturday, October 8, 2016

Convert adf binary to ascii whith GDAL on Mac OS

Link.


brew install gdal --with-python
brew install homebrew/python/numpy
brew install homebrew/python/numpy

If you get warnings like: Python modules have been installed and Homebrew's site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run: *****

Just run the script which is given.
Read more ...

Thursday, September 22, 2016

How to enable "Create a Windows 7 install disk" option in Boot Camp Assistant

Link.


1. Find Boot Camp Assistant.app in /Applications/Utilities/ and right click "Show Package Contents".

2. Backup the Info.plist in folder Contents and edit Info.plist.

3. Open System Information, copy Model Identifier (e.g. MacBookPro8,2) to the "Info.plist - PreUSBBootSupportedModels"

4. Copy the Boot ROM Version (e.g. MP11.222C.B11) from System Information to "Info.plist - DARequiredROMVersions"

5. Rename "Info.plist - PreUSBBootSupportedModels" to "Info.plist - USBBootSupportedModels".

6. Save it and copy back to the Boot Camp Assistant.app in Contents folder.

To create a bootable USB for windows installation.

1. Open Boot Camp Assistant.app

2. Only check the box for "Create a Windows 7 or later version install disk".

3. Select the iso file and the destination USB driver.
Read more ...

Thursday, July 21, 2016

Turn off automatic attachment preview in Mac Mail App

Link.


Turn off automatic attachment preview in Mail

Mail, by default, provides a preview of attachments in can read, such as graphics and PDF files. However, you can run a command in Terminal to turn this off. Run the following:
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes

Quit Mail and relaunch it. When you view a message, all attachments will be shown as icons only.

To restore the original functionality, run this command:
defaults write com.apple.mail DisableInlineAttachmentViewing -bool no
Read more ...

Wednesday, June 8, 2016

Mac Word-to-PDF template error: "A footer of section 1 is set outside the printable area of the page. Do you want to continue?"

1. File --> Page Setup...

2. Paper Size --> Manage Custom Sizes...


3. Create a New one with the name "Full A4", set margins to 0 mm.
Read more ...

Thursday, October 22, 2015

Disable the Dock icon for any Application (MAC OS X)

Link.


There are many applications on your Mac that don't need a Dock icon. Having a Dock icon for applications that are accessed through a menu bar item or constantly run in the background would just waste space and clutter up your Dock. Many applications like this automatically hide their Dock icon (Google Notifier, Quicksilver) however some don't (Launchbar, HardwareGrowler).

Luckily, if it is a cocoa application, you can hide the Dock icon yourself. To see if it is possible, right-click (Control-click) on the application icon. If "Show Package Contents" is in the menu that appears, you can hide the icon in the Dock.

If this is the case, select "Show Package Contents" and look for the "Info.plist" file inside the Contents folder. Open this file using TextEdit by right-clicking on it and choosing "Open With - Other" from the menu.

In the file, paste the following two lines just after <dict> on the 6th line:

<key>LSUIElement</key>
<string>1</string>

Save the file and close it. For the changes to take effect, you need to move the application to the desktop and them back to its original location (OS X keeps a cache of the file, so you need to trick it into checking it again).

Now when you open the application, no icon will appear in the Dock. I wouldn't recommend doing this with your regular applications like iTunes and Safari as this also has the side-effect of disabling the menu bar. This means that you will have to quit the application using the keyboard shortcut Command-Q. If the application doesn't have any windows, you will have to quit it from Activity Monitor (in Applications/Utilities).

To bring back the Dock icon, simply open up the Info.plist file and remove the lines you added.

If you are too lazy to do this yourself, FoggyNoggin Software has created an application called Dock Dodger that automates the process.
Read more ...

Thursday, October 8, 2015

gsl-config not found ERROR when install R package

Download gsl latest version from here.

./configure
make
sudo make install
Now you can install the R package without errors.
Read more ...

Sunday, September 27, 2015

Quickly Show/Hide Hidden Files on Mac OS X

Link.


// Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES

Hold the ‘Option/alt’ key, then right click on the Finder icon in the dock and click Relaunch.

// Hide hidden files
defaults write com.apple.finder AppleShowAllFiles NO

Again, hold the ‘Option/alt’ key, then right click on the Finder icon in the dock and click Relaunch.
Read more ...

Thursday, September 17, 2015

Disable internal laptop display when external display is attached

Link.


Before Lion it was possible to run an external display off a laptop and have the internal display disabled, even if you opened the lid. This can be useful for a myriad of reason including energy saving and better wifi reception. With Lion the internal display will always turn on when the lid is opened, even if there is already an external display connected.

A solution was posted on the Apple support forums by user chenga.8.

To go back to pre-Lion behaviour enter the following command in Terminal:
sudo nvram boot-args="iog=0x0"

To undo this change type type the following command or zap the PRAM (press Cmd+Opt+p+r at power up):
sudo nvram -d boot-args
Read more ...

Thursday, February 5, 2015

Textmate: Display the full file path in title bar

Link.


Create a file named '.tm_properties' in you home directory.
Add the following sentence in the '.tm_properties' file.

windowTitle = "$TM_DISPLAYNAME – $TM_DIRECTORY"
Read more ...

Wednesday, November 19, 2014

Getting MacPorts to Work Behind a Firewall

Link.


MacPorts is an extremely useful command line utility for managing open-source software (ports) on your Mac. It makes it a breeze to to find, download, compile and install open-source software on your machine, as well as upgrade to the latest versions without wasting a lot of time.

Unfortunately those of us behind corporate firewalls are usually prevented from using the tool due to network security restrictions of the rsyncd protocol.

I hope this post helps you solve some of the most common issues encountered when running MacPorts selfupdate or sync commands behind a corporate firewall.

What you will need
  • A recent copy of MacPorts installed. If you have not done this yet, please head over to MacPorts to get the latest version 
  • Your corporate proxy server name, port and proxy user credentials if necessary. 
  • The ability to (sudo) temporarily increase your account privileges to those of an administrator on your Mac. 
Step 1: Switch MacPorts to use HTTP

MacPorts is configured to synchronize its list of ports via rsync. We will change it so it uses HTTP instead.

Open a terminal window and edit the MacPorts source configuration file. Enter the superuser password when prompted.
sudo vim /opt/local/etc/macports/sources.conf
Comment out the line at the bottom of the file and add a new one that uses the HTTP address. When you are done, it should look something like this:
#rsync://rsync.macports.org/release/ports/ [default]
http://distfiles.macports.org/ports.tar.gz [default]
Save the file and exit the editor.

Step 2: Setup your Proxies

Edit your profile script, this could be in the form ~/.profile, ~/.bash_profile, etc.
vim ~/.profile

Add the following to the bottom of the file:
################################### CORP PROXY ###################################
PROXY_SERVER=corporate-proxy-server-here
PROXY_PORT=8888
PROXY_USERNAME=proxy_account
PROXY_PASSWORD=proxy_password
PROXY=$PROXY_USERNAME:$PROXY_PASSWORD@$PROXY_SERVER:$PROXY_PORT
# HTTP and HTTPS
export http_proxy=http://$PROXY
export HTTP_PROXY=http://$PROXY
export https_proxy=http://$PROXY
export HTTPS_PROXY=http://$PROXY
# RSYNC
export rsync_proxy=$PROXY
export RSYNC_PROXY=$PROXY
##################################################################################

Save the file and exit the editor.

Step 3: Edit the sudoers file

This is required to forward your proxies to the superuser account every time you run sudo port commands.
sudo visudo

Append the following to the end of the list of Defaults:
Defaults env_keep += "http_proxy rsync_proxy HTTP_PROXY RSYNC_PROXY"

Save the file and exit the editor.

Restart the Shell

Exit the terminal shell and start a new session to load the new settings.

Test your new proxy environment variables are now available:
env | grep http
You should see something like this:
$ env | grep http
http_proxy=http://proxy_account:proxy_password@corporate-proxy-server-here:8888
HTTP_PROXY=http://proxy_account:proxy_password@corporate-proxy-server-here:8888

Update your Ports

You should now be able to load the latest ports using the http proxy. Test this by typing the following command. Note that the -d switch invokes the command in debug mode. We do this so you can see what is happening behind the scenes.
sudo port -d sync

You should see a long list of ports being downloaded.
Read more ...

Tuesday, October 28, 2014

pdftk in Mac OS X with tips

Download pdftk for Mac.

tips:

1. Split multi-page PDFs into single page PDFs
$ pdftk my_multi_page.pdf burst
$ pdftk my_multi_page.pdf burst output my_directory/page_%02d.pdf

2. Pull some pages out of a PDF but keep the rest
$ pdftk my.pdf cat 1-5 13-21 24-end output my_edited.pdf

3. Concatenate (that’s join!) multiple pdfs into one big pdf
$ pdftk part0.pdf part1.pdf cat output the_whole_book.pdf

4. Get all of the images and other attachments out of a PDF and put them in a folder
$ pdftk my.pdf unpack_files output ~/attachments_from_my_pdf/

5. Print stats and metadata about a PDF
$ pdftk my.pdf dump_data

6. Add a background watermark (or a foreground overlay) to a pdf

- For a background
$ pdftk my.pdf background bg.pdf output my_watermarked.pdf

- For an overlay
$ pdftk my.pdf stamp overlay.pdf output my_overlayed.pdf
Read more ...

Wednesday, October 22, 2014

Copy file or folder path to the clipboard in Mac OS X

Link.


  1. Launch Automator
  2. Double-click the Service icon
  3. Toward the top of the right column, you’ll see this line of text: “Service receives selected _____ in _____”. Choose “Files or Folders” from the first menu and “Finder” from the second.
  4. Click on Utilities in the Actions library on the left side. Double-click “Copy to Clipboard” in the middle column.
  5. Go to File > Save in the menu bar and name your service Copy File Path.
  6. Launch System Preferences and go to the Keyboard pane. Click on the Keyboard Shortcuts tab.
  7. Select “Application Shortcuts” from the list on the left. Next, click on the + button at the bottom of the list.
  8. A small window will come up with a few options that need to be set. Select “Finder” from the Application menu, type Copy File Path as the Menu Title, and create your own Keyboard Shortcut. If you don’t know what to put here, you can just press Shift+Command+C on your keyboard. Click Add and we’re done!


If you’re not keen on keyboard shortcuts, the service you created is also accessible when you right-click on an item in Finder and select Services > Copy File Path from the contextual menu. The actual file we created for this service is located in: ~/Library/Services in case you ever want to delete it or copy it to put on another Mac.
Read more ...

Tuesday, October 14, 2014

Terminal command to check used memory in OS X

top -l 1 | head -n 10 | grep PhysMem
Read more ...

Tuesday, September 23, 2014

How to disable Adobe Reader in Safari?

Link.


Go to the "Help" menu in Safari and select "Installed Plug-ins". This will open a new tab displaying information about all of the currently installed plug-ins. Find the entry for Adobe Acrobat. Below it will be a line that reads something like:
Adobe® Acrobat® Plug-in for Web Browsers — from file “AdobePDFViewer.plugin”.
Note the name of the file from that line.
On your hard drive you will find a Library folder. In that folder will be another folder called Internet Plug-Ins. Inside that folder you should find the file that was shown in the "Installed Plug-ins" tab. The full path should be /Library/Internet Plug-Ins/AdobePDFViewer.plugin. That file needs to be deleted. Dragging it to the trash will do the trick.
If you are not sure you want to delete the file, you can move it to another location. For instance, you could create a new folder named "Disabled Plug-Ins" in the "Installed Plug-Ins" folder, and move the file to the new folder.
Then quit & relaunch Safari.
Adobe acknowledges this is a "known issue" and recommends this procedure.
Read more ...

Sunday, September 15, 2013

Java 1.6.0_51 breaks MATLAB 2012b

The was an issue in the Java security updates that Apple released for Mac OS X (as mentioned above). These updates install Java 1.6.0_51 and the exact build number looks like this (ending with M4508):
Java™ SE Runtime Environment (build 1.6.0_51-b11-456-10M4508) You can check if you have installed the xM4508 versions by running any one of the following commands on the Terminal of your Mac OS X:
java -version 
OR
/usr/libexec/java_home -v 1.6 -exec java -version 
If you have previously installed the xM4508 versions of the Java updates you can upgrade to the fixed xM4509 version by manually installing the following update:
Mac OS 10.7.x and 10.8.x:
================
Mac OS 10.6.x:
================
Confirm that you have the updated Java version by executing any of the above two commands. The exact build number looks like this (ending with M4509):
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-10M4509)
updates already (ending with M4508), you should receive this fix (ending with M4509) automatically through Software Update / App Store.

source: here
Read more ...

Friday, June 21, 2013

将 mac 系统安装盘标记为 AF

>> 打开windows下cmd
>> 输入diskpart
>> 当光标前面变成DISKPART>之后,输入select disk 0(mac系统安装盘)
>> 输入list partition找到mac安装盘的分区号
>> 输入select partition x, x为mac安装盘分区号
>> 输入set ID=AF
Read more ...

Install NetCDF on OS X (10.8)

Firstly, We have to install Xcode and then install Command Line Tools (Preferences -> Downloads).

Then, We have to install gfortran. I currently choose to use the relevant tar-file provided at the High Performance Computing web page. There are up-to-date distributions for some systems (only Mac OS X 10.7 (Lion) and 10.8 (Mountain Lion) as of the last update of this page). For simplicity, I would recommend only to install the relevant "gfortran only" distributions.

The files are gzip'd tar-files which should be unpacked, for instance by using the Terminal application, as follows:

sudo tar xvfz [tar-file] -C /

Note that the files are installed in /usr/local system directories which require the administrator password.

Install zlib follow this tutorial.
No special treatment how to install zlib in OS Lion or Linux. In Macintosh, you can install them via Fink, but i prefer not to do that to make sure where the library of zlib goes. Even zlib for Mac OS X is already included as part of Mac OS X
1. Download the source code here. I used zlib1.2.5 version.
2. tar xzf zlib-1.2.5.tar.gz
3. cd zlib-1.2.5
4. ./configure --prefix=/usr/local
5. make
6. make install

Install HDF5 follow this tutorial.
Thanks to the software engineer of HDF5 especially Madam Barbara Jones who helped me figure it out my difficulties on HDF5 installation at OS Lion. Here, I put the step by step how to install HDF5 1.8.7 for lion.
1. Download the source code of HDF5 1.8.7 from HDF5 URL. I used Mac OS X 10.7.0 (Intel 64-bit) static version
2. Open terminal and tar them
3. If you previously failed to install them, get a clean copy of the HDF5 source code.  (Alternately, run “make distclean”)
4. In the top directory of the HDF5 source code, you will see the config/ directory.  Go into the config/ directory. using “cd config”
5. You will see a file called: “gnu-flags”
6. Edit the “gnu-flags” file using emacs or vi and search for “PROD_CFLAGS”. Change the value of PROD_CFLAGS to “-O0″ (capital “O” letter + zero) for “gcc-4.*”.
7. ./configure –with-zlib=/usr/local –prefix=/usr/local –enable-fortran . Here you download HDF5 under “/usr/local” root.
8. make
9. make check
10. make install
11. sudo make install

Install NetCDF follow this tutorial.
1. Download the 4.1.3 release source code is available from the following URL (http://www.unidata.ucar.edu/blogs/news/entry/netcdf_c_fortran_c_version)
2. open “terminal”
3. write “tar xvf netcdf-4.1.3.tar” on terminal and continue to write the below commands:
4. export FC=gfortran
5. export F77=gfortran
6. export F90=gfortran
7. export CFLAGS=’-O3′
8. go to the folder where you extracted netCDF source file *tar.gz file:  ”cd netcdf-4.1.3″
9.  ./configure –prefix=/opt/netcdf4/gfortran –enable-netcdf-4 –with-hdf5=/usr/local . Here you installed netCDF file under /opt/netcdf4/gfortran folder. If you have different compilers such as “ifort” , you can later installed another netCDF4 under different folder, let say “/opt/netcdf4/ifort”.
10. make
11. make check
12. sudo make install
Read more ...

Install GMT on debian/ OS X 10.8

Recipe:

Go to GMT website ( GMT 5.0), select DOWNLOAD from navigation bar in the left.
Fill a INSTALL_FORM for installation parameters.
  1. Select GMT version: [ GMT 5.0.0 beta]
  2. Select default units in GMT: [ SI units (cm)]
  3. Select POSIX Advisory File Locking: [ NO. Do not use file locking]
  4. Select passive [Default] or active ftp transmission: [ Passive ftp]
  5. Select the components you want (bzip2 sizes indicated): [ GMT source, docs, supplements][ GSHHS Coastlines (all resolutions)]
  6. Select which triangulation algorithm to use: [ Watson's algorithm]
  7. Select library build type: [ Shared (dynamic) Libraries]/[ Static Libraries]
  8. Select the C compiler you want to use: [ gcc][ Use default (whatever your compiler prefers)]
  9. Select the make program you want to use: [ make]
  10. Select GMT final destination directories: [ /opt/GMT]
Save the parameter list as a text file ( params.txt) in your home directory.
Download  install_gmt.sh to your home directory.
Run sh install_gmt.sh params.txt
For csh tcsh, edit .cshrc add line set path=(/opt/GMT/bin $path)

One has to give the full permission for path /opt/GMT (su; chmod 777 /opt/GMT).

If you got ftp proxy problems, then you can go to GMT mirror sites to download  gmt-5.0.0b.tar.bz2( GMT source ) and gshhs-2.2.0.tar.bz2( GSHHS Coastlines) to you home directory. Change your params.txt.
GMT_ftp=n
GSHHS_ftp=n
and if you still get proxy problem, then you can change
passive_ftp=n
If the installation process can not find you Netcdf correctly, you have to setup the lib and inc for it. ( csh)
locate libnetcdf
find path for libnetcdf.a libnetcdf.so ... and so on. ( /usr/lib/libnetcdf.*)
locate netcdf.inc
find path for netcdf.inc. ( /usr/include/netcdf.inc )
setenv NETCDF_INC /usr/include/
setenv NETCDF_LIB /usr/lib

That is all.

To install netcdf, ubuntu/debian user can simply type sudo apt-get install netcdf-bin libnetcdf-dev
For OS X user, You can also follow this tutorial, but have to install NetCDF firstly, and put netcdf path to parameter form. (/opt/netcdf4)
Read more ...

How to install NetCDF @ Macintosh Lion

This post is from here.


Here, I would like to post how to install NetCDF 3.6.3  and/or NetCDF 4.1.3 in Macintosh Lion. NetCDF (network Common Data Form) is an interface for array-oriented data access and a library that provides an implementation of the interface. It is useful when you want to read *.nc file or you want to create small size unformatted input/output data.
Most of the time NetCDF requires zlib or slim and HDF5  libraries. I will show you how to install them too in my blog. It is important to finish job installation of HDF5 and zlib successfully. Therefore, I suggest you to install zlib and HDF5 before moving to NetCDF installation process.
I assumed that you have installed free “gfortran” compiler in your iMac. If you don’t know how to install gfortran in your iMac, please follow how to install gfortran first.
NetCDF 3 installation:
This process is relatively easy compared to NetCDF4. NetCDF3 is enough if you want to read or write netCDF format, but when it goes to the utilization of MPI you need NetCDF4. NetCDF3.6.3 is a very stable version, so you can depend on that. First I will show you to the step by step installing netCDF3 @ iMac lion.
1. Go to netCDF website and download the source code of netCDF3. http://www.unidata.ucar.edu/downloads/netcdf/netcdf-3_6_3/index.jsp. Usually mac automatically makes *tar.gz file into only *tar file.
2. Open terminal and go to the place where you saved the *tar file
3. tar it using “tar xvf netcdf*.tar”
4. export FC=gfortran
5. export F77=gfortran
6. export F90=gfortran
7. export CXX=g++
8. export FFLAGS=’-O3′
9. go to the folder where you extracted netCDF source file *tar.gz file
10 ./configure –prefix=/opt/gfortran/serial/netcdf3
11. make
12. make check
13. sudo make install, enter your password
14. Wait until finish.
NetCDF4 installation:
1. Download the 4.1.3 release source code is available from the following URL (http://www.unidata.ucar.edu/blogs/news/entry/netcdf_c_fortran_c_version)
2. open “terminal”
3. write “tar xvf netcdf-4.1.3.tar” on terminal and continue to write the below commands:
4. export FC=gfortran
5. export F77=gfortran
6. export F90=gfortran
7. export CFLAGS=’-O3′
8. go to the folder where you extracted netCDF source file *tar.gz file:  ”cd netcdf-4.1.3″
9.  ./configure –prefix=/opt/netcdf4/gfortran –enable-netcdf-4 –with-hdf5=/usr/local . Here you installed netCDF file under /opt/netcdf4/gfortran folder. If you have different compilers such as “ifort” , you can later installed another netCDF4 under different folder, let say “/opt/netcdf4/ifort”.
10. make
11. make check
12. sudo make install
13. enter your password and wait until finish.
Read more ...

Wednesday, December 12, 2012

Mac OS X 下用 iTunes 截取音乐任意部分的方法

右击进入歌曲 显示简介->选项,里面有“起始时间”和“停止时间”两个选择,填入你刚才记录的时间段。

选中歌曲,右击选择“转换所选内容为ACC”。就可以完成音乐截取了。
Read more ...