Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hidsystem/event_status_driver.h>
static int hid_mousex, hid_mousey;
static void hidCallback(void* context, IOReturn result, void* sender, IOHIDValueRef valueRef)
{
IOHIDElementRef element = IOHIDValueGetElement(valueRef);
if (mouse_capture > 0 && IOHIDElementGetUsagePage(element) == kHIDPage_GenericDesktop) {
int value = (int)IOHIDValueGetIntegerValue(valueRef);
@yamaya
yamaya / shuttle.swift
Created April 27, 2017 13:50 — forked from jeamland/shuttle.swift
My stunning adventures in Swift
import Foundation
import IOKit
import IOKit.hid
import Quartz
let ioman = IOHIDManagerCreate(kCFAllocatorDefault,
IOOptionBits(kIOHIDOptionsTypeNone))
let runloop : CFRunLoop = CFRunLoopGetCurrent()
let devices = [
kIOHIDVendorIDKey: 0x0b33,
@yamaya
yamaya / sVimrc
Last active January 19, 2017 09:36
sVimrc
let scrollduration = 20
let blacklists = ["*://reader.livedwango.com/reader/*", "*://(mail|calendar).google.com/*", "*://www.apple.com/jp/shop/*", "*://www.jtb.co.jp/*", "*://secure.j-bus.co.jp/*", "*://twitter.com/*", "*://*.starbucks.co.jp/*", "*://www.tumblr.com/blog/*", "*://logentries.com/app/*", "*://eexpress.jp/*", "*://kcw.kddi.ne.jp/*"]
let nextmatchpattern = "((?!first)(next( page)?|older|more|>|›|»|forward|次へ| )+)"
let previousmatchpattern = "((?!last)(prev(ious)?( page)?|newer|back|«|less|<|‹|前へ| )+)"
unmapAll
map "j" scrollPageDown
map "k" scrollPageUp
map "ctrl+f" scrollFullPageDown
map "ctrl+b" scrollFullPageUp
@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 / 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