Friday, February 27, 2015

Using Homebrew to install missing cscope/Exuberant Ctags/wget package on my MAC

I am using Homebrew as my MAC package manager now, here's my steps to install missing wget/cscope packages to my macbook pro:

1. Search if there is a "cscope" FORMULA in current Homebrew library:
$ brew search cscope
cscope


2. Start to install cscope:
$ brew install cscope
==> Downloading https://homebrew.bintray.com/bottles/cscope-15.8a.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cscope-15.8a.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/cscope/15.8a: 10 files, 736K


3. Install Exuberant ctags:
$ brew search ctags
ctags      rbenv-ctags
homebrew/php/phpctags

$ brew install ctags
==> Downloading https://homebrew.bintray.com/bottles/ctags-5.8.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ctags-5.8.yosemite.bottle.tar.gz
==> Caveats
Under some circumstances, emacs and ctags can conflict. By default,
emacs provides an executable `ctags` that would conflict with the
executable of the same name that ctags provides. To prevent this,
Homebrew removes the emacs `ctags` and its manpage before linking.

However, if you install emacs with the `--keep-ctags` option, then
the `ctags` emacs provides will not be removed. In that case, you
won't be able to install ctags successfully. It will build but not
link.
==> Summary
🍺  /usr/local/Cellar/ctags/5.8: 8 files, 364K


4. Same way to install wget:
$ brew install wget
==> Installing wget dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2: 459 files, 18M
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.16.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.16.1.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/wget/1.16.1: 9 files, 940K


References:
http://bearlin001.blogspot.tw/2015/02/homebrew-missing-package-manager-for-os.html

Homebrew: The missing package manager for OS

This is the steps I install homebrew to my macbook pro:

1. Install Homebrew itself:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 233669, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 233669 (delta 0), reused 0 (delta 0), pack-reused 233666
Receiving objects: 100% (233669/233669), 29.63 MiB | 423.00 KiB/s, done.
Resolving deltas: 100% (175242/175242), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at 00667c7 go: show what arch and os is currently building
==> Installation successful!
==> Next steps
Run `brew doctor` before you install anything
Run `brew help` to get started


2. Run Homebrew doctor:
$ brew doctor
Your system is ready to brew.

3. Install package:
$ brew install wget
==> Installing wget dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2: 459 files, 18M
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.16.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.16.1.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/wget/1.16.1: 9 files, 940K

4. Update Homebrew:
$ brew update
Already up-to-date.

5. Homebrew helps:
$ brew --help
Example usage:
  brew [info | home | options ] [FORMULA...]
  brew install FORMULA...
  brew uninstall FORMULA...
  brew search [foo]
  brew list [FORMULA...]
  brew update
  brew upgrade [FORMULA...]
  brew pin/unpin [FORMULA...]

Troubleshooting:
  brew doctor
  brew install -vd FORMULA
  brew [--env | config]

Brewing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]
  open https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md

Further help:
  man brew
  brew home


References:
http://brew.sh/
https://blog.engineyard.com/2010/homebrew-os-xs-missing-package-manager/ https://github.com/Homebrew/homebrew

Monday, February 23, 2015

QFontMetrics Class

http://doc.qt.io/qt-5/qfontmetrics.html
http://doc.qt.io/qt-5/qfont.html

https://www.google.com.tw/search?q=QFontMetrics&lr=lang_zh-CN%7Clang_zh-TW&es_sm=122&biw=1920&bih=955&tbs=lr:lang_1zh-CN%7Clang_1zh-TW&source=lnms&tbm=isch&sa=X&ei=FiDsVJfRCsacugTskILYDQ&ved=0CAsQ_AUoBA

https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png