This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 「英大文字」「英小文字」「数字」「記号」のうち、単一の1種類のみで構成されることなく、2種類以上が使われていること | |
# http://e-words.jp/p/r-ascii.html | |
class User | |
PASSWORD_FORMAT = %r{^ | |
(?![0-9])[\x20-\x7e]*?[0-9][\x20-\x7e]*?| | |
(?![a-z])[\x20-\x7e]*?[a-z][\x20-\x7e]*?| | |
(?![A-Z])[\x20-\x7e]*?[A-Z][\x20-\x7e]*?| | |
(?![!-\/:-@\[-`\{-~])[\x20-\x7e]*?[!-\/:-@\[-`\{-~][\x20-\x7e]*? | |
$}x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails _2.3.9_ test_2_3_9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def half_spaceize | |
self.gsub(/\s| /, ' ') | |
end | |
def half_spaceize! | |
self.gsub!(/\s| /, ' ') | |
end | |
# '-ー‐-' => '-' | |
def hyphenize | |
self.gsub(/\xE3\x83\xBC|\xE2\x80\x90|\x2D/, "\xEF\xBC\x8D") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationController.helpers.number_with_delimiter('10000') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module UrlHelper | |
def url_for_with_jpmobile(options = {}) | |
if !options.nil? && options.is_a?(Hash) | |
if request && (mobile = request.mobile) && !(mobile.instance_of?(Jpmobile::Mobile::Vodafone)||mobile.instance_of?(Jpmobile::Mobile::Softbank)) | |
options = options.inject({}){ |result, option| | |
result[option[0]] = convert_multibyte_with_mobile(option[1]) | |
result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def flatten_with_hash | |
inject([]){ |r, h| | |
if h.is_a?(Hash) | |
r << h.keys.flatten_with_hash | |
r << h.values.flatten_with_hash | |
else | |
r << h | |
end | |
r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def to_underscore_key | |
self.class.new.tap do |array| | |
self.each { |value| | |
case value | |
when Hash, Array | |
array << value.to_underscore_key | |
else | |
array << value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ポートフォワード | |
$ ssh -L 10000:remote.host.com:22 gate.com -p 11122 | |
# clone | |
$ git clone git+ssh://git@localhost:10000/repo/project.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# config/initializers配下やlib配下においてinclude | |
# | |
if defined?(Jpmobile) | |
class ActionDispatch::Request | |
def reset_session_with_jpmobile | |
reset_session_without_jpmobile | |
if self.mobile? | |
self.session_options[:id] = ActiveSupport::SecureRandom.hex(16) | |
if Rails.application.config.session_store == ActiveRecord::SessionStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ cd config/initializers && wget https://gist.github.com/raw/818098/8bb0db2303e86629166cecca8c57699690de58c9/deprecated_active_view.rb | |
# $ vi ~/.subversion/config | |
# [miscellany] | |
# global-ignores = deprecated_active_view.rb | |
# | |
ActionView.class_eval do | |
remove_const :SafeBuffer | |
SafeBuffer = ActiveSupport::SafeBuffer | |
end |