This file contains hidden or 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_support/all' | |
| require 'active_attr' | |
| class Itemchanger | |
| include ActiveAttr::Model | |
| extend ActiveModel::Callbacks | |
| define_model_callbacks :save |
This file contains hidden or 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
| #coding: utf-8 | |
| module Kansuuji | |
| NUMBERS = %w(〇 一 二 三 四 五 六 七 八 九) | |
| RANKS = [''] + %w(十 百 千) | |
| def self.kansuuji(int) | |
| raise RuntimeError, "can calc between 1 and 9999" if int < 1 || int > 9999 # FIXME | |
| return NUMBERS[1] if int == 1 |
This file contains hidden or 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 PadrinoFluentLogger | |
| extend Forwardable | |
| attr_accessor :level | |
| # options takes below: | |
| # :logger => custom Fluent::Logger::FluentLogger object | |
| # :tag_prefix => set your tag_prefix to FluentLogger | |
| def initialize(options = {}) | |
| env = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym | |
| config = Padrino::Logger::Config[env] |
This file contains hidden or 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 'google_drive' | |
| require 'oauth2' | |
| require 'json' | |
| require 'pry' | |
| # create in https://code.google.com/apis/console/ | |
| @client_id = "" | |
| @client_secret = "" | |
| @redirect_uri = "urn:ietf:wg:oauth:2.0:oob" |
This file contains hidden or 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 | |
| # coding: utf-8 | |
| require 'google_drive' | |
| require 'highline/import' | |
| require 'active_support/core_ext' | |
| require 'pry' | |
| def ask_authentication |
This file contains hidden or 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
| # test target sample class... | |
| class D | |
| def foo(num) | |
| %w[one two three][num - 1] | |
| end | |
| end | |
| def given(*args) | |
| subject.call(*args) | |
| end |
This file contains hidden or 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
| describe B do | |
| describe "#foo" do | |
| [ | |
| #[ argument, expect] | |
| [ 1, 'one'], | |
| [ 2, 'two'], | |
| [ 3, 'three'], | |
| ].each do |arg, expect| |
This file contains hidden or 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 "net/https" | |
| class Pushover | |
| def initialize(api_token, user_key) | |
| @api_token = api_token | |
| @user_key = user_key | |
| end | |
| def message(_message) |
This file contains hidden or 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
| # NOTE: memoized in @current_user | |
| # (1) | |
| def current_user | |
| @current_user ||= User.find(session[:user_id]) if session[:user_id] | |
| end | |
| # (6) | |
| def current_user | |
| @current_user ||= User.find_by_id(session[:user_id]) |
This file contains hidden or 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
| # 生成コードイメージ | |
| # 仮想コード。 | |
| # プロトコル(てきとう) | |
| RPC.remote :userinfo do | |
| method :get | |
| route: "/userinfo" |