我在知乎回答问题不多,这个问题: "对你职业生涯帮助最大的习惯是什么?它是如何帮助你的?",我还是主动回答了一下.
 

 做笔记

  1. 一开始笔记软件做的不好的时候就发邮件给自己,然后不断的回顾更新笔记;
  2. 后来用OneNote,由于这玩意当时不是云同步的,硬盘坏掉的时候丢了一些数据,打击还是挺大,好多事情要从头开始
  3. 再后来用过一段时间Google Wave,还以和朋友分享讨论笔记,结果,你们知道关闭服务了,费力导出来
  4. 现在转战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>

  

    比起"你应该知道的XX","你必须知道的XX","原来你不知道XX","XX原来可以这样用","你可能不知道的XX",这些名字,"Erlang杂记"这个不招摇的名字能让我们更关注内容而不是纠结于"谁说我不知道了,你才不知道呢,就你知道",当然了"XX的76个原则"这种伪装人生导师颐指气使的鸡汤标题就更惹人厌了.
 
 
ETS 数据压缩
 
版本: R14B01 ERTS5.8.2
   compressed If this option is present, the table data will be stored in a more compact format to consume less memory. The downside is that it will make table operations slower. Especially operations that need to inspect entire objects, such as match and select, will get much slower. The key element is not compressed in current implementa
 
  如果使用了compressed选项,表数据在内存中会更紧密的排列,占用更少的内存.代价就是一些操作变慢,比如match,select.另外,因为压缩本身的开销,数据量不大的情况下做压缩可能适得其反,下面的第一个例子就是这样,test2表在压缩之后占用内存反而多了.目前的版本中Key没有做压缩.官方曾表示对于复杂数据可以达到50%甚至更高的压缩比.如果全局应用压缩策略可以使用 erl +ec 
 
 

 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>
检查是否有旧版本的代码
 
R14B04 Erts 5.8.5 添加
 
-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>

  

erlang:external_size
 
R14B04 Erts 5.8.5 添加
 
erlang:external_size(Term) -> integer() >= 0

7> B= <<"binary_test_demo">>.
<<"binary_test_demo">>
8> erlang:external_size(B).
27
9> byte_size(B).
16
10>

 

process_limit
 
Returns the maximum number of simultaneously existing processes at the local node as an integer. This limit can be configured at startup by using the +P command line flag of erl(1).
 
The previous default of a maximum of 32768 simultaneous processes has been raised to . 
 
 
 
Tuple insert_element delete_element
 
 erlang:insert_element(2, {one, two, three}, new).
{one,new,two,three}
> erlang:delete_element(2, {one, two, three}).
{one,three}
 
 
float integer
 
> 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>

  

 
Non-blocking code loading. Erts 5.10
 
  Earlier when an Erlang module was loaded, all other execution in the VM were halted while the load operation was carried out in single threaded mode. Now modules are loaded without blocking the VM. Processes may continue executing undisturbed in parallel during the entire load operation. The load operation is completed by making the loaded code visible to all processes in a consistent way with one single atomic instruction. Non-blocking code loading will improve realtime characteristics when modules are loaded/upgraded on a running SMP system.
这个有意思,后面我会做更详细的梳理.
 
Runtime's maximum number of ETS tables.  
Erts 5.10.4
16> erlang:system_info(ets_limit) .
2053
17> 
 
 
颜色RGB 表示与16进制表示转换
 
这个并没有什么难度,只是提醒想想问题的本质是什么,是不是手头的工具就可以搞定

1> Color = 16#F09A29.
15768105
2> Pixel = <<Color:24>>.
<<240,154,41>>

  

 
 
 
io:printable_range
 
This flag affects what is interpreted as string data when doing heuristic string detection in the shell and in io/io_lib:format with the "~tp" and ~tP formatting instructions, as described above. [Doc]
 
[root@nimbus record]# erl  +pc unicode

Eshell V6.0  (abort with ^G)
1> io:printable_range().
unicode
2> io:format("~tp",["开心"]).
"开心"ok
2014-4-19 11:41:35补充
 
Run distributed Erlang through a firewall? 
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).
 
This forces Erlang to use only ports 9100--9105 for distributed Erlang 
traffic. 
 
 好,就到这里吧,昨天儿子闹了一晚上,今天真累了,晚安!

