Skip to content

Instantly share code, notes, and snippets.

View sakuemon's full-sized avatar

Tsuyoshi MIYAMOTO sakuemon

View GitHub Profile
@sakuemon
sakuemon / gist:3897967
Created October 16, 2012 08:06
rails3 logging filter
# coding: utf-8
module Filters
class TraceLogFilter
def initialize(logger = nil)
unless logger
@logger = Rails.logger
else
@logger = logger
end
@sakuemon
sakuemon / gist:3911856
Created October 18, 2012 13:37
rails3 logger
# coding: utf-8
module Loggers
if Settings.logger.trace.nil? or Settings.logger.trace.output.nil?
TRACE_LOGGER = ActiveSupport::TaggedLogging.new(Logger.new(STDERR))
else
TRACE_LOGGER = ActiveSupport::TaggedLogging.new(Logger.new(Settings.logger.trace.output))
end
end
@sakuemon
sakuemon / gist:3930440
Created October 22, 2012 08:51
rails3 エラー時に指定した画面を出す。
# see http://ar156.dip.jp/tiempo/publish/52
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from Exception, :with => :error_500
def error_500(exception)
logger.error "#{exception.message}"
render :file => "#{Rails.root}/public/500.html", :status => 500, :layout => false, :content_type => 'text/html'
end
@sakuemon
sakuemon / file0.xml
Created April 12, 2013 10:26
Macのsublime text2のvintageモードでinsertモードから抜けた時にimeをoffする ref: http://qiita.com/items/55b1267f18e1a9e4e26e
<?xml version="1.0"?>
<root>
<item>
<name>control+[ with ime-off</name>
<identifier>private.ctrl-L2ctrl-L+IME-OFF</identifier>
<appendix></appendix>
<autogen>__KeyToKey__ KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::JIS_EISUU</autogen>
</item>
</root>
@sakuemon
sakuemon / file0.txt
Created August 9, 2013 02:16
クラス名の文字列からインスタンスを生成 with ActiveSupport ref: http://qiita.com/sakuemon@github/items/5c34ab2aa93dafadb8ef
class_name.camelize.constantize.new
@sakuemon
sakuemon / file0.js
Created September 9, 2013 02:47
sequelizeでsqlのログを何らかのロギングモジュールで出したいとき ref: http://qiita.com/TsuyoshiMIYAMOTO/items/ba755b91789f9888f8e2
options.logging = function(args) {
logger.debug(args);
};
var sequelize = new Sequelize(db, username, password, options);
@sakuemon
sakuemon / file0.js
Created September 19, 2013 12:49
gruntでexpressを起動すると文字化けするのを解消 ref: http://qiita.com/TsuyoshiMIYAMOTO/items/f7cf071f47b7190f7b01
var child = spawn(cmd, args, opts.opts);
var stdout = [];
var stdoutLength = 0;
var stderr = [];
var stderrLength = 0;
if (child.stdout) {
child.stdout.on('data', function(buf) {
stdout.push(buf);
stdoutLength += buf.length;
});
@sakuemon
sakuemon / your-project.sublime-project
Created October 20, 2013 06:23
SublimeText2のiosアプリ用SublimeClangの設定 ref: http://qiita.com/TsuyoshiMIYAMOTO/items/e35f585b7e1ed35d0ba7
{
"settings": {
"sublimeclang_options": [
"-Wall",
"-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk",
"-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include",
"-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks",
"-arch", "arm",
"-I${project_path:your-project}/**"
]
@sakuemon
sakuemon / file0.txt
Created December 30, 2013 05:26
brewdlerの初期設定をちょっとだけ簡単にする。 ref: http://qiita.com/TsuyoshiMIYAMOTO/items/08b5f4e713f5207da400
brew tap | awk '{print "tap " $0}' >> Brewfile
brew list | awk '{print "install " $0}' >> Brewfile
git ls-files --deleted -z | xargs -0 -t git rm --ignore-unmatch