Skip to content

Instantly share code, notes, and snippets.

@hirokim
hirokim / git command
Last active August 29, 2015 14:07
忘れがちなGitコマンド
設定確認
$ git config -l
リモート登録
$ git remote add origin REMOTE_URL
リモート変更
$ git remote set-url origin git@git.example.com:foo/bar.git
リモートのタグの削除
@hirokim
hirokim / gist:41b08063e09f8db829b2
Created October 31, 2014 07:41
使われてないリソース検索(Android)
java -jar AndroidUnusedResources1.6.2.jar
@hirokim
hirokim / LineBrush.m
Last active August 29, 2015 14:11
線を描画するときにブラシ効果
- (void)drawLine:(UIBezierPath*)path
{
// 非表示の描画領域を生成
UIGraphicsBeginImageContextWithOptions(self.canvas.frame.size, NO, 0.0);
// 描画領域に、前回までに描画した画像を、描画
[lastDrawImage drawAtPoint:CGPointZero];
// ブラシを指定して色をセット
UIColor *brushPattern = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"mask"]];
@hirokim
hirokim / TrimmingSquareView.h
Created December 15, 2014 01:46
切り取り範囲の矩形を選択するクラス
#import <UIKit/UIKit.h>
@interface TrimmingSquareView : UIView
@property (nonatomic, readonly) CGRect trimmngRect;
- (void)resetPosition;
@end
@hirokim
hirokim / remakeImageForOrientation.m
Created December 18, 2014 08:55
UIImageの向きを統一するために作り直す処理
// 度数をラジアンに変換するマクロ
static inline double radians (double degrees) {return degrees * M_PI/180;}
/**
* UIImageの向きを統一するために作り直す
*
*/
+ (UIImage*)remakeImageForOrientation:(UIImage*)originalImage {
// 変換が不要なものはそのままリターン
@hirokim
hirokim / splitDataWithData.m
Created December 18, 2014 08:56
NSDataを指定サイズに分割する
/**
* NSDataを指定サイズに分割する
*
*/
+ (NSArray *)splitDataWithData:(NSData *)data splitSize:(int)size
{
NSRange dataRange;
NSInteger dataSize = data.length;
NSInteger dataSplitCount = dataSize/size;
@hirokim
hirokim / resizeAspectFitWithSize.m
Created December 18, 2014 08:59
アスペクト比を保ってUIImageをリサイズ
/**
* アスペクト比を保ってUIImageをリサイズ
*
*/
+ (UIImage *)resizeAspectFitWithSize:(UIImage *)srcImg size:(CGSize)size
{
CGFloat widthRatio = size.width / srcImg.size.width;
CGFloat heightRatio = size.height / srcImg.size.height;
CGFloat ratio = (widthRatio < heightRatio) ? widthRatio : heightRatio;
@hirokim
hirokim / TakeBracketCapture.m
Created December 24, 2014 06:31
ブラケット撮影
NSArray *settings = @[
[AVCaptureManualExposureBracketedStillImageSettings manualExposureSettingsWithExposureDuration:CMTimeMake(1, 100) ISO:100.0],
[AVCaptureManualExposureBracketedStillImageSettings manualExposureSettingsWithExposureDuration:CMTimeMake(1, 200) ISO:400.0],
[AVCaptureManualExposureBracketedStillImageSettings manualExposureSettingsWithExposureDuration:CMTimeMake(1, 300) ISO:800.0]
];
[self.stillImageOutput
captureStillImageBracketAsynchronouslyFromConnection:videoConnection
withSettingsArray:settings
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, AVCaptureBracketedStillImageSettings *stillImageSettings, NSError *error) {
@hirokim
hirokim / AVCaptureDeviceFormat of iPhone6Plus
Created December 24, 2014 09:39
AVCaptureDeviceFormat of iPhone6Plus
<AVCaptureDeviceFormat: 0x174005b30 'vide'/'420v' 192x 144, { 2- 30 fps}, HRSI:3264x2448, fov:58.040, max zoom:153.00 (upscales @17.00), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000>
<AVCaptureDeviceFormat: 0x174005b40 'vide'/'420f' 192x 144, { 2- 30 fps}, HRSI:3264x2448, fov:58.040, max zoom:153.00 (upscales @17.00), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000>
<AVCaptureDeviceFormat: 0x174005b50 'vide'/'420v' 352x 288, { 2- 30 fps}, HRSI:2992x2448, fov:53.203, max zoom:153.00 (upscales @8.50), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000>
<AVCaptureDeviceFormat: 0x174005b60 'vide'/'420f' 352x 288, { 2- 30 fps}, HRSI:2992x2448, fov:53.203, max zoom:153.00 (upscales @8.50), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000>
<AVCaptureDeviceFormat: 0x174005b70 'vide'/'420v' 480x 360, { 2- 30 fps}, HRSI:3264x2448, fov:58.040, max zoom:153.00 (upscales @6.80), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000>
<AVCaptureDeviceFormat: 0x174005b80 'vide'/'420f' 480x 360, { 2- 30 fps}, HR
@hirokim
hirokim / PieChartView.m
Created February 25, 2015 01:36
iOSで円グラフ描画
/**
* 円グラフ描画
*
*/
- (void)drawGradCircle:(CGRect)dirtyRect context:(CGContextRef)context {
[[UIColor whiteColor] set];
// 画面サイズの小さい方の長さ
float dim = MIN(self.bounds.size.width, self.bounds.size.height);