DRYな備忘録

Don't Repeat Yourself.

cocoapodsでAlamofire入れようとしたらclang: error: linker command failed with exit code 1と叱られる

結論

% pod install
Analyzing dependencies
Downloading dependencies
Installing Alamofire (3.4.1)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `unko.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

書いてあるがな!

[!] Please close any current Xcode sessions and use unko.xcworkspace for this project from now on.

% open unko.xcworkspace

解決!

DRYな備忘録として

diffとpatchのワンライナー

diff -u ./index.html ./public/index.html | git apply -R

サーバからブラウザにプッシュ通知を送りたい(非WebSocket、非ロングポーリング)

追記 2017/06/19

このエントリで絶賛してる公式ドキュメントがいつの間にかすっげーわかりづらいものになってたので、あらためて自分でサンプル書いたやつがこちらです。

otiai10.hatenablog.com

以下原文

Progressive Web App Dev Summit っていうのがあったので行ってきました。結論から言うとめっちゃ面白かったです。

events.withgoogle.com

個人的にはだいたいの場合「ネイティブアプリが作りたい」と思う同期の多くが「プッシュ通知したい」だったので、ウェブで完結してプッシュ通知できるんならそれはとっても嬉しいな、って。

ゴール

  • サーバからのプッシュ通知を
    • PCのChromeが受け取れる
    • サーバ(GCM)からのプッシュなので、WebSocketとかロングポーリングとかしてnew Notificationして…、とかやらなくていい!

f:id:otiai10:20160622051523p:plain

参考

作業記録

実際の作業記録はこれです: Commits · otiai10/push-notifications · GitHub

マジでこれなので、詰まったところだけ備忘録します

ServiceWorkerが更新されない問題

問題

  • sw.jsの内容を更新したのに、出てくるpushNotificationのアイコンとかが変わってないよ

解決

雑感

  • ぜんぜん詰まらなかった。ドキュメントがめちゃくそ丁寧!
  • これをAndroidChrome相手にやれば、ネイティブのスリープ画面での通知トーストとかが使える!はず!最高!
  • Progressive Web App dev summit、すげー面白かったです
    • #pwadevsummit - Twitter Search
    • もちろんpushNotificationも具体的でよかったんですが、
    • Offline First
      • ServiceWorkerを活用したcache
    • 全体的には、manifest.jsonとServiceWorkerがすげえな、っていう印象です(雑)

DRYな備忘録として

v2とか作ってる別リポジトリをv1のリポジトリにマージっぽいことしたい

なんかv2っぽいものをゼロスクラッチで別リポジトリに書いてたけど、v1のリポジトリにわりとスターついてるし、page viewもあるのでゼロスクラッチだけど、最終的にはv1で、もちろんコミットログを上乗せした形で公開したいな、と。

参考

方針

  1. repo_v2を、repo_v1のリモートに、適当な名前でpushする
  2. repo_v2相当のブランチを、ローカルのrepo_v1のrepoでfetchする
  3. repo_v1でv2本命なブランチをつくり、すべての(.git以外の)ファイルを削除したコミットをする
  4. git logで出てくるコミットのリストを、このブランチにcherry-pickで流し込む

ログ

ローカルのv2リポジトリkcwidgetという)

% git remote -v
origin  git@github.com:otiai10/kcwidget.git (fetch)
origin  git@github.com:otiai10/kcwidget.git (push)

ここに、v1リポジトリkanColleWidgetという)をremoteとして登録する

% git remote add v1remote git@github.com:otiai10/kanColleWidget.git

v2でのコミットログをv1リポジトリのリモートにpushする

% git push v1remote develop:wip/v2

つぎに、ローカルのv1リポジトリで、今まさにリモートのv1リポジトリにpushされたv2相当のブランチをfetchする

% cd ~/proj/chrome/kanColleWidget
% git fetch origin
remote: Counting objects: 367, done.
remote: Compressing objects: 100% (297/297), done.
remote: Total 367 (delta 131), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (367/367), 58.80 KiB | 0 bytes/s, done.
Resolving deltas: 100% (131/131), done.
From github.com:otiai10/kanColleWidget
 * [new branch]      wip/v2 -> origin/wip/v2

これでv2リポジトリで書いたコミットたちがv1リポジトリで参照できるようになったので、あとは順次古いものからcherry-pickしていけばよい。

まずは、v2のコミットたちを迎えるべく、土地をゼロに均す(しかし.gitは保持)コミットをしとく。

% git checkout -b v2/master
% find . -mindepth 1 -maxdepth 1 ! -name ".git" -delete
% git commit -m "(just like) starting over~♪"

いよいよ、v2相当ブランチから、cherry-pickしていく

% git log --pretty=%H --reverse origin/wip/v2 | xargs git cherry-pick

で、最後の仕上げ

% git push origin v2/master

これで、さっきまで別リポジトリで開発していたv2のコミットが、v1のコミットの上に積み重なる形で、v1リポジトリのブランチとして生まれ変わった。 (需要なさそう)

DRYな備忘録として

git logでコミットハッシュだけほしい

追記

以下、読まなくていいです

f:id:otiai10:20160615071933p:plain

% git log --pretty=oneline
5df2e90cfca356707f58de15b0c45ed7ba2446bb いろいろあたらしいかんじに調整
f7caec1f173889c76fc9bc83eed350d930a1ec41 chomexはつねにmockしない
2db4ecf41caefb102982ba88e01ba7b608d17aab Mockは分ける
...

となってコミットメッセージも得られるので、awkつかえば

% git log --pretty=oneline | awk '{print $1}'
5df2e90cfca356707f58de15b0c45ed7ba2446bb
f7caec1f173889c76fc9bc83eed350d930a1ec41
2db4ecf41caefb102982ba88e01ba7b608d17aab
...

が得られる

DRY

Androidエミューレータがスプラッシュ画面からいっこうに進まない

問題

Androidエミューレータがスプラッシュ画面を表示したままいっこうにアプリのビューを表示しない。さっきまで元気に動いていたのに←重要

調査

  • それっぽいものがみつからない
  • 質問してみた

git管理下じゃないディレクトリになんかキャッシュファイル的なのが残ってるとかあるんですかね・・・

んーそうかも

解決

AVDマネージャからアプリのDiskを綺麗に?した

f:id:otiai10:20160606190409p:plain

f:id:otiai10:20160606190428p:plain

f:id:otiai10:20160606190459p:plain

f:id:otiai10:20160606190605p:plain

雑感

  • Android、なんかあったときの原因の切り分けがすげーむずい
    • Java自体とかAndroidStudioがアグレッシブにアップデートしてくるし
    • バイスもいろいろだし
  • マヂムリ... がんばろ...

DRYな備忘録として

Androidエミュレータが起動しない: Internal error: initial hax sync failed

問題

エミュレータが起動しない。さっきまで動いていたのに。←重要

f:id:otiai10:20160603221831p:plain

エラー全文

/Users/otiai10/Library/Android/sdk/tools/emulator -avd ReactNativeTest
emulator: WARNING: VM heap size set below hardware specified minimum of 256MB
emulator: WARNING: Setting VM heap size to 512MB
Hax is enabled
Hax ram_size 0x80000000
HAX is working and emulator runs in fast virt mode.
console on port 5554, ADB on port 5555
Failed to sync vcpu reg
Failed to sync vcpu reg
emulator: ERROR: Unfortunately, there's an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn't allow multiple hypervisors to co-exist.  It is being actively worked on; you can find out more about the issue at http://b.android.com/197915 (Android) and https://www.virtualbox.org/ticket/14294 (VirtualBox)
Failed to sync vcpu reg
Internal error: initial hax sync failed

原因

エラーメッセージをちゃんと読んでなかった

emulator: ERROR: Unfortunately, there's an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn't allow multiple hypervisors to co-exist. It is being actively worked on; you can find out more about the issue at http://b.android.com/197915 (Android) and https://www.virtualbox.org/ticket/14294 (VirtualBox)

VirtualBoxAndroidエミュレータは今んとこ同時に動かせないっぽい?

解決

VirtualBox止めた

DRY