Capistranoを使うメモ
$ bundle init
GemfileにCapistranoを入れる
# A sample Gemfile
source "https://rubygems.org"
Capistranoを使うメモ
$ bundle init
GemfileにCapistranoを入れる
# A sample Gemfile
source "https://rubygems.org"
defmodule Hhfuns do | |
def a(o, p, q) do | |
fn(num, acc) -> | |
IO.puts "#{inspect o}, #{inspect p} #{inspect q}" | |
num + acc | |
end | |
end | |
end | |
x = Hhfuns.a("ooo", "ppp", "qqq") | |
IO.puts "x = #{inspect x}" ## x = #Function<0.111962536/2 in Hhfuns.a/3> |
Erlang, Elixir間の変換
Erlang
1> element(2, {a, b, c}). %% インデックスは1ベース
b
Elixir
iex(1)> elem({:a,:b,:c}, 1) ## インデックスは0ベース
Riakにコネクションを貼る
iex(1)> {:ok, pid} = :riakc_pb_socket.start_link('*.*.*.*', 8087)
{:ok, #PID<0.191.0>}
iex(2)> :riakc_pb_socket.ping(pid)
:pong
Riakオブジェクトを作成して,Riakに保存する
$ rel/riakcscalc/bin/riakcscalc rpc Elixir.RiakcsCalc.StorageConsole batch "['1']."
options is :"1"
options is atom true
$ rel/riakcscalc/bin/riakcscalc rpc Elixir.RiakcsCalc.StorageConsole batch "[\"1\"]."
options is '1'
options is list true
Erlangのio
モジュールの出力フォーマットの一部をチェックしてみる
数字97を2桁で出力
54> io:fwrite("|~2b|~n", [97]).
|97|
ok
数字97を3桁で出力
my-hello-emacs
関数を定義して,呼び出す
(defun my-hello-emacs()
(message "hello emacs"))
(my-hello-emacs) ; my-hello-emacs関数を呼び出す
文字列FOO
を変数foo
に代入.'
はquote
関数の略称
rebar3を使ってcowboyのアプリケーションを作成,ソースコード
$ rebar3 new release echo_get
$ cd echo_get
echo_get
のrebar.config
ファイルのdeps部分をcowobyを入れる
{deps, [
CentosにEmacs のinstall
yum remove emacs-nox emacs-filesystem emacs-common
yum install gcc ncurses-devel
cd /opt
wget http://ftp.gnu.org/pub/gnu/emacs/emacs-25.3.tar.gz
tar zxvf emacs-25.3.tar.gz
cd /opt/emacs-25.3
./configure --without-x
make
give_away
関数の使い方1> Pid = spawn(fun () -> receive foo -> ok end end). %% Erlang Shellから一個のプロセスを作成
<0.35.0>
2> Tab = ets:new(x, [public]). %% 新規作成したETSテーブルのownerはErlang Shell
16400
3> self().