emolog

脳内メモです。

プログラミング

brew updateで `homebrew-core / homebrew-cask is a shallow clone. `と怒られる

Macにて、 brew update を実行しようとしたら怒られた $ brew update Error: homebrew-core is a shallow clone. homebrew-cask is a shallow clone. To brew update, first run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --u…

Flutterでレイアウト調整の際に、Containerの枠に色をつける

メモです。 Container( # 色 decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.red)), width: width, height: gifHeight, child: Center( child: Image.asset('images/logo.png'), ), ),

Flutterで画像を表示する

Flutterで画像を表示する プロジェクト直下にimagesディレクトリを作成 pubspec.yamlを編集する flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the materi…

【Flutter】formとsubmitボタンを定義する

Flutterでフォームとsubmitとボタンを作成したかったのでメモです。 Widget build(BuildContext context) { final roomNameFocusNode = FocusNode(); final formState = GlobalKey<FormState>(); return Form( key: formState, child: Column( children: [ TextFormFiel</formstate>…

未経験からエンジニアになって4年目になったので、ちゃんと読み直したい本達のメモ

2018年の4月くらい(たしか)にエンジニアになり、早いものでエンジニアになって4年目になりました。 非エンジニアの期間とエンジニアの期間が5:5くらいで、ビジネスとエンジニアリングのバランスを評価されることが多いのですが、エンジニアリングも引き続…

Flutterのローカル開発で、APIリクエストがSocketExceptionと怒られたときの対応

事象 APIリクエストには retrofit を使用している -ローカル環境に対してつないでいる、Andoridのエミュレーター リクエスト時に、SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 37922 みたいなエラーになる ロ…

【rails】新規のrailsプロジェクトを作るときの手順メモ

何回やっても、よく忘れるのでメモです。 新規のrailsプロジェクトを作る 前提 rails new hogeしない システムのgemを使わない bundle execで呼び出す $ mkdir hoge $ cd hoge $ bundle init Gemfile # frozen_string_literal: true source "https://rubygem…

【rails】active_adminの詳細ページを変更する

やりたいこと active_adminで管理画面の詳細ページから、ユーザのメールアドレスを変更できるように修正したい やったこと /admin/users.rb の変更 ActiveAdmin.register User do actions :index, :show, :new, :create, :update, :edit permit_params :emai…

【rails】 seedデータ投入時に、csvをimportしてよしなにする

seed_data投入をいい感じにやりたかったので、メモ seeds.rbに全部入れるのは見通しが悪くなるのでやめたい。 やりたいこと csvファイルに、seed_data用のファイルを定義 そのファイルを読み込んでseed_dataとして投入 bundle exec rails db:seed で実行され…

railsでfactory_botのセットアップ

やりたいこと 新規プロジェクトでのfactory_botの整備をしたい railsでモックのデータを作る やったこと gemに追加 group :test do gem 'factory_bot_rails' end rails_helperに以下を追加 RSpec.configure do |config| config.include FactoryBot::Syntax::…

rubocopを入れたメモ

やりたいこと 新規プロジェクトでのrubocopの整備 やったこと gemの追加 group :development do # rubocop用に追加 gem 'rubocop', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec' end…

ssh_addしたらCould not open a connection to your authentication agent.って怒られたのでメモ

$ ssh-add ~/.ssh/hoge_key Could not open a connection to your authentication agent. sshのエージェントが立ち上がっていなかったっぽいので、変更したら解決した $ eval "$(ssh-agent)" ssh-addに失敗する場合の対処:Could not open a connection to yo…

rspecのセットアップ

github.com # Or, run against the main branch # (requires main-branch versions of all related RSpec libraries) group :development, :test do %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib| gem lib, git: …

DataFrameのメモ

python初心者なのでメモ del df['列名'] で消せる 少数をまるめる round(float, 桁数)

ActiveRecordでレコードの合計値を取得する場合は、countよりsize使おうという話

結論(仮) countよりsize使ったほうが便利 sizeとcountの挙動の違いについて size メモリに乗っているときはクエリ発行せずメモリ上から計算 なければクエリ発行 以下railsのapiドキュメントからの引用 size()Link Returns the size of the collection. If …

Cloud Functions for Firebaseで環境変数を設定する

firebase.google.com 環境変数の設定 firebase functions:config:set service_name.api_key="hogehoeg" 環境変数の削除 firebase functions:config:unset service_name コンソール内で設定した環境変数の確認 firebase functions:config:get コード内で取得(…

railsのENV[]とENV.fetch()の違い

ENV[] とENV.fetch()の違いがわかっていなくで少しはまった。 localでfailした local環境でもstagingやprodutionの環境変数部分は展開しているっぽい 修正前 staging: <<: *default host: <%= ENV["DB_HOSTNAME"] %> database: <%= ENV["DB_NAME"] %> username: <%= ENV["DB_USERNAME"] %> password: <%=</:>…

railsでいい感じにページングしたい人生だった

railsでmobile用にページングを作成する必要があり、いい感じにページングしたかったのでメモです。 要件 以下をapiのcall元(今回であれば)mobileからparameterが渡される。 それに合わせてページングする pagingした何ページ目か page defautl: 1 paging…