DRYな備忘録

Don't Repeat Yourself.

2016-02-01から1ヶ月間の記事一覧

【追記】babelのバージョン揃えるのみなさんどうしてるんですか? Unexpected token

% npm install --save-dev babel babel-core babel-loader こういうの出る % webpack ERROR in ./src/js/app/app.jsx Module parse failed: /app.jsx Line 1: Unexpected token You may need an appropriate loader to handle this file type. | import Reac…

【AWS】S3のbucket以下のリソースをpublicに読み込み可能にしたい

AWS

問題 S3上に置いた画像ファイルをブラウザから読むと403が返る AWSのコンソールでbucket以下ディレクトリ(正確にはObject)を Make Public すると見れる しかし、もちろんその後追加されるObjectについてはpublicにならない S3のBucketのPermissionsをいじ…

【Elixir】argument error, :erlang.++({'content-type', 'image/png'}, [])

いやーよくわからないエラーメッセージとスタックトレースなんだけど。なんか深そうだし。 ** (exit) an exception was raised: ** (ArgumentError) argument error :erlang.++({'content-type', 'image/png'}, []) (erlcloud) src/erlcloud_s3.erl:699: :er…

React+Babel+webpackの最小構成つくってだるかったことメモ

サンプルページ 3がつく数字でアホになるやつ tl;dr npm install -gはだるいので、npm scripts経由でwebpack呼ぶのがよさそう webpackが扱うべきファイルによってloaderがひつよう(babel-loaderとか) loaderを書く順番でひっかかって非常にだるかった impo…

【Elixir】protocol String.Chars not implemented for【エラー】

っていうエラーが出る protocol String.Chars not implemented for %{"avatar_url" => "https://avatars.githubusercontent.com/u/12345?v=3"} 文字列補完(string interpolation)に、String.Charsを持っていないデータ(MapとかStruct)を渡していることに…

【Elixir】Ecto.Migrationで外部キー参照とNOT NULL制約を追加

こういうことを学んだので↓ otiai10.hatenablog.com これを、Ecto.Migrationでやりたい defmodule MyApp.Repo.Migrations.CreateUserToken do use Ecto.Migration def change do create table(:posts) do add :user_id, references(:users, on_delete: :dele…

【MySQL】DEFAULT NULLと外部キー制約の同居

同居できるんかなと(ほんとはMariaDB) mysql> CREATE TABLE users ( id SERIAL, name VARCHAR(255) ); Query OK, 0 rows affected (0.01 sec) mysql> CREATE TABLE posts ( user_id BIGINT(20) UNSIGNED DEFAULT NULL, # ← あえてつける message VARCHAR(2…

【Elixir】Module内のfunctionのリストを取得する

stackoverflow.com Ecto.Repo.__info__(:functions) [__adapter__: 0, __pool__: 0, __query_cache__: 0, __repo__: 0, all: 1, all: 2, config: 0, delete: 1, delete: 2, delete!: 1, delete!: 2, delete_all: 1, delete_all: 2, get: 2, get: 3, get!: 2,…

Ecto.Migration内でINSERTする

Ecto.Migration – Ecto v2.0.0-beta.0 execute使お... defmodule MyApp.Repo.Migrations.CreateProviderTable do use Ecto.Migration def change do create table(:providers) do add :name, :string timestamps end create unique_index(:providers, [:name…

Elixirで無名関数の実行

Elixir (iex) iex(1)> (fn msg -> IO.puts msg end).("hello!") hello! :ok Go func(msg string) { fmt.Println(msg) }("hello!")

Herokuインスタンス上の環境変数を取得、確認する

% heroku run --app my-app env env実行したらええやん的な

ElixirでFizzBuzz

前回まで 【Elixir】バージョン管理しつつErlangとElixirをMacにインストールする - DRYな備忘録 【Elixir】the result of the expression is ignored - DRYな備忘録 【Elixir】use of operator === has no effect と言われる - DRYな備忘録 Elixirでゼロ埋…

Elixirでゼロ埋め【zero padding】【elixir】

iex(6)> String.rjust("hoge", 8, ?0) "0000hoge" zero paddingしたい対象がintegerなら、適宜、第1Integer.to_striingなど使う。 123 |> Integer.to_string |> String.rjust(8, ?0) 参考 In Elixir, how do you format numbers with string interpolation -…

【Elixir】use of operator === has no effect と言われる

問題 Elixirのコンパイラに掲題のように叱られる。 原因 「===使ってもええんやで」という意味。 解決 1..max |> Enum.each fn(n) -> - case {rem(n, 3) == 0, rem(n, 5) == 0} do + case {rem(n, 3) === 0, rem(n, 5) === 0} do {true, true} -> 雑感 たと…

【Elixir】the result of the expression is ignored

問題 ElixirでFizzBuzz書いてて、掲題のように怒られる main.exs:4: warning: the result of the expression is ignored (suppress the warning by assigning the expression to the _ variable) the result of the expression is ignored (suppress the war…

docker-composeで Unknown MySQL server host 'localhost' とかなる現象

問題 だいたいどんなDBのイメージ使ってても、同じdocker-composeでサーバアプリケーションも一緒に動かそうとすると、いかのように叱られることがよくある。 Unknown MySQL server host 'localhost' べつにMySQLに限らない。MongoDBでもRedisでも、ありがち…

【Elixir】バージョン管理しつつErlangとElixirをMacにインストールする

just want "Hello, World"? brew install elixirで、ErlangもElixirも入ります。 参考 qiita.com Prerequisite JDK installed on your mac brew install wget Good Bye Elixir, installed via brew brewで入れたelixirは消す % brew uninstall elixir % brew…