コンパイラかく語りき

import { Fun } from 'programming'

ExpressとRethinkDBで作るRESTfulなWebAPI

ExpressとRethinkDBで作るRESTfulなWebAPIです。 RethinkDB公式のこちらを参考にしました。 ひとまず、Expressでルーティングを定義して、RethinkDB上のデータへのCRUD処理ができるところまで。 前提条件 RethinkDBをインストールしておく。 Express起動前に…

Promiseチェーンの中で条件を満たすまで同じ処理を繰り返す(リトライ処理)

Promiseチェーンの中で、特定の条件を満たすまで同じ処理を繰り返したい場合があります。 例: データロード処理 そんな場合のコードサンプルです。 コード こちら。 const retryPromise = (func, delay) => { const retry = (resolve, reject) => func() .th…

table-layout: fixed; せずに text-overflow: ellipsis; する

長過ぎる文字列に対して、文末に「…」をつけて省略して表示したい時があります。 これをHTMLのtable要素で実現する方法について書きます。 固定幅テーブル まず、行が固定幅で良いのなら以下のように書けます。 table { table-layout: fixed; } td { white-s…

curlに対して、Express上のGraphQLサーバが Must provide query string. を返す

問題 Express上のGraphQLサーバへと、curlでqueryを発行した。 $ curl -XPOST -H "Content-Type:application/graphql" \ 'http://localhost:5000/api/graphql' \ -d 'query Query { user(_id: 3) { name, mail } }' すると、以下のようなレスポンスが。 { "e…

webpacker2.0に上げたら、Herokuへのデプロイが失敗する対処(Configuration config/webpacker.yml file not found. Make sure webpacker:install is run successfully before running dependent tasks)

問題 Herokuへのデプロイが失敗した。 webpacker gemを2.0に上げたのが原因っぽい(元々は1.2でした)。 こちらがエラーログ。 Configuration config/webpacker.yml file not found. Make sure webpacker:install is run successfully before running depend…

The git source `hoge` uses the `git` protocol, which transmits data without encryption...の対処法

問題 Gemfile内でgemに対して、:github プロパティを使っていた所、以下のようなエラーが。 The git source `hoge` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`…

ReqlDriverError: Could not connect to localhost:28015. → RethinkDB自体が起動していませんでした

RethinkDBとRethinkDBのnodeドライバに関して、ちょっとハマったのでメモ。 問題 ローカルのコンソールからRethinkDBのドライバを起動しようとする。 // server.js r = require('rethinkdb') r.connect({host: 'localhost', port: 28015}... $ node server.j…

RethinkDBでDB名の変更

無かったのでメモ。 以下のReQLクエリでDB名が変更できる。 r.db("old_name").config().update({name: "new_name"}) configについて。 https://www.rethinkdb.com/api/javascript/config/ 参考: https://github.com/rethinkdb/rethinkdb/issues/151#issueco…

RethinkDBで「DBが存在して無ければ作る」「テーブルが存在して無ければ作る」

※ Nodeで書いてますが、ReQL自体は言語フリーなので他言語の方にも参考にはなると思います。 初期化時にありがちな、DBとテーブルを有無をチェックしながら作成するという処理。 DB作成 // 無ければDBを作成 r.dbList().contains('messages').do((containsDb…

node.jsでRethinkDBを扱うためのORM "Thinky" を試してみた

Thinkyというnode.jsでRethinkDBを扱うためのORMを試してみました。 RethiknDB: https://www.rethinkdb.com/ Thinky: https://thinky.io/ 参考ページ 公式のドキュメントのクイックスタートというページを参考にしてみました。 https://thinky.io/documentat…