2014年6月12日 星期四

MacOS skype input lag

自從不知道哪個版本後 Skype 沒事打字就會頓 之前試過只留 main log 再蓋回去有效 可是過陣子又會爛 剛生氣又找了一下,發現這個方法 感覺有效...也沒有之前那麼麻煩
  • Quit Skype
  • rm -rf ~/Library/Caches/com.skype.skype
http://community.skype.com/t5/Mac/Skype-increasing-lagging-and-using-too-much-CPU/td-p/2011405

Fuck you Microsoft

2014年1月8日 星期三

不小心 git commit --amend 了別人的 patch

環境

2d14654 HEAD@{0}: commit (amend): Other's patch
428555b HEAD@{1}: commit: Other's patch
bd33767 HEAD@{2}: commit: Previous one

先把 HEAD 退回到原來的 patch, 記得確定把你的 working directory 搞乾淨

$ git reset --hard HEAD~1
HEAD is now at bd33767 Previous one

$ git cherry-pick 428555b
....

把 amend 到別人 patch 的內容 diff 出來,重新 apply, apply 的參數 - (dash) 表示是從 STDIN 讀入

$ git diff 428555b 2d14654 | git apply -

這時打 git status 就可以發現當初的修改回來 unstage 的狀態了, 重新 git commit

$ git commit

完成

2013年11月26日 星期二

Nexus 5 w/ AOSP

Tested in KRT16M / KOT49H

Steps

Follow the steps here

http://source.android.com/source/building.html

  • unlock device
  • get source code Version

    • KRT16M | android-4.4_r1
    • KOT49H | android-4.4.2_r1
  • get nexus driver

  • fix what's missing in nexus driver

    link
    yes, pull the binary from stock ROM first If you didn't do that, your SIM cannot be used

  • (optional) get /system/media/bootanimation.zip Because AOSP android doesn't have nexus animation

  • (ADD: 2013/11/29 16:55) add Network Location Provider for GMS
    link
    Fixed Wireless GPS issues. Changed "config_locationProviderPackageNames" from "com.google.android.location" to "com.google.android.gms" in frameworks/base/core/res/res/values/config.xml

  • start to build

      $ source build/envsetup.sh  
      $ lunch  
          => Press AOSP hammerhead userdebug  
      $ make clobber  
      $ make -j 4  
    
  • flash custom recovery (CWM or TWRP)

  • flash everything other than recovery

  • fastboot reboot bootloader

  • Press VOL-UP than power button to enter recovery mode
    Choose Advanced -> sideload mode, if you are using TWRP

      $ adb sideload gapps
          gapps link http://forum.xda-developers.com/showthread.php?t=2397942
      $ adb sideload stock_boot_animation or 
          adb push bootanimation.zip into /system/media/bootanimation.zip
    
  • do a factory reset

  • (ADD: 2013/12/19 16:07)
    fix green line issue in camcorder KOT49H (KRT16M has this issue?)
    Replace /system/lib/libmmcamera_interface.so by stock one
    link

Have fun!

2013年11月12日 星期二

WeakReference listener in API

在找 OnSharedPreferenceChangeListener 範例抄時找到這個

SharedPreferences keeps listeners in a WeakHashMap. This means that you cannot use an anonymous inner class as a listener, as it will become the target of garbage collection as soon as you leave the current scope.

SharedPreferences.onSharedPreferenceChangeListener not being called consistently

靠... 這很容易踩到啊 =_=

2013年11月2日 星期六

ad block on android

plurka 廣告設計得太爛,不要怪我對你不義啊

記錄一下

adb shell mount -o rw,remount /system 
adb push hosts.for.mobile.txt /etc/hosts
adb reboot

refs: xda

2013年10月25日 星期五

Mac OS Mavericks broken list

ant 不見了

xcode-select --install 後還是不在, 用 Mac Ports 吧

$ sudo ports install apache-ant

Genymotion 1.3.0 broken

啟動後的 navigation bar 跟 orietation 一整個亂七八糟
解法: 升級到 1.3.1

http://stackoverflow.com/questions/19561669/error-on-loading-genymotion-device-on-os-x-mavericks

iMovie

更新到 10.0 後, 9.0.9 被搬到 /Application/iMovie 9.0.9 下面
iWork 也是還存在
應該可以砍了吧 = ="

電源按鈕行為改變了

以前按一下電源鈕會跑出電源選單,現在只會直接睡著
解法: 長按 1.5 秒

http://support.apple.com/kb/HT5869?viewlocale=en_US

iWork / iLife 可以免費升級

因為我一直以為只對 Keynote 有需求,所以我當初只買了 Keynote
Pages / Numbers 在試用期過後就放著讓他可以開檔案
結果這次搞一搞他就變正式版了 wwwww

http://share.inside.com.tw/posts/2899

MacPorts 壞了

gnutar 找不到
暫時解法:

sudo ln -s /usr/bin/tar /usr/bin/gnutar

不過 darwin12 != darwin13 只能等官方修吧 QQ

http://trac.macports.org/wiki/MavericksProblems  

update 10/28: mac ports 修好了, 等各 ports 陸續更新...

陸續更新...

