Skip to content

Instantly share code, notes, and snippets.

View mokoaki's full-sized avatar
💭
死にかけ

mokoaki mokoaki

💭
死にかけ
View GitHub Profile
@mokoaki
mokoaki / commit_message_example.md
Created March 1, 2022 10:53 — forked from mono0926/commit_message_example.md
[転載] gitにおけるコミットログ/メッセージ例文集100
@mokoaki
mokoaki / hage.rb
Last active September 30, 2018 08:15
ActiveSupport presense present? blank? FizzBuzz
# https://github.com/rails/rails/blob/683a0b5042262d841bfed687a4c56125364cf7a7/activesupport/lib/active_support/core_ext/object/blank.rb#L5
# https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/blank.rb
class Object
def blank?
respond_to?(:empty?) ? !!empty? : !self
end
def present?
!blank?
@mokoaki
mokoaki / thread_post_memo.rb
Last active September 5, 2018 06:52
昔しごとでスレッドを使いRestサーバに並列アクセス(どう見ても攻撃)したときのコードメモ
# require 'open-uri'
require 'thread'
# require 'openssl'
REST_API_CONNECT_URL = 'https://api.mokoaki.net/'.freeze
def faraday_connection
Faraday::Connection.new(REST_API_CONNECT_URL) do |conn|
conn.headers = {
'user_agent' => "AAAAAAAAAA",
@mokoaki
mokoaki / ruby.md
Last active January 30, 2019 04:41
Ruby べんり

Ruby べんり

RUBY_VERSION
# => "1.9.3"

とある配列の重複している要素が知りたい

重複している要素のみの配列を返す

@mokoaki
mokoaki / file_tree_diff.rb
Created February 15, 2018 05:51
ファイル/ファイルツリーの簡易diff まだファイル単体同士を指定した時にバグがある 時間がある時に治す
require 'digest/sha1'
target_path_a = ARGV[0]
target_path_b = ARGV[1]
def sha_data(target_path)
begin
file_type = File.ftype(target_path)
rescue Errno::ENOENT
raise "No such file or directory - #{target_path}"
@mokoaki
mokoaki / temp.rb
Last active October 5, 2017 07:33
配列のハッシュをエクセル系にコピペ
# records = User.where('id > 0')
# records = User.where('id > 0').to_a
records = [{a: 1, b: 2}, {a: 3, b: 4}]
headers =
if records.first.class == Hash
records.first.keys
elsif records.first.class.superclass == ActiveRecord::Base
records.first.class.column_names.map(&:to_sym)
else
@mokoaki
mokoaki / 4.2.5.2_4.2.6.txt
Created March 8, 2016 14:40
Rails4.2.5.2 => 4.2.6
rails _4.2.5.2_ new testapp --skip-test-unit --database=mysql --skip-bundle
rails _4.2.6_ new testapp --skip-test-unit --database=mysql --skip-bundle
変更なし
@mokoaki
mokoaki / 4.2.5.1_4.2.5.2.txt
Created March 2, 2016 04:09
Rails4.2.5.1 => 4.2.5.2
rails _4.2.5.1_ new testapp --skip-test-unit --database=mysql --skip-bundle
rails _4.2.5.2_ new testapp --skip-test-unit --database=mysql --skip-bundle
変更なし
@mokoaki
mokoaki / 4.2.5_4.2.5.1.txt
Created January 26, 2016 03:02
Rails4.2.5 => 4.2.5.1
rails _4.2.5_ new testapp --skip-test-unit --database=mysql --skip-bundle
rails _4.2.5.1_ new testapp --skip-test-unit --database=mysql --skip-bundle
変更なし
@mokoaki
mokoaki / 4.2.4_4.2.5.txt
Created November 26, 2015 12:15
Rails4.2.4 => 4.2.5
rails _4.2.4_ new testapp --skip-test-unit --database=mysql
rails _4.2.5_ new testapp --skip-test-unit --database=mysql
変更なし