Skip to content

Instantly share code, notes, and snippets.

View tetz-akaneya's full-sized avatar

Tetsuo Akaneya tetz-akaneya

View GitHub Profile
ラップ
ネジ
machine:
ruby:
version: 2.2.2
dependencies:
post:
- touch a.txt
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.1.tar.gz
- tar -xvf elasticsearch-6.0.1.tar.gz
- elasticsearch-6.0.1/bin/elasticsearch -d
# Make sure that Elasticsearch is up before running tests:
h1,h2,h3,h4,h5,h6,
table,
pre,
.alert-box,
div,
.wrapper,
th,
td,
.white-background,
.button,

はじめに。Promiseについて

(基本的に読者はPromiseasync, awaitについて知っている前提です。この「Promiseについて」で説明はしていますが、とにかくはしょり過ぎているので、これらを正しいと感じれらるかだけの利用に限ってください=正しいと感じられたら次に進んでください。学習には向きません。)

Promiseはcallback地獄を回避するために生まれた。

Promiseのインスタンスには3種類の状態があり、pending, resolved, rejectedがある。

例えば、

@tetz-akaneya
tetz-akaneya / file0.txt
Last active July 1, 2019 06:33
Promiseが分かれば簡単!async, await ref: https://qiita.com/valley/items/dd37deb77f06eb6c451c
async function asyncFunc (arg) {
// もちろん引数のargはここで使えます
const message = 'Hello async';
return message;
}
@tetz-akaneya
tetz-akaneya / Rackのmiddlewareについて.md
Last active July 17, 2018 22:59
Rackのmiddlewareについて

http://railscasts.com/episodes/151-rack-middleware?autoplay=true メモ

railsは、リクエストがアプリケーションに到達するまでに、またはしてからたくさんのrackミドルウェアを通過して、様々なことが行われる

rails middlewareにて、デフォルトのmiddlewareたちが分かる Rails.middleware.use("SomeMiddleware", arg)にて、自作のmiddlewareを引数付きで使える middlewareは実は1つ1つが小さなrackアプリケーションで、反応すべきメソッドさえようしておけば良い 基本、libディレクトリの下に自作のものは作る

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でホストのディレクトリをマウントする

Arelについて調べてみた

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

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

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

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

@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
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