Devoutsin's Home

生命就像一条大河,时而宁静时而疯狂


  • 首页

  • 归档

  • 标签

  • 分类

小试牛刀微信小程序

发表于 2018-01-01 | 分类于 技术

注册小程序AppID

1.用一个没有注册过微信公共帐号平台的邮箱注册小程序

微信公众平台

2.下载官方的开发工具

开发者工具下载页面

3.打开开发工具

3.1选择一个空的目录作为小程序代码存放目录

3.2给小程序起一个骚气的名字
...

go-1.7版本崩溃问题

发表于 2017-12-13 | 分类于 技术

近期线上的一台机器突然挂掉,发现crash:fatal error: sweep increased allocation count

这是1.7版本存在的一个问题,参考: golang/go

gen_server模板

发表于 2015-05-16 | 分类于 技术

gen_server代码模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% gen_server代码模板
-module(new_file).

-behaviour(gen_server).
% --------------------------------------------------------------------
% Include files
% --------------------------------------------------------------------

% --------------------------------------------------------------------
% External exports
-export([]).

% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

-record(state, {}).



% --------------------------------------------------------------------
% Function: init/1
% Description: Initiates the server
% Returns: {ok, State} |
% {ok, State, Timeout} |
% ignore |
% {stop, Reason}
% --------------------------------------------------------------------
init([]) ->
{ok, #state{}}.

% --------------------------------------------------------------------
% Function: handle_call/3
% Description: Handling call messages
% Returns: {reply, Reply, State} |
% {reply, Reply, State, Timeout} |
% {noreply, State} |
% {noreply, State, Timeout} |
% {stop, Reason, Reply, State} | (terminate/2 is called)
% {stop, Reason, State} (terminate/2 is called)
% --------------------------------------------------------------------
handle_call(Request, From, State) ->
Reply = ok,
{reply, Reply, State}.

% --------------------------------------------------------------------
% Function: handle_cast/2
% Description: Handling cast messages
% Returns: {noreply, State} |
% {noreply, State, Timeout} |
% {stop, Reason, State} (terminate/2 is called)
% --------------------------------------------------------------------
handle_cast(Msg, State) ->
{noreply, State}.

% --------------------------------------------------------------------
% Function: handle_info/2
% Description: Handling all non call/cast messages
% Returns: {noreply, State} |
% {noreply, State, Timeout} |
% {stop, Reason, State} (terminate/2 is called)
% --------------------------------------------------------------------
handle_info(Info, State) ->
{noreply, State}.

% --------------------------------------------------------------------
% Function: terminate/2
% Description: Shutdown the server
% Returns: any (ignored by gen_server)
% --------------------------------------------------------------------
terminate(Reason, State) ->
ok.

% --------------------------------------------------------------------
% Func: code_change/3
% Purpose: Convert process state when code is changed
% Returns: {ok, NewState}
% --------------------------------------------------------------------
code_change(OldVsn, State, Extra) ->
{ok, State}.

erlang beam文件反编译成erl源文件

发表于 2015-05-07 | 分类于 技术

erlc带debug_info参数编译erl文件生成beam里面包含了debug信息,
所以可以通过debug版本的beam反编译生成erl文件。

例如sum.beam是带debug编译好的beam文件,反编译步骤如下:
{ok, {_, [{abstract_code, {_, Ac}}]}} = beam_lib:chunks(code:which(sum), [abstract_code]).
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(Ac))]).
这样我们就得到的sum.beam的预处理之后的程序。
如果我们想查看beam文件的汇编程序erts_debug:df(sum). 执行完毕会得到sum.dis文件,里面就是对应的汇编代码。

所以生成debug的beam文件是很不安全的,不过可以生成加密的debug信息,这样别人拿到这些beam也无法反编译生成erl文件
方法:
在rebar.config文件的debug_info中加上{debug_info_key,{des3_cbc,”your secret key”}编译选项

参考erlang.org

ejabberd删除好友bug

发表于 2014-06-10 | 分类于 技术

ejabberd删除好友bug

make_jid的参数Item#roster.jid是一个<"yangrong@localhost">binary类型,造成函数条款不匹配的错误,应该使用string_to_jid。

ejabberd删除好友bug

这块取消订阅是有一方取消之后,双方关系都解除,之前测试只是谁取消订阅删除谁的记录,是因为这块bug引起的,导致unsubscribe消息没有推送出去,把这块代码注释掉是为了实现半删除。

Devoutsin's Home

发表于 2013-05-01

我会喜欢这里

Devoutsin

6 日志
1 分类
3 标签
RSS
GitHub
© 2013 — 2018 Devoutsin
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.3