Skip to content

Instantly share code, notes, and snippets.

@takuya-i
takuya-i / gist:3117040
Created July 15, 2012 14:02
Android strings.xml convert to csv fromat
#!/usr/local/bin/ruby
#
# Need "nokogiri" for xml parse
#
require "nokogiri"
file = File.open(ARGV[0])
xml_doc = Nokogiri::XML(file)
array = xml_doc.xpath("//string")
@takuya-i
takuya-i / gist:3136619
Created July 18, 2012 14:46
[android] force set forcus to View object
/**
* android snippet
* Force set forcus to View object.Somtimes this is not effected
*
* @param v View instance object of set forcus
*/
public void foceSetFocus(View v) {
v.setFocusable(true);
v.setFocusableInTouchMode(true);
if (!v.requestFocus()) {
@takuya-i
takuya-i / gist:3446726
Created August 24, 2012 06:42
Rmagick install brew → gem
# export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/lib/pkgconfig:$PKG_CONFIG_PATH
# C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/
# gem install rmagick
@takuya-i
takuya-i / gist:3662521
Created September 7, 2012 01:54
rails with Rmagick createing thumbnail image
#Create squre thumbnail from bytedata by RMagick
def thumbnail(size=128)
image = Magick::Image.from_blob(self.binary_contents).shift
image_width = image.columns
image_height = image.rows
if image_width > image_height
crap_size = image_width -image_height # 正方形にするため、カットするpixcel数
thumbnail = image.crop(crap_size /2, 0, image_width - crap_size , image_height).resize(size, size)
@takuya-i
takuya-i / gist:4192883
Created December 3, 2012 05:17
[android] Log utility
package jp.co.so_da.android.extension;
import android.util.Log;
/**
* ファイル名 + 行番号付きで、Log出力を行うUtility クラス<br>
* <h4>使い方</h4>
* アプリ起動時に、Logger{@link #tag}とLogger{@link #logDebug}に必要な値を設定して下さい。
* @author Takuya Inoue
*
*/
@takuya-i
takuya-i / Present Local ime
Created February 7, 2013 17:27
Get local Time String
Time.now.getlocal.to_s => "2013-02-08 02:25:46 +0900"
@takuya-i
takuya-i / xxxx-Prefix.pch
Created February 14, 2013 15:21
iphone NSLog macro
#ifndef DEBUG
#define NSLog( m, args... )
#endif
@takuya-i
takuya-i / check airplane mode
Last active December 14, 2015 04:39
Check airplane mode at android os
public satic boolean isAirPlaneMode() {
Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1
}
@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
@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