Skip to content

Instantly share code, notes, and snippets.

View junara's full-sized avatar
🐇
rabbit

jungo araki junara

🐇
rabbit
View GitHub Profile
@junara
junara / SvgIcon.vue
Last active February 11, 2023 15:48
@jamescoyle/vue-icon (Composition API + script setup + TypeScript)
<template>
<svg
:width="sizeValue"
:height="sizeValue"
:viewBox="viewboxValue"
>
<path :d="path" />
</svg>
</template>
@junara
junara / database.yml
Last active November 8, 2021 11:33
GitHub Actions で MySQL + Rails の構成で Annotateを実行してPRを作成する
default: &default
adapter: mysql2
host: <%= ENV['MYSQL_HOST'] || '127.0.0.1' %>
port: <%= ENV['MYSQL_PORT'] || 3306 %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: <%= ENV['MYSQL_DATABASE'] || 'junara_annotate_development' %>

目的

  • 既存のRailsプロジェクトにrubocopを導入する
  • rubocopをチームで活用する・・・GitHub Actionsでrubocop自動でチェックする

概要

  • 前準備
  • rubocop導入
  • GitHub Actionsでrubocop

前準備

class BulkUpserter
attr_reader :scope, :on_duplicate_key_update, :raise_error, :validate, :batch_size, :reports, :error, :exit_on_error
# activerecort-importのon_duplicate_key_updateを使いやすくしたもの
# 使い方例
# bulk_upserter = BulkUpserter.new(Blog.limit(100), {'Blog' => [:name], 'Comment' => [:name]})
# bulk_upserter.run {|blog, instances| blog.assign_attributes(name: 'fuga') || instances.add(blog) || blog.comments.build(name: 'piyo') || instances.add(blog)}
#
# bulk_upserter.reports はactiverecord_importのreportの配列
# => #<BulkUpserter::Reports:0x000055f74b08c4e0 @messages={:Blog=>[#<struct ActiveRecord::Import::Result failed_instances=[#<Blog id: 1, name: nil, edited_at: nil, created_at: "2019-11-23 07:17:30", updated_at: "2019-11-23 10:56:26">], num_inserts=0, ids=[], results=[]>], :Comment=>[#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1, ids=[], results=[]>]}>
@junara
junara / InkbirdLoggerReadme.md
Last active December 4, 2019 08:16
IBS-TH1 のログを取得してAmbientとローカルCSVに出力する python script
@junara
junara / file0.txt
Last active May 15, 2018 03:22
住所から都道府県を推定する ref: https://qiita.com/junara/items/dc5ab1ef4fb7c8872330
gem install levenshtein
@junara
junara / keyword_prediction.rb
Last active May 15, 2018 04:17
Keyword prediction by levenshtein
# USAGE
# keyword_prediction = KeywordPrediction.new
# keyword_prediction.path = './name2prefecture.csv' # set index data
# keyword_prediction.load # load index.csv
# keyword_prediction.predict('府中市') => [{"name"=>"府中市", "prefecture_name"=>"東京都", "similarity"=>1.0, "keyword"=>"府中市"}, {"name"=>"府中市", "prefecture_name"=>"広島県", "similarword"=>"府中市"}]
require 'csv'
require 'levenshtein'
class KeywordPrediction