[Erlang 0118] Erlang 杂记 V的更多相关文章

  1. [Erlang 0129] Erlang 杂记 VI

    把之前阅读资料的时候记下的东西,整理了一下. Adding special-purpose processor support to the Erlang VM   P23 简单介绍了Erlang C ...

  2. [Erlang 0124] Erlang Unicode 两三事 - 补遗

    最近看了Erlang User Conference 2013上patrik分享的BRING UNICODE TO ERLANG!视频,这个分享很好的梳理了Erlang Unicode相关的问题,基本 ...

  3. [Erlang 0122] Erlang Resources 2014年1月~6月资讯合集

    虽然忙,有些事还是要抽时间做; Erlang Resources 小站 2014年1月~6月资讯合集,方便检索.      小站地址: http://site.douban.com/204209/   ...

  4. [Erlang 0105] Erlang Resources 小站 2013年1月~6月资讯合集

    很多事情要做,一件一件来; Erlang Resources 小站 2013年1月~6月资讯合集,方便检索.      小站地址: http://site.douban.com/204209/     ...

  5. Erlang 103 Erlang分布式编程

    Outline 笔记系列 Erlang环境和顺序编程Erlang并发编程Erlang分布式编程YawsErlang/OTP 日期              变更说明 2014-11-23 A Outl ...

  6. [Erlang 0057] Erlang 排错利器: Erlang Crash Dump Viewer

    http://www.cnblogs.com/me-sa/archive/2012/04/28/2475556.html Erlang Crash Dump Viewer真的是排错的天兵神器,还记得我 ...

  7. [Erlang 0107] Erlang实现文本截断

       抽时间处理一下之前积压的一些笔记.前段时间有网友 @稻草人 问字符串截断的问题"各位大侠 erlang截取字符串一般用哪个函数啊",有人支招用string:substr/3, ...

  8. [Erlang 0106] Erlang实现Apple Push Notifications消息推送

        我们的IOS移动应用要实现消息推送,告诉用户有多少条消息未读,类似下图的效果(笑果),特把APNS和Erlang相关解决方案笔记于此备忘.          上面图片中是Apple Notif ...

  9. [erlang 001] erlang中的错误及异常处理

    一. erlang中的错误 1. 分类 1) 编译错误:主要是编译器检测出的代码语法错误: 2) 逻辑错误:是指程序没有完成预期的工作,属于开发人员的问题: 3) 运行时错误:是指erlang运行时抛 ...

随机推荐

  1. CSS currentColor 变量的使用

    CSS中存在一个神秘的变量,少有人知自然也不怎么为人所用.它就是crrentColor变量(或者说是CSS关键字,但我觉得称为变量好理解些). 初识 它是何物?具有怎样的功效?它从哪里来?带着这些疑问 ...

  2. ABP源码分析三十七:ABP.Web.Api Script Proxy API

    ABP提供Script Proxy WebApi为所有的Dynamic WebApi生成访问这些WebApi的JQuery代理,AngularJs代理以及TypeScriptor代理.这些个代理就是j ...

  3. C#中,switch case语句中多个值匹配一个代码块的写法

    switch (num) { case 1: Response.Write("1"); break; case 2: case 3: Response.Write("2| ...

  4. linux shell 中的sleep命令

    开始还以为是这样的语法: sleep(1), 后面发现是: linux shell 中的sleep命令 分类: LINUX 在有的shell(比如linux中的bash)中sleep还支持睡眠(分,小 ...

  5. SQL Server 阻止了对组件“xp_cmdshell”的 过程“sys.xp_cmdshell”的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。

    今天在创建数据库的时候突然发现,xp_cmdshell的存储过程不能用了,网上一搜,发现大部分都是只关闭安全配置,然后就有了下文 代码:具体的看注释,值得一提的是==>reconfigure w ...

  6. JS事件调试 - 查找HTML元素绑定的事件以及绑定代码所在位置

    日常的网页开发调试工作中,经常需要知道指定的某个网页元素绑定了哪些事件以及绑定代码的位置,下面介绍三种用来跟踪页面中的事件的方法. 1.使用firefox调试 我们可以使用firefox的debug工 ...

  7. 学习笔记之(console)

    今天小颖在逛博客园时,发现一位帅锅写的有意思的Console小颖看了后,就自己敲了一遍嘻嘻,为了方便以后查看,小颖把它记录下来嘻嘻,有兴趣的小伙伴也可以自己试试哦. 格式占位符 作用 %s 字符串 % ...

  8. ASP.NET MVC5+EF6+EasyUI 后台管理系统(52)-美化EasyUI皮肤和图标

    系列目录 我很久以前就想更新系统的皮肤功能,Easyui 自带的皮肤已经无法满足客户的审美. 皮肤颜色来源于AdminLTE系统.我的颜色全部都这里取的.,所以一共取了11个颜色.1个皮肤=2个ban ...

  9. 趣说游戏AI开发:对状态机的褒扬和批判

    0x00 前言 因为临近年关工作繁忙,已经有一段时间没有更新博客了.到了元旦终于有时间来写点东西,既是积累也是分享.如题目所示,本文要来聊一聊在游戏开发中经常会涉及到的话题--游戏AI.设计游戏AI的 ...

  10. c#编程基础之函数可变参数

    可变参数:int sum (params int[] values)int sum (string name,params int[] values) 注意:params参数必须是形参表中的最后一个参 ...