Skip to content

Instantly share code, notes, and snippets.

View oakbow's full-sized avatar
🏠
Working from home

Oakbow oakbow

🏠
Working from home
View GitHub Profile
# You need to add your domain into Capybara's whitelist.
RSpec.configure do |config|
Capybara::Webkit.configure do |c|
c.block_unknown_urls
c.allow_url("admin.lvh.me")
end
Capybara.default_selector = :css
:

自己紹介

名前

大久保英樹(@oakbow)

職業

流しのRuby/Railsプログラマ ※ 元Job-Hubの開発責任者

各技術のステータス

@oakbow
oakbow / Gemfile
Created February 3, 2015 10:32
herokuでセッションの保存先をRedisにする ref: http://qiita.com/Oakbow/items/98599da0fc62863fc1b8
gem 'redis'
gem 'redis-rails'
@oakbow
oakbow / file0.txt
Created January 28, 2015 07:59
Object.in?でArgumentErrorが発生した場合の対処(Rails3 => Rails4) ref: http://qiita.com/Oakbow/items/f1d3f2b69fd056488162
ArgumentError - wrong number of arguments (2 for 1):
@oakbow
oakbow / active_admin_cancan.rb
Last active August 29, 2015 14:14
ActiveAdminの検索条件から、has_manyとhas_oneを除外する ref: http://qiita.com/Oakbow/items/3d577468c0106ccc320b
module ActiveAdmin
module Filters
# lib/active_admin/filters/resource_extension.rb
# サイドバーの検索条件から、default_association_filters を対象外にする。
# has_manyやhas_oneがプルダウン条件になって恐ろしく重くなる現象の回避策。
module ResourceExtension
# Returns a default set of filters for the associations
def default_association_filters
@oakbow
oakbow / tipsy.css.erb
Last active August 29, 2015 14:02
use conveniently jQuery tooltip plugin tipsy ref: http://qiita.com/Oakbow/items/a1af86a4cf098aa75ecd
# change images file path for Rails applications.
.tipsy-arrow { position: absolute; background: url('<%= asset_path 'tipsy.gif' %>') no-repeat top left; width: 9px; height: 5px; }
@oakbow
oakbow / Gemfile
Last active August 29, 2015 13:58
heroku+CloudFrontで静的ファイルを配信する(Webフォント対応) ref: http://qiita.com/Oakbow/items/9ceb93d47d918aeafe3a
gem 'rack-cors', require: 'rack/cors'
@oakbow
oakbow / application_controller.rb
Last active August 29, 2015 13:57
exchange character encoding from UTF-8 to SJIS, for IE or Excel users. ref: http://qiita.com/Oakbow/items/a62d1de9c62ee8fa2eb2
# IEのダウンロードファイル名の文字化け対応
def filename_for_download(filename)
if request.env['HTTP_USER_AGENT'] =~ %r{MSIE} && request.env['HTTP_ACCEPT_LANGUAGE'] =~ /^ja/
filename = Utf8ToWin31jCodeConverter.convert_to_windows31j(filename)
end
filename
end
@oakbow
oakbow / Array:indexOf_for_IE8.coffee
Last active December 28, 2015 04:19
be able to use 'Array:indexOf' on IE8.
unless "indexOf" of Array::
Array::indexOf = (find, i) ->
i = 0 if i is `undefined`
i += @length if i < 0
i = 0 if i < 0
n = @length
while i < n
return i if i of this and this[i] is find
i++
@oakbow
oakbow / shorten_UTF8_to_byte_you_want.rb
Last active December 28, 2015 04:19
shorten UTF-8 character string to fit bytes which length you want. 
original_file_extension = File.extname(@original_filename)
#@original_filename = File.basename(@original_filename)
@original_filename.force_encoding("ascii-8bit")
pp "ascii"
pp @original_filename
@original_filename = @original_filename[0, (configatron.uploadfilename.bytesize - original_file_extension.bytesize)]