Skip to content

Instantly share code, notes, and snippets.

@takuya-i
takuya-i / file0.txt
Created July 3, 2015 06:54
GPUImageVideoCameraにセットされたsessionのサイズの取得(Swift版) ref: http://qiita.com/takuya-i/items/84dd0c8d202eff4104a8
//VideoCameraはGPUIMageVideoCameraのインスタンス
let output = videoCamera.captureSession.outputs[self.videoCamera.captureSession.outputs.endIndex - 1] as! AVCaptureVideoDataOutput
let setting:NSDictionary = output.videoSettings
let width = (setting["Width"] as! NSNumber).longValue
let height = (setting["Height"] as! NSNumber).longValue
@takuya-i
takuya-i / file0.txt
Created June 30, 2015 13:24
AndroidでrailsのDateTimeをパースし、ローカルロケール時刻テキストに変換 ref: http://qiita.com/takuya-i/items/c48fac398b6715596a8c
public final static String TIME_FORMAT = "yy/MM/dd HH:mm:ss";
//UTC標準時刻をローカル時間のテキストに変換する。
public String toLocalTime(String utcTime) {
try {
Time t = new Time();
t.parse3339(utcTime);
long msec = t.normalize(false);
Date d = new Date( msec );
@takuya-i
takuya-i / file0.txt
Last active January 26, 2016 16:44
Unicorn 起動コマンドメモ ref: http://qiita.com/takuya-i/items/8582cc0af7ed9930dfbd
kill -KILL `cat tmp/unicorn.pid`
@takuya-i
takuya-i / file0.txt
Last active August 29, 2015 14:23
Rails + Mysql データベース作成 ref: http://qiita.com/takuya-i/items/3d6c2d81b31d0b58a3a0
$mysql>create database [データベース名] character set utf8;
$mysql>create user 'ユーザ名'@'localhost' identified by 'パスワード';
$mysql>grant all privileges on [データベース名].* to 'ユーザ名'@'localhost';
@takuya-i
takuya-i / file0.txt
Created June 17, 2015 01:03
Post時にInternal Server Error with Maximum file multiparts in content reachedとエラーが返る ref: http://qiita.com/takuya-i/items/30c056004db73533c1cc
Rack::Utils.multipart_part_limit = 0
@takuya-i
takuya-i / FileHelper.java
Last active August 29, 2015 14:17
android File helper
import android.graphics.Bitmap;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@takuya-i
takuya-i / gist:4012bdd235eed282eaaf
Created September 8, 2014 09:20
Rails4のtimestampをUTCのままNSDateに変換する
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
//"2014-09-05T03:37:21.000Z"
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.000Z";
NSDate * lastDate = [dateFormatter dateFromString:@"2000-12-31T12:12:12.000Z"];
@takuya-i
takuya-i / gist:9594731
Created March 17, 2014 06:17
Objective-C 日本語ロケールかどうかの判別マクロ
#define isJapanes() [[[NSLocale preferredLanguages] objectAtIndex:0]isEqualToString:@"ja"]
@takuya-i
takuya-i / gist:5214371
Created March 21, 2013 16:23
iOS Prefix header debugging macro
//Logging macro
//if release mode, undfeine this macro
#ifdef DEBUG
#define NSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define NSLog(fmt, ...)
#endif
//assertion macro
@takuya-i
takuya-i / gist:5031075
Last active December 14, 2015 04:49
AU光の契約で配られているルータが、ローカルLANからグローバルIP指定し、サーバアクセスすると、 接続できないんで、それを判別し、ssgfsで自動マウントするスクリプト。(OSX 専用 ) サーバあるんだったら、DNS立てろというのはなしはなしで.....
#!/bin/sh
#
# check Home Local LAN or other place, wifi or company office
# if access from home LAN, out Home LAN IP address, otherwise return global IP addrress
# Author Takuya Inoue
#GROBAL IP address
IP_ADDR=xxx.xxx.xxx.xxx
# network is 192.168.0.0/24