Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@yamaya
yamaya / quickrun-config-plantuml.vim
Last active August 29, 2015 13:57
plantuml実行してでき上がったpngをPreview.appで開く
let g:quickrun_config['plantuml'] = {
\ 'command': 'plantuml'
\, 'exec': ['%c %s', 'open %s:p:r.png']
\, 'outputter': 'null'
\}
#import <Foundation/Foundation.h>
@interface UserDefaults : NSObject
@end
@implementation UserDefaults : NSObject
- (id)objectForKeyedSubscript:(id)key {
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
}
@yamaya
yamaya / autolayout-10things.md
Last active December 26, 2015 09:49
[10 Things You Need To Know About Cocoa Autolayout](http://oleb.net/blog/2013/03/things-you-need-to-know-about-cocoa-autolayout/) の意訳。

10 Things You Need To Know About Cocoa Autolayout の意訳。

Autolayoutで考えるべき10個の事柄

  1. ざっくりいうと、次元ごとに2つの制約がある

各次元(垂直方向と水平方向)で、ビューの位置とサイズは、3つの値によって定義される: Leading Space , Size , Trailing Space である。 Leading SpaceTrailing Space は、親・兄弟ビューとの関係から定義する。 一般的に、これら3つの値のうち2つのレイアウトの制約がきまれば、残り1つは算出できるものである。逆にいうと、明確なレイアウトのためには各次元毎に少なくとも2つの制約を必要とする。

  1. 固有(Intrinsic)サイズを理解する
@yamaya
yamaya / autocmd.vim
Last active December 25, 2015 21:19
MacBookでMacVimしていると手のひらがTrack Padに触れてウザイのをなんとかする。要 KeyRemap4MacBook
" MacVimの起動時、アプリケーション切り替え時にKeyRemap4MacBookコマンドラインを実行してポインティング・デバイスを有効・無効にする
let g:keyremap4macbook_cmd = '/Applications/KeyRemap4MacBook.app/Contents/Applications/KeyRemap4MacBook_cli.app/Contents/MacOS/KeyRemap4MacBook_cli'
let g:keyremap4macbook_pointing_device_ignoring_cmd = g:keyremap4macbook_cmd . ' set notsave.private.pointing_device_ignoring '
augroup VimrcEx
autocmd!
" ポインティング・デバイスの有効・無効
autocmd FocusGained,VimEnter *
\ let out = system(g:keyremap4macbook_pointing_device_ignoring_cmd . '1')
\| if out != '' | echoerr out | endif
@yamaya
yamaya / after_ftplugin_objc.vim
Last active December 11, 2015 16:58
VimからXcodeでActiveなtargetをRunする
function! <SID>XcodeRunCurrentTarget()
let l:apple_script = 'tell application "Xcode"'
\. "\n". ' activate'
\. "\n". ' tell application "System Events"'
\. "\n". ' key code 15 using {command down}'
\. "\n". ' end tell'
\. "\n". 'end tell'
call system(printf("osascript -e '%s'", l:apple_script))
endfunction
nnoremap <buffer> <F5> :call <SID>XcodeRunCurrentTarget()<CR>
@yamaya
yamaya / clang-options
Last active December 11, 2015 02:59
iOS SDKをclangでcode-completionする場合に必要な最小設定 with iPhoneSimulator
-arch x86_64
-fmacro-backtrace-limit=0
-std=gnu99
-fblocks
-fobjc-arc
-fmodules
-mios-simulator-version-min=8.0
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
-D DEBUG
-I Pods/Headers
@yamaya
yamaya / private.xml
Last active December 10, 2015 17:18
KeyRemap4MacBookのprivate.xml
<?xml version="1.0"?>
<root>
<deviceproductdef>
<productname>KENSINGTON_USB_PS2_EXPERT_MOUSE</productname>
<productid>0x1015</productid>
</deviceproductdef>
<deviceproductdef>
<!-- MacBook Pro 15-inch Late 2008 -->
<productname>APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0238</productname>
<productid>0x0238</productid>
@yamaya
yamaya / gist:4333810
Created December 19, 2012 02:13
Xcode Organaizer からダウンロードされているプロビジョニングプロファイルを削除する方法
$ rm -rf ~/Library/MobileDevice/Provisiong\ Profile
# KeychainからProvisiong Profileに対応する証明書を削除する
$ defaults delete com.apple.dt.Xcode DTDKPortalCache
@yamaya
yamaya / xcode-clang-vers
Last active April 2, 2025 00:16
Xcode clang version record
# Xcode 4.3.3
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
# Xcode 4.3.2
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
@yamaya
yamaya / gist:2853897
Last active October 5, 2015 18:29
Run iPhone Simulator with target .app from the command line
#!/bin/bash
# NOTE: $1 must be absolute path.
open -a `xcode-select -print-path`/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app --args -SimulateApplication $1
osascript 2>/dev/null <<EOF
tell application "System Events"
tell process "iPhone Simulator" to keystroke "2" using command down
end
EOF