顯示具有 Memo 標籤的文章。 顯示所有文章
顯示具有 Memo 標籤的文章。 顯示所有文章

2012-12-17

刪除 Open With 選單裡重覆的項目


OSX 用久了會發現當要用右鍵開啟某些檔案時,在 Open With 選單裡有重覆的項目,此時可在 Terminal 裡輸入 :

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\ -domain system -domain user

待執行完成之後 Relaunch Finder (control+option+滑鼠右鍵 點選 Finder ),即可刪除重覆的項目。

ref : http://itpixie.com/2011/05/fix-duplicate-old-items-open-with-list/#.UM3vUqWVgcQ

2012-03-06

linux / osx 指令筆記

顯示程式需要的 library
readelf -d <file> | grep -i shared

iptables 將 port 從 443 導到 5200
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 5200
(刪除)
iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 5200
查看 iptables port forward 之設定
iptables -t nat -L -n -v

將 ssh public key 加入到對方電腦的 authorized_keys 裡
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'

查詢某檔案或某資料夾 (包含其子資料夾) 之佔用的硬碟空間
du -sh ./file_or_dir

透過 SSH 遠端執行指令 "pwd; ls;"
ssh -l user0 ip0 -p port "pwd; ls;"

SSH Tunnel 建立通道 (在 ip0 建立通道,讓輸入指令端可以透過 ip0 連線至 TARGET_IP) :
ssh -N -L localhost:2222:TARGET_IP:TARGET_PORT user0@ip0

SSH Tunnel 建立通道 (此時在 ip0 可以透過 2222 連回輸入指令端):
ssh -R 2222:localhost:22 user0@ip0 -p port0

建立 socks5 (3128) 通道:
SSH Tunnel 建立後 (此時應已進入 ip0:port0 ) 再輸入 :
ssh -p 2222 -D 3128 user1@localhost

OSX 開啟/關閉 apache2:
sudo apachectl start
sudo apachectl stop

OSX 開啟/關閉 postfix:
sudo launchctl start org.postfix.master
sudo launchctl stop org.postfix.master

同步/更新時間:
ntpdate pool.ntp.org

mac port 一些指令:
1) port selfupdate 檢查更新
2) port installed 檢查已安裝項目
3) port search [item] 搜尋可安裝項目 (例 port search nodejs)
4) port install [item] 安裝項目
5) port uninstall [item] 反安裝項目
6) port upgrade outdated 更新已安裝的套件

OSX Finder 顯示隱藏檔案及資料夾:
1) defaults write com.apple.Finder AppleShowAllFiles TRUE
2) killall Finder

OSX Finder 不顯示隱藏檔案及資料夾:
1) defaults write com.apple.Finder AppleShowAllFiles FALSE
2) killall Finder

screen
1) screen -m -d -S <ScreenName> <Command> 背景開新的 screen 並執行程式
2) screen -ls 列出目前所有 screen 狀態
3) Control+A 放開再按 D 跳離 screen
4) Control+A 放開再按 Esc 上下捲動 Screen

設定日期
date -s "2 OCT 2006 18:00:00"

更改 ulimit -n 之預設上限
1. 編輯檔案 /etc/security/limits.conf , 在結尾新增 :
* soft nofile 50240
* hard nofile 50240
2. reboot

ubuntu 新增 user
sudo adduser <username>

ubuntu 設定 user 為管理者
sudo adduser <username> admin

OSX 顯示目前正在等待連線的 TCP Port
sudo lsof -nP -iTCP -sTCP:LISTEN

MacPort 使用 http 更新 :
修改檔案 /opt/local/etc/macports/sources.conf
將原本的 [default] 那一行改成
http://www.macports.org/files/ports.tar.gz [default]
最後使用指令
cd /opt/local/etc/macports/ && sudo port -d sync && sudo portindex
ref : https://destefano.wordpress.com/2011/03/18/macports-behind-a-proxy/


2011-11-24

git 使用筆記

刪除所有 .git 資料夾
    find . -type f | grep -i .git | xargs rm
取得程式:
    git clone git://URL
取得最新的程式:
    git pull
目前狀態:
    git status
如果確定 repo 有更新,但使用 git pull 確沒有效果(顯示 Your system reports no Git commands at all.)時使用:
    git fetch origin master:tmp
    git merge tmp

程式修改完之後:
    git add . 
    git commit –a –m '註解'

    git commit -i <file> -m '註解'
刪除沒有被加入到 git 的檔案:
    git clean –d -f
回復上次 commit 前的狀態(包含實際檔案):
    git reset –-hard HEAD^
回復到與 repo 上 origin/master 相同的狀態(包含實際檔案):
    git reset –-hard origin/master
個別檔案回復到 modified 之前的狀態(包含實際檔案):
    git checkout <filename>
個別檔案回復到某次 commit 時的狀態(包含實際檔案):
    git checkout <commit id> <filename>
回復上次 commit 前的狀態(不包含實際檔案):
    git reset –-soft HEAD^
更改 branch 名稱:
    git branch -m <old_name> <new_name>
修改的程式回寫至 repo:
    git push

--------------------
列出 stash 清單:
    git stash list
將 working copy 暫存:
    git stash
取出最後一次執行暫存的 stash:
    git stash pop

--------------------
產生備份:
    git bundle create <filename> --all
還原至某目錄:
    git clone <filename> <foldername>
    至該 folder 內輸入:
    git fetch
    git pull

將現有的 repository push 還原至其它 repository
    git push http://<git repo url> +<current branch>:master

--------------------
收拾失控的 repository (objects/pack/ 資料夾內出現一堆 pack file)
    git gc --aggressive
統計 repository objects
    git count-objects -v

2010-10-28

Unity 3D 相關筆記

  • 2012-04-30
    • JSON Serializer/Deserializer 參考這篇,程式碼參考這裡。
  • 2012-04-13
    • Unity3D 卸載未使用的資源指令 : Resources.UnloadUnusedAssets()
  • 2011-02-25
    • Unicode CJK (中文, 日文, 韓國) 字元範圍,參考這篇文章。
  • 2010-12-13
    • Unity 3D 執行順序 (Link)
  • 2010-11-02
    • 以 DllImport 方式把 Lua 嵌在 C# 裡(適用於 Unity3D),參考這篇文章。
  • 2010-10-28
    • 利用 Command 建立 AssetBundle 參考這篇討論。
    • 執行時期載入程式碼參考這篇討論。