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

Friday, September 24, 2021

Links related to how force macOS to use integrated/discrete graphics


Copied from the above post in case the post is gone


sudo pmset -a gpuswitch 0

-b when on battery
-c when on AC power
-a always

0 iGPU only
1 dGPU only
2 automatic graphics switching

To reset everything back to default:
sudo pmset -a gpuswitch 2

Tuesday, August 25, 2015

On OS X, Java Control Panel and Terminal show different Java versions

That's because Java Control Panel shows version of JRE for normal Mac user, but command line on Terminal shows version of JDK. To update JDK version, need to download the full package from Oracle website.
Older JDK version won't be replace automatically to allow us to switch back if we want. So we have to manually remove it by following the instruction here http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903

Credit: http://stackoverflow.com/a/28254333

Friday, March 29, 2013

[Fixed][VIM] E354: Invalid register name: '*'

This error occurs when you or some of your vim plugins try to access register '*' which is a system clipboard. In default Mac OSX vim, it is compiled without system clipboard support enable. You can check this by run command :version inside vim. In the result, you will see -clipboard. Disable is -, enable is +.

To solve this issue, you need to compile vim with +clipboard yourself. I suggest OSX users to use brew to help this process. Out-of-the-box brew compiles vim with +clipboard. To do this run
brew install vim
Then you might need to create a new symbolic link from your vi command to point to the newly installed vim.
First you need to know the path of your new vim. Run
brew info vim
You should see something similar to /usr/local/Cellar/vim/7.3.875 in the result which means your vim binary file is at /usr/local/Cellar/vim/7.3.875/bin/vim. To create a new symbolic link for vi, first you need to remove the existing link
sudo rm /usr/bin/vi
Then you can create a new link.
sudo ln -s /usr/local/Cellar/vim/7.3.875/bin/vim /usr/bin/vi

Monday, May 28, 2012

Mac OS X Terminal shortcut keys

Terminal is one of the most frequently using application everyday but I have never had a chance to master its short keys. Today is a good day to start.

As I know, Terminal's short keys come from Emac, when I refer to meta short keys it means that you can use esc button or setting option(alt) button as a meta key. (Settings > Keyboard > Use option as meta key)

  • Ctrl + a = Go to the beginning of the line
  • Ctrl + e = Go to the end of the line
  • Ctrl + l or Command + k = Clear screen
  • Ctrl + r = Search for previous commands (pressing more r to get earlier commands)
  • Ctrl + w = Delete the word before cursor
  • Meta + d = Delete the word after the cursor
  • Ctrl + u = Clear the line before cursor
  • Ctrl + k = Clear the line after cursor
  • Meta + t = Swap last 2 words before cursor
  • Ctrl + d = Delete a character after cursor
  • Meta + f = Move cursor to the right one word
  • Meta + b = Move cursor to the left one word

Saturday, December 24, 2011

[PostgreSQL][Mac] Modify root password (Forgot password)


  • sudo su postgres
  • supply your Mac password
  • modify /Library/PostgreSQL/9.x/data/pg_hba.conf
    • from local all all   md5
    • to local all all   trust
  • execute /Library/PostgreSQL/9.x/bin/pg_ctl restart -D /Library/PostgreSQL/9.x/data/
  • run psql
  • change postgres password
    • ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
  • modify pg_hba.conf back
  • restart again
Tested with PostgreSQL version 9.1 OSX Lion

Saturday, September 17, 2011

Thursday, July 14, 2011

How to install PHPUnit to Mac OSX

- Install PEAR
curl -O http://pear.php.net/go-pear.phar
php -d detect_unicode=0 go-pear.phar


- Install PHPUnit
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear install --force --alldeps phpunit/PHPUnit


- Set phpunit bin path to System Environment Variables

Credit
Getting and installing the PEAR package manager
PHPUnit Installed on Mac OSX

Tuesday, April 7, 2009

How to show hidden and protected files in OS X Finder

I have followed the method from the following blog How To Show Hidden and Protected Files in OS X Finder

but for my convenient I will make a summarize here.

There is just only 2 steps
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

boom!!! Your hidden files is shown.

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...