2013年9月17日 星期二

一些 git / gerrit / ssh 設定

git / gerrit

alias

常用的指令例如 status 可以減化成短指令

~/.gitconfig

[alias]  
    ci = commit  
    st = status  
    co = checkout  
    l = log --stat=140,100  
    br = branch  
    p = cherry-pick  
    r = rebase  
    f = fetch  
    up = pull --rebase  

指令就變為

$ git st

自動產生 Change-Id

單獨 git clone 下來的 git repository 不會有 commit-msg hook
所以 push 到 gerrit 時,不會有 Change-Id
沒有 Change-Id 的話,重複 push 不會在同一個 patch 裡繼續疊加
所以 commit-msg hook 是必需要用的
(除非要手動從 gerrit 上 copy 下來...何苦呢...)

如果手邊有 BSP

    $ find . -name commit-msg \<BSP_ROOT>/.repo

把他 copy 到 .git/hooks/ 裡

gerrit server

    $ scp -p -P 29418 \<SERVER>:hooks/commit-msg .git/hooks/

template

每次 git repository commit 時,如果要填寫固定格式
可以先將文字檔存下來,就不會每次都要打一次

per repository

進 git repository 寫一個文字檔 .gittemplate

$ git config commit.template=.gittemplate

global

放在 ~/.gitconfig 裡指定

[commit]  
    template = ~/.gittemplate

手動 push 到指定的 branch

$ git push ssh://\<SERVER>:29418/\<PATH> HEAD:refs/for/\<BRANCH>

PATH 可以使用

$ git config -l | grep url remote.origin.url=ssh://\<SERVER>:29418/here/is/my/branch

在此可以知道路徑是 here/is/my/branch

BRANCH

$ git branch -a
...
remotes/origin/aosp/jb-release
...

在裡面找需要的 branch, 不需要包 remotes/origin
所以這邊需要 aosp/jb-release

$ git push ssh://mickey.acer.com.tw:29418/here/is/my/branch HEAD:refs/for/aosp/jb-release

ssh

設定 gerrit

為了不要每次下指令都指定 user name 也就是

$ repo init -u ssh://my.id@\<SERVER>...... 

~/.ssh/config

Host \<SERVER>
Port 29418
User XXXX.YYY

跟 Gerrit 裡 Settings -> Profile -> Username 一樣

2013年9月16日 星期一

BuildConfig in BSP

BuildConfig 在 Eclipse 裡會自動生成 不過如果這份 source code 同時要在 BSP 裡使用就會有問題 先找到一個很醜的解法
wrapper!
public class L {
    private static boolean BUILDCONFIG_DEBUG = false;
    static {
        try {
            Class<?> c = Class.forName("com.helloworld.BuildConfig");
            Field field = c.getField("DEBUG");
            BUILDCONFIG_DEBUG = field.getBoolean(null);
        } catch (NoSuchFieldException e) {
        } catch (ClassNotFoundException e) {
        } catch (IllegalArgumentException e) {
        } catch (IllegalAccessException e) {
        }
    }
}

2013年8月30日 星期五

使用 Dropbox 備份 source code

基本上我自己開發 sample app 都會一併使用 git 開始管理 source code
一方面為了備份, 只是存在本地總是有風險

Steps

  • 聯結 Dropbox 到電腦
    我的路徑是 ~/Dropbox/ git base 想放在 ~/Dropbox/Backup/gitbase
  • 建立 bare 的 git repository
    bare 的話,就不會把 source code 再 checkout 出來一份
$ cd ~/Dropbox/Backup/gitbase
$ git init --bare HelloWorld
Initialized empty Git repository in /Users/elvis/Dropbox/Backup/gitbase/HelloWorld/
脫光光的 git repository 長得像
$ ls -l HelloWorld
total 24
drwxr-xr-x 9 elvis staff 306 8 30 14:56 .
drwxr-xr-x 8 elvis staff 272 8 30 14:56 ..
-rw-r--r-- 1 elvis staff 23 8 30 14:56 HEAD
-rw-r--r-- 1 elvis staff 112 8 30 14:56 config
-rw-r--r-- 1 elvis staff 73 8 30 14:56 description
drwxr-xr-x 11 elvis staff 374 8 30 14:56 hooks
drwxr-xr-x 3 elvis staff 102 8 30 14:56 info
drwxr-xr-x 4 elvis staff 136 8 30 14:56 objects
drwxr-xr-x 4 elvis staff 136 8 30 14:56 refs
  • 連結原來的 source code 到 dropbox
$ cd ~/work/HelloWorld
$ git remote add dropbox ~/Dropbox/Backup/gitbase/HelloWorld
如果原來已經有一個 master 了, 你也本來沒有 upstream
$ git push dropbox master
$ git branch -u dropbox/master master
如果原來的 master 已經有 upstream 了,只是備份用,就直接
git push dropbox master

2013年8月27日 星期二

View.isInEditMode()

每次都會忘記的東西
在 Custom View 裡, 想要在 GUI layout editor 看到東西
if (isInEditMode()) { // put some item here }
這樣在 layout editor 就可以看到,而不是空空的一片
這個可以參考 Google IO 2011 影片