[Erlang 0118] Erlang 杂记 V
做笔记
- 一开始笔记软件做的不好的时候就发邮件给自己,然后不断的回顾更新笔记;
- 后来用OneNote,由于这玩意当时不是云同步的,硬盘坏掉的时候丢了一些数据,打击还是挺大,好多事情要从头开始
- 再后来用过一段时间Google Wave,还以和朋友分享讨论笔记,结果,你们知道关闭服务了,费力导出来
- 现在转战Evernote和思维导图Conceptdraw
记忆是靠不住的,会自然淘汰长时间不用的数据,一旦需要重新加载,如果从0开始那成本就太高了,而笔记和思维导图是自己思考方式的组织的,可以快速加载;
下面这些内容零零散散记录了很久,当时记录的时候可能还是新东西,过了那么久新东西也都成常识了,算不得"新"了;删之可惜,继续放在Erlang杂记里面吧,无论如何都是一个知识积累的记录;另外,分享记录还可以发现盲点,比如下面代码就是我曾经的盲点之一,我曾经使用非常绕的方法解决ETS进程依赖Shell进程的问题,很快就有朋友指出其实只需要执行下catch_exception(true)就可以搞定.
Eshell V6.0 (abort with ^G)
1> self().
<0.33.0>
2> 1/0.
** exception error: an error occurred when evaluating an arithmetic expression
in operator '/'/2
called as 1 / 0
3> self(). %% 注意这里 已经重启
<0.36.0>
4> catch_exception(true).
false
5> 1/0.
* exception error: an error occurred when evaluating an arithmetic expression
in operator '/'/2
called as 1 / 0
6> self().
<0.36.0>
7>
Eshell V6.0 (abort with ^G)
1> catch_exception(true).
false
2> ets:new(test,[named_table]).
test
3> [ ets:insert(test,{N,1,1,2}) || N <- lists:seq(1,10) ].
[true,true,true,true,true,true,true,true,true,true]
4>
4> ets:info(test).
[{compressed,false},
{memory,389},
{owner,<0.33.0>},
{heir,none},
{name,test},
{size,10},
{node,nonode@nohost},
{named_table,true},
{type,set},
{keypos,1},
{protection,protected}]
5> ets:new(test2,[named_table,compressed]).
test2
6> [ ets:insert(test2,{N,1,1,2}) || N <- lists:seq(1,10) ].
[true,true,true,true,true,true,true,true,true,true]
7>
7> ets:info(test2).
[{compressed,true},
{memory,399},
{owner,<0.33.0>},
{heir,none},
{name,test2},
{size,10},
{node,nonode@nohost},
{named_table,true},
{type,set},
{keypos,1},
{protection,protected}]
Eshell V6.0 (abort with ^G)
1> catch_exception(true).
false
2> ets:new(t,[named_table]).
t
3> [ ets:insert(t,{N,[1,1,2],[a,b],{2,1,1024}}) || N <- lists:seq(1,100000) ].
[true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true|...]
4> ets:info(t).
[{compressed,false},
{memory,2314637},
{owner,<0.33.0>},
{heir,none},
{name,t},
{size,100000},
{node,nonode@nohost},
{named_table,true},
{type,set},
{keypos,1},
{protection,protected}]
5> ets:new(t2,[named_table,compressed]).
t2
6> [ ets:insert(t2,{N,[1,1,2],[a,b],{2,1,1024}}) || N <- lists:seq(1,100000) ].
[true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true|...]
7> [ ets:insert(t2,{N,[1,1,2],[a,b],{2,1,1024}}) || N <- lists:seq(1,100000) ].
[true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true,true,true,true,true,true,true,
true,true,true,true,true,true|...]
8> ets:info(t2).
[{compressed,true},
{memory,1414637},
{owner,<0.33.0>},
{heir,none},
{name,t2},
{size,100000},
{node,nonode@nohost},
{named_table,true},
{type,set},
{keypos,1},
{protection,protected}]
9>
-module(a).
-compile(export_all).
v()-> 1.0. Eshell V6.0 (abort with ^G)
1> c(a).
{ok,a}
2> a:v().
1.0
3> c(a). %% 代码已经修改过了
{ok,a}
4> erlang:check_old_code(a).
true
5> a:v().
2.0
6>
7> B= <<"binary_test_demo">>.
<<"binary_test_demo">>
8> erlang:external_size(B).
27
9> byte_size(B).
16
10>
{one,new,two,three}
> erlang:delete_element(2, {one, two, three}).
{one,three}
> float_to_list(7.12, [{decimals, 4}]).
"7.1200"
> float_to_list(7.12, [{decimals, 4}, compact]).
"7.12"
> float_to_binary(7.12, [{decimals, 4}]).
<<"7.1200">>
> float_to_binary(7.12, [{decimals, 4}, compact]).
<<"7.12">>
13> erlang:binary_to_integer(<<"10204">>).
10204
14> erlang:integer_to_binary(10204).
<<"10204">>
15>
2053
17>
1> Color = 16#F09A29.
15768105
2> Pixel = <<Color:24>>.
<<240,154,41>>
1> io:printable_range().
unicode
2> io:format("~tp",["开心"]).
"开心"ok
The simplest approach is to make an a-priori restriction to the TCP
ports distributed Erlang uses to communicate through by setting the
(undocumented) kernel variables 'inet_dist_listen_min' and
'inet_dist_listen_max':
application:set_env(kernel, inet_dist_listen_min, 9100).
application:set_env(kernel, inet_dist_listen_max, 9105).
traffic.
[Erlang 0118] Erlang 杂记 V的更多相关文章
- [Erlang 0129] Erlang 杂记 VI
把之前阅读资料的时候记下的东西,整理了一下. Adding special-purpose processor support to the Erlang VM P23 简单介绍了Erlang C ...
- [Erlang 0124] Erlang Unicode 两三事 - 补遗
最近看了Erlang User Conference 2013上patrik分享的BRING UNICODE TO ERLANG!视频,这个分享很好的梳理了Erlang Unicode相关的问题,基本 ...
- [Erlang 0122] Erlang Resources 2014年1月~6月资讯合集
虽然忙,有些事还是要抽时间做; Erlang Resources 小站 2014年1月~6月资讯合集,方便检索. 小站地址: http://site.douban.com/204209/ ...
- [Erlang 0105] Erlang Resources 小站 2013年1月~6月资讯合集
很多事情要做,一件一件来; Erlang Resources 小站 2013年1月~6月资讯合集,方便检索. 小站地址: http://site.douban.com/204209/ ...
- Erlang 103 Erlang分布式编程
Outline 笔记系列 Erlang环境和顺序编程Erlang并发编程Erlang分布式编程YawsErlang/OTP 日期 变更说明 2014-11-23 A Outl ...
- [Erlang 0057] Erlang 排错利器: Erlang Crash Dump Viewer
http://www.cnblogs.com/me-sa/archive/2012/04/28/2475556.html Erlang Crash Dump Viewer真的是排错的天兵神器,还记得我 ...
- [Erlang 0107] Erlang实现文本截断
抽时间处理一下之前积压的一些笔记.前段时间有网友 @稻草人 问字符串截断的问题"各位大侠 erlang截取字符串一般用哪个函数啊",有人支招用string:substr/3, ...
- [Erlang 0106] Erlang实现Apple Push Notifications消息推送
我们的IOS移动应用要实现消息推送,告诉用户有多少条消息未读,类似下图的效果(笑果),特把APNS和Erlang相关解决方案笔记于此备忘. 上面图片中是Apple Notif ...
- [erlang 001] erlang中的错误及异常处理
一. erlang中的错误 1. 分类 1) 编译错误:主要是编译器检测出的代码语法错误: 2) 逻辑错误:是指程序没有完成预期的工作,属于开发人员的问题: 3) 运行时错误:是指erlang运行时抛 ...
随机推荐
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- 访问IIS网站需要输入用户名密码(非匿名登录)问题汇总
无语了,最近不少Windows服务器都出现这个访问网站需要输入的问题,而且每次解决方法还不一样...唉,先汇总下解决方法吧,有时间再仔细研究下这些问题是如何导致的. 当IIS已启用"允许匿名 ...
- DOM getElementsByClassName IE兼容方案
平时写HTML时多用class来命名,为很少用id来命名,主要原因就是class使用起来比较灵活. 但是万恶的JS在操作DOM的时候对ie6+只提供了getElementById和getElement ...
- WCF学习之旅—请求与答复模式和单向模式(十九)
一.概述 WCF在通信过程中有三种模式:请求与答复.单向.双工通信.以下我们一一介绍. 二.请求与答复模式 客户端发送请求,然后一直等待服务端的响应(异步调用除外),期间处于假死状态,直到服务端有了答 ...
- SQL-从数据类型 varchar 转换为 bigint 时出错的解决方案
解决
- 了解HTML列表
前面的话 从某种意义上讲,不是描述性文本的任何内容都可以认为是列表.人口普查.太阳系.餐馆菜单等都可以表示为一个列表或列表的列表.列表分为无序列表.有序列表和定义列表三种 无序列表 无序列表(unor ...
- Linux文件系统的实现
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! Linux文件管理从用户的层面介绍了Linux管理文件的方式.Linux有一个树状 ...
- scikit-learn Adaboost类库使用小结
在集成学习之Adaboost算法原理小结中,我们对Adaboost的算法原理做了一个总结.这里我们就从实用的角度对scikit-learn中Adaboost类库的使用做一个小结,重点对调参的注意事项做 ...
- 搞定.NET MVC IOC控制反转,依赖注入
一直听说IOC,但是一直没接触过,只看例子好像很高达上的样子,今天抽了点时间实现了下,当然也是借助博客园里面很多前辈的文章来搞的!现在做个笔记,防止自己以后忘记! 1.首先创建MVC项目 2.然后新建 ...
- dagger2系列之生成类实例
上一节的最后,我讲到一次注入生成类实例的生成步骤.先来回顾一下: 1 Module中存在创建方法,则看此创建方法有没有参数 如果有参数,这些参数也是由Component提供的,返回步骤1逐一生成参数 ...