Skip to content

Instantly share code, notes, and snippets.

View tecnowilliam's full-sized avatar

tecnowilliam tecnowilliam

View GitHub Profile
% Compile: c(gs_frequency).
-module(gs_frequency).
-author("William Vargas").
-version("1.0").
-behaviour(gen_server).
% API
-export([start_link/0, get/0, add/1, allocate/0, deallocate/1, reset/0, stop/0]).
% gen_server
% Compile: c(frequency).
-module(frequency).
-author("William Vargas").
-version("1.0").
-export([init/2, start/2]).
% Register the server as frequency_hardened
-spec start(atom(), list(integer())) -> pid().
start(Process, Frequencies) ->
AL-COL-15761:hot code upgrade williamvargas$ erl
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V9.1 (abort with ^G)
1>
1>%% Copy the frequency1.erl to frequency.erl
1> os:cmd("cp frequency1.erl frequency.erl").
[]
2> %% Compile the frenquency module
2> c(frequency).
% Compile: c(frequency_hardened).
-module(frequency_hardened).
-author("William Vargas").
-version("1.0").
-export([init/0, start/0, stop/0, allocate/0, deallocate/1, tests/0]).
% Register the server as frequency_hardened
-spec start() -> ?MODULE.
start() ->
% Compile: c(echo).
-module(echo).
-export([listener/0]).
-author("William Vargas").
-version("1.0").
-spec listener() -> any().
listener() ->
case rand:uniform(10) of
% Compile: c(frequency_hardened).
-module(frequency_hardened).
-author("William Vargas").
-version("1.0").
-export([init/0, start/0, stop/0, allocate/0, deallocate/1, tests/0]).
% Register the server as frequency_hardened
-spec start() -> ?MODULE.
start() ->
% Compile: c(frequency).
-module(frequency).
-author("William Vargas").
-version("1.0").
-export([init/0, start/0, allocate/0, deallocate/1, tests/0]).
% Register the server as frequency
-spec start() -> frequency.
% Compile: c(mailbox).
-module(mailbox).
-author("William Vargas").
-version("1.0").
-export([receiver/0, receiver_seq/0, tests/0]).
receiver() ->
timer:sleep(1000),
receive
% Compile: c(palin).
% Start the server: Server = spawn(palin,server,[self()]).
% Display the messages in the terminal: flush().
-module(palin).
-author("William Vargas").
-version("1.0").
-export([tests/0, check/1, server/1]).
-spec remove_punctuation(string()) -> list(string()).
% Compile:
% c(rpss).
-module(rpss).
-author("William Vargas").
-version("1.0").
-export([
play/1,
echo/1,
play_two/3,
rock/1,