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
ITEMS_BASIC = [ | |
[:R, 82], | |
[:SR, 15], | |
[:SSR, 3], | |
] | |
ITEMS_SPECIAL = [ | |
[:SR, 97], | |
[:SSR, 3], | |
] |
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
require 'active_model' | |
class ActiveModel::Errors | |
module WithSymbol | |
attr_accessor :symbol_value | |
end | |
def add_with_symbol(attribute, message = :invalid, options = {}) | |
add_without_symbol(attribute, message, options).tap do |messages| |
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
#!/usr/bin/env ruby | |
require "json" | |
require "open-uri" | |
class LoveLiveQuiz | |
API_URL = 'https://lovelive-quiz-api.herokuapp.com/quiz' | |
def initialize | |
fetch |
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
require 'active_model' | |
class ActiveModel::Errors | |
module HiddenEntity | |
attr_accessor :_entity | |
end | |
def generate_message_with_format(attribute, type = :invalid, options = {}) | |
message = generate_message_without_format attribute, type, options |
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
Array::forEachAsync = (each, context) -> | |
copy = @slice() | |
index = -1 | |
do next = -> | |
return if copy.length == 0 | |
process.nextTick -> | |
item = copy.shift() | |
index += 1 |
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 Parent | |
enumerize :nyan, in: [:a, :b, :c], scope: true | |
end | |
class Child1 < Parent | |
enumerize :nyan, in: [:a], default: :a | |
end | |
class Child2 < Parent | |
enumerize :nyan, in: [:a, :b], default: :b |
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
#!/usr/bin/env node | |
var fs = require('fs') | |
, http_proxy = require('http-proxy') | |
, http = require('http') | |
, https = require('https') | |
, cert_file_path = '/path/to/server.crt' | |
, key_file_path = '/path/to/server.key'; | |
var proxy = http_proxy.createProxyServer(); |
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
#SOURCE https://gist.github.com/tatat/9526513 | |
ja: | |
devise: | |
confirmations: | |
confirmed: 'アカウントを登録しました。' | |
# confirmed: 'Your account was successfully confirmed. You are now signed in.' | |
send_instructions: '登録方法を数分以内にメールでご連絡します。' | |
# send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' | |
send_paranoid_instructions: 'もしあなたのEメールアドレスが見つかった場合、本人確認についてのメールが数分以内に送られます。' |
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 ApplicationHelper | |
# 私がやるとこうなる(ごたごたしてる) | |
def without_whitespaces(options = {}) | |
captured = capture &Proc.new | |
captured = captured.gsub(%r{\A\s+|\s+\Z}, '').gsub(%r{(>)\s+(<)}, '\1\2') | |
captured = captured.gsub(%r{(>)\s*(.*?)\s*(<)}, '\1\2\3') if options[:trim] | |
captured.html_safe | |
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
class Nyan | |
def behave_method(target, source) | |
(class << self; self end).module_exec do | |
alias_method "#{target}_original", target unless method_defined? "#{target}_original" | |
alias_method "#{source}_original", source unless method_defined? "#{source}_original" | |
alias_method target, "#{source}_original" | |
end | |
end | |
def with_behaving_method(a, b) |