erlang
hanyingzhong
这个作者很懒,什么都没留下…
展开
-
rebar test
[root@han eredis_pool]# lltotal 160drwxrwxr-x 4 1001 1001 35 Dec 31 04:49 depsdrwxrwxr-x 2 1001 1001 154 Dec 31 04:49 docdrwxrwxr-x 2 1001 1001 109 Dec 31 04:55 ebin-rw-rw-r-- 1 1001 1001 395 Dec 31 04:55 Makefile-rw-rw-r-- 1 1001 1001 .原创 2021-12-31 13:09:18 · 487 阅读 · 0 评论 -
Monitor CPU/MEM/storage
[root@han kazoo-4.3.140]# cat /root/monitor_cpu.sh#!/bin/bash#system process CPU&MEM use information#mail: [email protected]=$1name=$2process=$3mem_total=$(cat /proc/meminfo | grep "MemTotal" | awk '{printf "%.f",$2/1024}')cpu_total=$(( $.原创 2021-09-06 09:24:21 · 182 阅读 · 0 评论 -
13[2-8]
[root@han learn_erl]# cat numberconvert2.erl -module(numberconvert2).-compile(export_all).binary_to_charlist(_, Postion, Result, TotalLength) when Postion =:= TotalLength -> lists:reverse(Result);binary_to_charlist(Str, Postion, Result, TotalLe.原创 2021-08-23 16:52:56 · 46 阅读 · 0 评论 -
更新列表中元组的值
1> c(update).{ok,update}2> 2> 2> update:update3().** exception error: undefined function update:update3/03> A = [{"key1","value1"},{"key2","values"}].[{"key1","value1"},{"key2","values"}]4> 4> 4> update:update3(A, "key1",.原创 2021-07-06 12:50:49 · 113 阅读 · 0 评论 -
从复杂元表中获取数据
2> A = {ok,{[{<<"module">>,<<"callflow">>},{<<"children">>,{[{<<"_">>,{[{<<"module">>,<<"play">>},{<<"children">>,{[]}},{<<"data">>,{[{<<"id">>,.原创 2021-06-18 13:35:52 · 79 阅读 · 0 评论 -
erlang:列表拼接/过滤列表/快速排序
[root@han learn_erl]# erlErlang/OTP 22 [erts-10.7.2.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]Eshell V10.7.2.1 (abort with ^G)1> c(conact).{error,non_existing}2> c(concat). concat.erl:2: Warning: export_all flag enab.原创 2021-05-14 08:48:10 · 363 阅读 · 0 评论 -
Erlang 中的 supervisor
【概况】supervisor behaviour 是用来实现监控其他子进程的supervisor 进程的模块;子进程可以是另一个 supervisor 进程,也可以是一个 worker 进程;worker 进程一般使用 gen_event,gen_fsm 或 gen_server behaviour 来实现;一个使用 supervisor behaviour 实现的 supervisor 有一个接口方法的标准集,包括跟踪和错误报告的功能;supervisor 机制用来构建一个分层进程结构,称为..转载 2021-04-28 14:10:22 · 516 阅读 · 0 评论 -
erlang:循环执行方法(1)
%% b.erl-module(b).-export([x/0]).-export([test/1]).x() -> 20000.y() -> io:format("Vsn1 (~p) b:x() = ~p~n", [1, 2]).test(Count) ->[y() || _ <- lists:seq(1,Count)].[y() || _ <- lists:seq(1,Count)].4> b:test(10). Vsn1 (1.原创 2021-04-28 09:47:35 · 204 阅读 · 0 评论 -
erlang 模块热加载
[root@han erlangsrc]# cat codereload.erl -module(codereload).-export([main/0, master_loop/2, worker_loop/0]).-define(VERSION, "0.2"). main() -> process_flag(trap_exit, true), Pid1 = spawn(?MODULE, worker_loop, []), Pid2 = spawn(?MOD...原创 2021-04-28 09:01:29 · 198 阅读 · 0 评论 -
erlang:一个简单的资源分配器
-module(allocator).-export([start/1,server/2,allocate/0,free/1]).start(Resources) -> Pid = spawn(allocator, server, [Resources,[]]), register(resource_alloc, Pid).% The interface functions.allocate() -> request(alloc).free(Resour.原创 2021-04-01 23:40:58 · 94 阅读 · 0 评论