加快bootstrap載入速度

來自 How to Load Bootstrap Faster in 5 Easy Steps

  1. 如果用不到bootstrap script的部分,就移除它。
  2. 如果移除ootstrap script的話,用不到jQuery的話也可以順便移掉,或者改用google hosted libraries
  3. 只選用需要的bootstrap功能,而非全部載入。
  4. 不要用Glyphicons。確實需要icon字形時,可以考慮用Font Awesome代替。
  5. 將bootstrap css的部分搬到CDN。

清除 DNS 快取

2016/03/18 更新:

from Chris Laird

OS X 10.11 El Capitan

sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say flushed 
`</pre>

* * *

之前一直用

<pre>`killall -HUP mDNSResponder
`</pre>

「[Mac 及 Windows 系統下如何清除 DNS 快取,即時查看網域解析情況](http://steachs.com/archives/10821)」文章整理了常用的指令,例如:

OSX 10.10 Yosemite

<pre>`discoveryutil mdnsflushcache
discoveryutil udnsflushcaches
`</pre>

OSX 10.9 Mavericks

<pre>`dscacheutil -flushcache
killall -HUP mDNSResponder
`</pre>

Windows

<pre>`ipconfig /flushdns

OSXDaily 也有一篇How to Flush DNS Cache in OS X Yosemite with discoveryutil

OSX 用homebrew安裝rbenv,代替系統的ruby

其實,我只是想裝compass,遇到很龜毛的:

&gt; gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.1.11.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
`</pre>

然後又不想做 `sudo gem update --system`,就裝起 [rbenv](https://github.com/sstephenson/rbenv) 了...

<!--more-->

步驟很短:

<pre>`brew update
brew tap homebrew/dupes
brew install rbenv rbenv-gem-rehash ruby-build
`</pre>

然後把下面這行加到 `.bash_profile` 中

<pre>`eval "$(rbenv init -)"
`</pre>

就裝完了...

幾個簡單的用法是:
  1. 查有哪些ruby版本可以裝 rbenv install -l
  2. 安裝ruby rbenv install 1.9.3-p484
  3. 安裝完ruby執行程式後要做rbenv rehash,但是因為之前裝了rbenv-gem-rehash,可省略
  4. 設定使用的ruby版本(global) rbenv global 1.9.3-p484
  5. 設定使用的ruby版本(local) rbenv local 1.9.3-p484

    改完ruby版本後,可以用gem env查看gem的設定,可以發現其中的不同:

    `> rbenv global system
    > gem env
    RubyGems Environment:

    • RUBYGEMS VERSION: 2.0.3
    • RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
    • INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
    • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    • EXECUTABLE DIRECTORY: /usr/bin
    • RUBYGEMS PLATFORMS:
      • ruby
      • universal-darwin-13
    • GEM PATHS:
      • /Library/Ruby/Gems/2.0.0
      • /Users/filitov/.gem/ruby/2.0.0
      • /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
    • GEM CONFIGURATION:
      • :update_sources => true
      • :verbose => true
      • :backtrace => false
      • :bulk_threshold => 1000
    • REMOTE SOURCES:

    > rbenv global 1.9.3-p484
    > gem env
    RubyGems Environment:

    • RUBYGEMS VERSION: 2.1.11
    • RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-darwin13.0.0]
    • INSTALLATION DIRECTORY: /Users/filitov/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1
    • RUBY EXECUTABLE: /Users/filitov/.rbenv/versions/1.9.3-p484/bin/ruby
    • EXECUTABLE DIRECTORY: /Users/filitov/.rbenv/versions/1.9.3-p484/bin
    • SPEC CACHE DIRECTORY: /Users/filitov/.gem/specs
    • RUBYGEMS PLATFORMS:
      • ruby
      • x86_64-darwin-13
    • GEM PATHS:
      • /Users/filitov/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1
      • /Users/filitov/.gem/ruby/1.9.1
    • GEM CONFIGURATION:
      • :update_sources => true
      • :verbose => true
      • :backtrace => false
      • :bulk_threshold => 1000
    • REMOTE SOURCES:
    • SHELL PATH:
      • /Users/filitov/.rbenv/versions/1.9.3-p484/bin
      • /usr/local/Cellar/rbenv/0.4.0/libexec
      • /Users/filitov/.rbenv/shims
      • /usr/local
      • /usr/local/bin
      • /usr/local/sbin
      • /usr/local/opt/php55
      • /usr/local/mysql/bin
      • /Users/filitov/.gem/ruby/1.8/bin
      • /usr/bin
      • /bin
      • /usr/sbin
      • /sbin
      • /usr/local/bin

OSX 裝TrueCrypt後,用homebrew的brew doctor時的警告訊息

裝TrueCrypt後,再裝homebrew時,會有Unbrewed的訊息…

Unbrewed dylibs were found in /usr/local/lib
`</pre>

<!--more-->

用 `brew doctor` 訊息內容長這樣

<pre>`Warning: Unbrewed dylibs were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libmacfuse_i32.2.dylib
    /usr/local/lib/libmacfuse_i64.2.dylib
    /usr/local/lib/libosxfuse_i32.2.dylib
    /usr/local/lib/libosxfuse_i64.2.dylib

Warning: Unbrewed .la files were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
    /usr/local/lib/libosxfuse_i32.la
    /usr/local/lib/libosxfuse_i64.la

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
    /usr/local/lib/pkgconfig/osxfuse.pc
`</pre>

原因是 TrueCrypt 把 libmacfuse_xxxx.dylib 跟 libosxfuse_xxxx.dylib 裝到 `/usr/local/lib` 下了,把它搬到 `/Applications/TrueCrypt.app/Contents/Resources/Library/` 下,再做 symbolic link 回去就好。 在 stackoverflow 有人[問這問題](http://stackoverflow.com/questions/18628188/unexpected-dylib-la-and-pc-files-with-fresh-mountain-lion-install),回覆中提到有高手整理好的[script](https://gist.github.com/trinitronx/5437061):

<pre>`#!/bin/bash

libs=( "/usr/local/lib/libmacfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i64.2.dylib" \
"/usr/local/lib/libmacfuse_i64.2.dylib" \
"/usr/local/lib/libosxfuse_i32.la" \
"/usr/local/lib/libosxfuse_i64.la" \
"/usr/local/lib/pkgconfig/osxfuse.pc" )

truecrypt="/Applications/TrueCrypt.app/Contents/Resources/Library"

[ ! -d $truecrypt ] &amp;&amp; mkdir -p $truecrypt

for lib in "${libs[@]}"
do
  mv $lib "${truecrypt}/" &amp;&amp; echo "Moved ${lib} to ${truecrypt}." || echo "Problem moving: ${lib} to ${truecrypt}"
  rm $lib || echo "Problem removing: ${lib}"
  ln -s "${truecrypt}/$(basename $lib)" ${lib} &amp;&amp; echo "Linked ${lib}." || echo "Problem symlinking ${lib}"
done

brew prune
brew doctor

悼,強哥

我應該祝你一路好走。
但,我更想罵你,偏偏話到嘴邊一次又一次吞了回去。

我構築不了什麼有意義的言詞。
腦中只剩下我們房中的那缸樹蛙、那張地毯,還有把酒暢談那個女孩的情景。
還有還有…樓下有胎記常吃榴槤的房東太太,那台拉長前叉的huskey。
我仍舊經常經過那邊,每次都會想起你。

我還是想罵你,可是我說不出口。
你該知道,我並不想那樣說。
而我偏偏只能祝你一路好走。