Skip to content

Instantly share code, notes, and snippets.

View tetz-akaneya's full-sized avatar

Tetsuo Akaneya tetz-akaneya

View GitHub Profile
bundle config --local <name> <value>
ex.
bundle config --local path vendor/bundle
if defined?(PryByebug)
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
Pry.commands.alias_command 'c', 'continue'
end
Railsにおいて、--apiをつけてnewした際には、通常のnewした際に比べてmiddlewareは以下のように異なる
(コメントアウトしている部分がapiモードの際にはかけている部分。)
use Rack::Sendfile
use ActionDispatch::Static
use ActionDispatch::Executor
use ActiveSupport::Cache::Strategy::LocalCache::Middleware
use Rack::Runtime
# use Rack::MethodOverride
use ActionDispatch::RequestId
use ActionDispatch::RemoteIp
git branch -m <古いブランチ名> <新しいブランチ名>
git branch -m <新しいブランチ名>
rm from stage
git reset HEAD -- <directoryName>
git rm --cached <file>
@tetz-akaneya
tetz-akaneya / oauth2_client.md
Created December 25, 2018 09:38
oauth2_client.md

gem install oauth2 irb -r oauth2

site = "http://localhost:3000/"
client = OAuth2::Client.new("es", "some_secret", site: site)
url = client.auth_code.authorize_url(redirect_uri: "https://localhost:3000/accounts/auth/")
URLにアクセス。返ってきたきたcodeを取得。
code = 自分で代入
token = client.auth_code.get_token(code, redirect_uri: "https://localhost:3000/accounts/auth/")
https://www.wappalyzer.com/
rails new ***
rails generate scaffold user name:string email:string age:integer
rails db:migrate
rails server -p 3000
# rvmを使ってるならrvm gemdirでgemのdirが分かる
# ln -s <gem_path> <destination>
ln -s `rvm gemdir`/gems external_libraries
@tetz-akaneya
tetz-akaneya / binary.rb
Last active September 8, 2018 02:42
RailsのArelを調査してみた ref: https://qiita.com/valley/items/9ac200acbccc46b2ea44
# Arel::Noees::Orの親クラス
def initialize left, right
super()
@left = left
@right = right
end

Arelについて調べてみた

RailsでSQLについて調べていくうち、Arelが分からないと分からんという状況に至りました。色んな方のブログを読むと、同じような方が何名かいて「ですよね」って一人で言い続けてました。

今のところ見知っていることを書きます。

Arelは、複雑なクエリをまとめあげるロジックを持つライブラリです。 rails/activrecordの下で開発されているけど、activerecordやrailsとは別のgemです。

rubydocを片手にライブラリの構成を見ていきます。

https://docs.docker.com/storage/bind-mounts/#choosing-the--v-or---mount-flag

-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.
In the case of bind mounts, the first field is the path to the file or directory on the host machine.
The second field is the path where the file or directory is mounted in the container.
The third field is optional, and is a comma-separated list of options, such as ro, consistent, delegated, cached, z, and Z. These options are discussed below.

Qiita: 【Docker】Dockerでホストのディレクトリをマウントする