2020/02/24~2020/03/08のメモ
だいぶサボってた…
catalinaにjava sdkをインストールする
これが正解なのかわからないがbrewでいれた。
brew install java11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
circleciのrubyイメージでmysql2 gemがうまく使えない
circleci/ruby:2.3.7-node-browsers
- そもそもこれが古い
- mysql2は0.5.2
- インストールは成功するが、いざ使う段になって次のエラーがでる
LoadError: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /home/circleci/repo/vendor/bundle/ruby/2.3.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.so
になる
- 原因はgemのキャッシュだった。Dockerのimageが変わるときにはgemのキャッシュをpurgeされるようにしておいたほうがいいのかも?
ruby - Sunspot/Solr: indexing a time field results in NumberFormatException - Stack Overflow
Dockerで用意したsolrがデフォルト設定なので、2gram前提で作っているテストがコケた
- solrにschema設定してデータをpostする - Qiita
- のようにRESTで設定を突っ込むとよいのかな
- solrconfig.xmlの一部設定を変更することでschema.xmlを読みに行かせることができる
- sunspotはsolr7系以上で使えるschema.xmlを用意している
- ワンチャン使えるかな?と思ってsolr5.5で試してみたけどだめだったのでsolr7系を使うように変更した
- Apache Solr設定メモ - Qiita
Dockerfileを作って、developmentのとtestのcoreをbuild時に作るようにした
sunspot.ymlはERB使える模様
cp — Docker-docs-ja 17.06.Beta ドキュメント
dockerでscpみたいなのできるのかな…と思っていたが普通にできましたね…
docker pushのお作法
- たまにしかやらないので忘れる。
- imageとして
willnet/hoge:1.0.0
のような名前にしておく必要があった docker tag 今の名前 新しい名前
で新しいタグを作れる
CentOS7で実行ファイルの不足している依存関係を解消する(CentOS7でElectronが試せない話に関連して) - Qiita
yum whatprovides
便利ではyum provides
でも同じそう
Amazon LinuxでImageMagicK(Imagick)を使う | ハックノート
古い環境に古いimagemagickインストールバトルつらい…
RPMパッケージをインストール/アンインストールするには
↑でimagemagickをyum経由でインストールするには、関連するrpmを都度インストールして依存関係を満たして上げる必要がありそう。めんどい
bundle installした古いバージョンのgemが参照されている
bundle -v Bundler version 2.1.4
bundle clean
したら解消(当たり前だけど)した。gemコマンドもしくはbundlerかなあ…。
sidekiqでメール送信したときにエラーになってもsentryには通知したくない
- どうせすぐリトライするので、少なくともerrorではなくてwarnかinfo程度にしておきたい
- 数回ためして全部ダメだったら初めてerrorとして通知したい
- Error Handling · mperham/sidekiq Wiki
- 規定のリトライ回数実行してもだめだったときの処理を↓のように書ける
- ので、workerの設定側で
- 基本的にはwarnでSentryに投げる
sidekiq_retries_exhausted
ではerrorで投げる- のようにすれば目的達成できるかな
class FailingWorker include Sidekiq::Worker sidekiq_retries_exhausted do |msg, ex| Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}" end def perform(*args) raise "or I don't work" end end
- しかし↑で書いたやり方だと、sentryが定義しているやりかたを完全に上書きするようになってしまう。なんかもうちょっとスマートなやり方ないかな
- sentryはこんな感じでsidekiqのerror_handlersを定義して、server_middlewareにsentry用のmiddlewareを追加している raven-ruby/sidekiq.rb at master · getsentry/raven-ruby
- sidekiqのcontextに、何回目のエラーであるという情報は含まれないのだろうか
- sentryの実際のエラーページ見た感じだと含まれてなさそう?
- 結局、自作のerror_handlersを定義する必要があるかな
- ravenの読み込み方を工夫すると、sidekiq用のコードを読ませずにロードできそう
gem 'sentry-raven, require: 'sentry-raven-without-integrations'
- ドキュメントもあった
- ravenの読み込み方を工夫すると、sidekiq用のコードを読ませずにロードできそう
- error_handlersに失敗回数渡せるのかな
- ざっと見た感じでは渡せていそうなので、頑張ればできるか
- だれか他にやってる人いるんじゃないのかな…
elasticsearch
- elasticsearchのデフォルトだと字句解析の結果が直感的ではない
- kuromojiいれた
- Japanese (kuromoji) Analysis Plugin | Elasticsearch Plugins and Integrations [7.4] | Elastic
- searchkick側も
searchkick language: 'japanese'
のようにするだけだった - 簡単すぎるんだけど穴とかないんですかね
- 関連先も検索条件に含めたい
How should I generate an API key that allows me to use the Heroku Platform API? - Heroku Help
Chromeで自己証明書(などの不正証明書)を使用したサイトにアクセスする方法 - Qiita
Promise#finally
finallyという名前から、いつ登録しても最後に呼ばれるのでは?と勘違いしていまったが普通に登録した順ですね…。
Promise.resolve(1).then((v) => { console.log(v); return v }).finally((v) => console.log('finally')) VM502:1 1 VM502:1 finally Promise {<resolved>: 1} Promise.resolve(1).finally((v) => console.log('finally')).then((v) => { console.log(v); return v }) VM516:1 finally VM516:1 1
Type 'string' is not assignable to type 'RequestCredentials' · Issue #21618 · microsoft/TypeScript
- これはこういうものらしい
- 最初objectのpropertyとして定義されるときに型が推測されるのでstringとして扱われてしまう
- fetchの引数として即突っ込む場合はRequestCredentialsと判断される
- ↓のようにしたら通った
let options = { # ... credentials: <RequestCredentials>'include' }
RubyMineを使っているならReformatでもっと幸せになろう | mah365
rubymine弱なので、どこかからコピペしたコードのインデントがずれていたときに手動でインデント直したりしていた。reformatという単語だけ覚えておけば次からなんとかなりそう
2020/02/18~23のメモ
Application Security Management Platform | Sqreen
雑に眺めたので間違ってるかもだけど
- アプリケーションサーバに対するファイヤウォール
- エージェント(かな?)をアプリケーションサーバにインストールして、攻撃を検知する
- 試すのはともかくお値段だいぶ高そうなので、ちゃんと売上の立っていてかつセンシティブなサービスでないと導入が難しそうな雰囲気がある
- 小さいサービス(3Mリクエスト/月)なら無料で使えるので手持ちのサービスにいれて雰囲気を掴んでみたい
Develop. Preview. Ship. - ZEIT
- 無料でサーバレス環境使えるのは便利そうではある
- rubyも使えるっぽい
que-rb/que: A Ruby job queue that uses PostgreSQL's advisory locks for speed and reliability.
- better delayed_jobっぽい
- postgres限定
- postgres のadvisory lockを使っているので速いとのこと
ghq
brew upgrade ghq
でバージョンアップしたらメジャーバージョンがあがり非互換な変更が入っていた- デフォルトのディレクトリが
~/.ghq
から~/ghq
に変更されていた 単純に
mv .ghq ghq
として対応yoshiori/fish-peco_select_ghq_repository がうまく動かなくなった
fishのお作法がよくわかっていない
fish-peco_select_ghq_repository/peco_select_ghq_repository.fish at master · yoshiori/fish-peco_select_ghq_repository を読みつつ何をやっているのかざっと書く
set -l a b
はローカル変数aにbをアサインする- commandlineはコマンドラインバッファ(って何)の読み書きをする
- 引数なしだと現在のコマンドラインバッファを読む
- 引数ありだと今のコマンドラインバッファを消して引数ので差し替える
- commandline:自作エディタコマンドのお供【上級者向け】
- 最終的にこれでいいんじゃない、となった
function peco_select_ghq_repository ghq list | peco | read line if [ $line ] cd (ghq list --full-path --exact $line) commandline -f repaint end end
- forkした willnet/fish-peco_select_ghq_repository
- 理由がわかったらPRしたいところ
yarn
yarn install --frozen-lockfile
でyarn.lockが更新されないことを保証できる。yarn.lockがpackage.jsonの記述を満たさないときは通常yarn.lockは更新されるのだけど、このオプションではそれを抑制できるっぽい
webpackerってどうやって最新のnpmがインストールされていることを確認しているんだっけ
- webpacker/README.md at 2dfa56fe4b1b73b1122e13663b198f606c177b2f · rails/webpacker
- webpacker/railtie.rb at 93152cfa5827e032ae84f54a6b61a57ca9379e4f · rails/webpacker
yarn check --integrity && yarn check --verify-tree 2>&1
yarn check
とそれぞれのオプションは違うっぽい
NOTE: The command yarn check has been historically buggy and undermaintained and, as such, has been deprecated and will be removed in Yarn 2.0. You should use yarn install --check-files instead.
- yarn checkは使わないほうがいいらしい。
- これはyarn check単体の話で、
yarn check --integrity
とyarn check --verify-tree
はまた別(つかってもよい)のかな?- いろいろ見た感じ、どうも同様っぽいぞ
- これはyarn check単体の話で、
yarn check
(使わない)はpackage.jsonとyarn.lockとの整合性を見るyarn check --integrity
はpackage.jsonとyarn.lockとの整合性と、yarn.lockのハッシュ値が正しいかを見るyarn check --verify-tree
はpackage.jsonとnode_modules
配下に置いてあるファイルのバージョンとの整合性を見る(yarn.lockは見ない)Remove yarn check by arcanis · Pull Request #106 · yarnpkg/rfcs
It has to do with the way we make an early bailout if the node_modules is already there (to avoid running an installation if there is no need). Without --check-files Yarn will only checks for the various folders to exist (plus various other settings), whereas with --check-files it will also check for all the registered files to exist. It's not super useful anymore, but it's not as redundant as yarn check.
yarn install --check-files
はインストール前にnode_modeles配下をちゃんとファイル単位で見る、というのが--check-files
なしとの違いのよう
Add strict_loading
mode to optionally prevent lazy loading by eileencodes · Pull Request #37400 · rails/rails
lazy loadingしないぞ!という強い決意を示したいとき(どういうときだろ)に使えそう
Spark
2020/02/17のメモ
Linux Tips – RAMディスク(/dev/shm)のIO性能をチューニングに活用する方法
/dev/shm
よくわかってなかったので再度調べた- Dockerコンテナで利用できるリソースや権限を制限する(Dockerの最新機能を使ってみよう:第3回) | さくらのナレッジ
- chromeがデフォルトで
/dev/shm
使うのハマりどころだよなーと思う
yumリポジトリ追加リスト 完全版 - Qiita
Amazon Linux 2 EC2 インスタンスに Extras Library からソフトウェアをインストールする
こんな仕組みあるの知らなかったな
Amazon Linux 2のExtras Library(amazon-linux-extras)を使ってみた | Developers.IO
2020/02/16のメモ
Modern site search for companies of all sizes | Algolia
- elasticsearchと比べてどうなのかが気になる
- ElasticSearch vs Algolia - Mariano Matayoshi - Medium
- このエントリ的を斜め読みするとalgoliaのほうがちょっと便利さが強いが値段が高い、と書いてあるように読める
- What makes Algolia different than Elasticsearch or Solr? | Why Algolia FAQ | Docs Algolia
- algolia公式的には、速いのと、検索機能でよく必要なもの(先頭文字入力からの検索、typoをいい感じにする、結果のハイライト、ランキング)が簡単に使える、というところが違うぞと書いてある
- ElasticSearch vs Algolia - Mariano Matayoshi - Medium
- 公式gemがある
elasticsearch用のgem
- elastic/elasticsearch-ruby: Ruby integrations for Elasticsearch
- ankane/searchkick: Intelligent search made easy with Rails and Elasticsearch
- toptal/chewy: High-level Elasticsearch Ruby framework based on the official elasticsearch-ruby client
searchkickとchewyはどちらもelasticsearch-rubyベース
deviseを所有しているorgが変わっていた
For all other Open Source projects under the Plataformatec organization on GitHub, we will reach out to the current maintainers and take the necessary steps to transfer the ownership of all relevant assets, including names, source code, and logos of such projects.
Important information about our Elixir and Ruby Open Source projects « Plataformatec Blog
ということで、買収がきっかけで別の人にOSSプロジェクトを引き渡したってことかな。
SQLite3の実際の型 - すがブロ
- rails6でもsqlite3なデータベースの文字列型はvarcharだった
- 実質text
- 上限いくつですかね
- String storage size in sqlite - Stack Overflow
The default is 109 bytes.
- えっ10GB?
- Implementation Limits For SQLite
- postgresでもほぼ同様かな
- database - PostgreSQL character varying length limit - Stack Overflow
- In any case, the longest possible character string that can be stored is about 1 GB
2020/02/14のメモ
macにmongodbをインストール
brew install mongodb
ではだめだった。
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
brew tap mongodb/brew brew install mongodb-community@4.2
↓で起動
mongod --config /usr/local/etc/mongod.conf
MongoDBのデータダンプとリストア - Qiita
mysqldumpっぽさある
What is an "Unregistered User"? – CircleCI Support Center
- circleciに一度もsignupしていないユーザはUnregistered User
- signupしても過去Unregistered Userとなっていたものは更新されない
2020/02/13のメモ
GitHub CLI Beta | Take GitHub to the command line
- hubを完全に置き換えられるのかな
- 現時点ではそうではなさそう
Work seamlessly with GitHub from the command line. GitHub CLI is in early stages of development, and we'd love to hear your feedback at <https://forms.gle/umxd3h31c7aMQFKG7> Usage: gh [command] Available Commands: help Help about any command issue Create and view issues pr Create, view, and checkout pull requests Flags: --help Show help for command -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format --version Show gh version Use "gh [command] --help" for more information about a command.
2020/02/12のメモ
rollbar
- githubのように、一つのアカウントが複数のorganizationに所属できるイメージだったんだけどうまくorganizsationへの追加ができなかった
- 招待メールアドレスをユーザに追加しておくのが条件っぽい(メールアドレスを追加したらいけた)
Refactoring Rails
- 興味はあるのだけどだいたい知ってる内容っぽい&&積みそうなので購入を躊躇している
- https://courses.gorails.com/refactoring-rails
Investigate libxml2 vulnerabilities patched in USN-4274-1 · Issue #1992 · sparklemotion/nokogiri
Merge pull request #37174 · rails/rails@a6cf649
- ActiveSupport::Concernにprependサポートが入った
- (使うかどうかはさておき)なるほど感ある