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
'2021-07-08 06:56:00 JST'.to_datetime.utc | |
'2021-07-07 21:56:00'.to_datetime.in_time_zone('Tokyo') |
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
def main | |
@class_files = Dir.glob("app/loyalties/**/*.rb") | |
@rspec_files = Dir.glob("spec/loyalties/**/*.rb") | |
@class_files.each do |class_file| | |
rspec_file = class_file.gsub(/\Aapp/, 'spec').gsub(/loyalty.rb\z/, 'loyalty_spec.rb') | |
next if @rspec_files.include?(rspec_file) | |
next if class_file == 'app/loyalties/application_loyalty.rb' | |
puts "#{class_file} のテストが無いよ #{rspec_file}だよ" | |
end | |
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
def main(raise_class) | |
raise raise_class, 'try rescue!' | |
rescue Mysql2::Error | |
puts "catch #{$!}" | |
rescue | |
puts "Through #{$!}" | |
end | |
main(Mysql2::Error) | |
main(Mysql2::Error::TimeoutError) |
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
# frozen_string_literal: true | |
@media_website_id = 2_136 | |
def before_labels | |
registered_labels = [] | |
MediaWebsite.eager_load(media_website_labels: :label) | |
.where(id: @media_website_id).first | |
.media_website_labels.each do |media_website_label| | |
label = media_website_label.label |
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
# frozen_string_literal: true | |
def build_total(reports) | |
[reports] | |
end | |
def original | |
campaigns = Campaign.where(id: 1..3) | |
reports = MediaDailyReport.limit(3).to_a |
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
db = Sequel.mysql2(ApplicationRecord.connection_config) | |
# media_daily_referrer_campaign_report | |
Benchmark.bm do |x| | |
# 1. sequel | |
# 1-1. idのみ | |
x.report('sequel(id) ') do | |
db.fetch('select id from media_daily_referrer_campaign_reports limit 50000'){|r| r[:id] } | |
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
#!/bin/sh | |
private_key_path=$1 | |
insert_file_path=$2 | |
environment_path=$3 | |
if [ ${environment_path} = '/home/ec2-user/circuit-x-batch-dev' ]; then | |
echo '[[[ 開発環境に向いています ]]]' | |
batch_server_ip_address=3.112.22.21 | |
else |
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 SlackHelper | |
extend ActiveSupport::Concern | |
# メッセージを通知します | |
def self.send_to_slack(message, channel:, mentions: nil, icon: ':fukurouchan:') | |
mentions_line = SlackHelper.create_mentions_line(mentions) | |
SlackHelper.send_core(mentions_line + message, channel, icon_emoji: icon) | |
end | |
delegate :send_to_slack, to: SlackHelper |
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 'uri' | |
require 'pry' | |
require 'csv' | |
require 'time' | |
REPRODUCE_HOST = 'localhost:4567' | |
PROTOCOL = 'http' | |
CURL_COMMAND = 'curl' | |
def main |
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
php -r "readfile('https://getcomposer.org/installer');" | php | |
php composer.phar require guzzlehttp/guzzle | |
php composer.phar require bugsnag/bugsnag | |
``` | |
require 'vendor/autoload.php'; | |
$bugsnag = Bugsnag\Client::make($_ENV['BUGSNAG_API_KEY']); | |
$bugsnag->setReleaseStage('development'); | |
$bugsnag->notifyException(new RuntimeException("Test error"));" | |
``` |
NewerOlder