Skip to content

Instantly share code, notes, and snippets.

View tkoki's full-sized avatar

Takashi Koki tkoki

  • Tokyo, Japan
View GitHub Profile
@tkoki
tkoki / gist:a0df02072d99768e4110
Created June 23, 2015 01:43
javaクラスのメソッドシグネチャの取得方法
javap -s -p java.io.File
@tkoki
tkoki / gist:46133a9278c42ec0f67d
Created June 12, 2015 02:50
javahによるJNIヘッダ生成
javah -classpath bin/classes -d jni jp.co.petworks.filesystemtest.NDKBridge
@tkoki
tkoki / gist:4bc9ec288d5191696459
Created April 8, 2015 08:41
GCDでの遅延実行パターン
double delayInSeconds = 1.0; // 遅延時間
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// ここに遅延実行したい処理を記述。
});
@tkoki
tkoki / dump_mobileprovision
Last active December 29, 2015 00:55
mobileprovisionsの中身をplist形式で出力する
security cms -D -i pp.mobileprovision > tmp.plist
@tkoki
tkoki / gist:783cd534afb0c24daadb
Created October 28, 2014 05:53
Objective-Cをコマンドラインでさくっとコンパイル
#import <Foundation/Foundation.h>
int main(int argc, char **argv) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/*
Objective-Cのコード。
*/
[pool drain];
return 0;
}
@tkoki
tkoki / gist:6880798
Created October 8, 2013 07:11
起動中の言語を取得する
NSArray *languages = [NSLocale preferredLanguages];
if ([[languages objectAtIndex:0] isEqualToString:@"ja"]) {
// 日本語での処理
} else {
// それ以外での処理
}
@tkoki
tkoki / create_cf_signed_url.py
Last active December 22, 2015 19:09
botoを使ってCloudFrontのsigned URLを発行する。
import boto, time
'''
@param[in] aws_access_key_id AWSアカウントのアクセスキーID
@param[in] aws_secret_access_key AWSアカウントのシークレットキー
@param[in] keypair_id CloudFrontキーペアID
@param[in] keypair_file CloudFrontキーペアファイル
@param[in] cf_distribution_id CloudFrontディストリビューションID
@param[in] s3_object_name 公開したいS3オブジェクトのキー
@param[in] expires_in_seconds CloudFrontで公開する期間を秒で指定
@tkoki
tkoki / gist:6267745
Last active December 21, 2015 06:59
iPhone simulator内からホストコンピュータ上のopenコマンドを叩く。この例ではiPhone simulator内のアプリの/tmpディレクトリ内にあるpngファイルをホストコンピュータ上のpngに関連付けられたアプリ(デフォルトではPreview.app)で開く。画像を生成するアプリのテストに重宝する。
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/open" arguments:[NSArray arrayWithObject:[NSString stringWithFormat:@"/tmp/%@.png", filename]]];
@tkoki
tkoki / gist:6153003
Created August 5, 2013 02:09
UIViewのちょいアニメ
[UIView animateWithDuration:0.5 animations:^{
self.imageView.alpha = 0.0;
}];
@tkoki
tkoki / SMB over SSH
Created June 12, 2013 05:57
Mac OS X 10.5.x 〜 Mac OS X 10.6.xでsshトンネル経由でLAN内のSMBサーバーに接続する方法。10.8.xではloopbackアドレスへの接続が許可されてるので、この例の様に仮想インタフェースを作る必要は無い。10.7.xは未確認。
1. 仮想インタフェースの作成
% sudo ifconfig lo0 alias 127.0.0.2
Password: <--- パスワードを入力。
2. トンネル接続
% ssh -N <username>@<ssh server> -L 127.0.0.2:8139:<SMB server>:139
3. Finderでマウント