c(translate_service).
Service = spawn(fun translate_service:watch_loop/0).
Service ! new.
translate_service:translate(translator, "casa").
translate_service:translate(translator, "blanca").
translate_service:translate(translator, "incorrect").
translate_service:translate(translator, "casa").
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Defines the basic module | |
-module(basic). | |
% Expose the example/1 function through the module | |
-export([example/1]). | |
% Defines the actual mirror function, which returns the first argument | |
example(Anything) -> Anything. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(count). | |
-export([to_ten/0]). | |
%Assignment: Write a function that uses recursion to count to ten. | |
%Entrypoint | |
to_ten() -> count(0). | |
% Base case | |
count(10) -> 10; | |
%keep on adding 1 untill you reach the above function | |
count(Value) -> count(Value + 1). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(print_err_success). | |
-export([print/1]). | |
%Assignment: Write a function that uses matching to selectively print “success” or “error: message” given input of the form {error, Message} or success. | |
%Simple return Success String. | |
print(success) -> "Success"; | |
%Error message. The '++' concatenates the two strings. | |
print({error, Message}) -> "Error: " ++ Message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- module(key_lookup). | |
- export([search/2]). | |
%Assignment: Consider a list of keyword-value tuples, such as [{erlang, "a functional language"}, {ruby, "an OO language"}]. Write a function that accepts the list and a keyword and returns the associated value for the keyword. | |
search(Key, List) -> do_search(Key, List). | |
%With the use of pattern matching we are able to have the do_search1 return once we | |
%hit the result. | |
do_search(Key, [{Key, Value}|_]) -> | |
io:fwrite("do_search1 Keyword(~p) Value(~p)\n", [Key, Value]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"Beer", 2.50, 8}, {"Snacks", 1.99, 4}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(problem1). | |
-export([solve/0]). | |
%Assignment: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
%Find the sum of all the multiples of 3 or 5 below 1000. | |
solve() -> | |
solve(1, 0). | |
solve(Number, Sum) when Number == 1000 -> | |
Sum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SSH into the machine | |
ssh -i "aws-rancher.pem" rancher@ec2-00-158-000-000.eu-central-1.compute.amazonaws.com | |
#To switch to a Docker version supported by k8s. | |
#http://rancher.com/docs/rancher/v1.6/en/hosts/#supported-docker-versions | |
sudo ros engine switch docker-1.12.6 | |
#Install Rancher | |
#http://rancher.com/docs/rancher/v1.6/en/installing-rancher/installing-server/ | |
sudo docker run -d -v /home/rancher/mysql:/var/lib/mysql --restart=unless-stopped -p 8080:8080 rancher/server |
-
Setup your socks proxy. In my case I'm creating a socks proxy by creating a secure shell connection (SSH): ssh iain@8.8.4.4 -D 9050
-
(Optional for mac users): You can also simplify this action by using a lovely (free) application called Secure Pipes: https://www.opoet.com/pyro/
-
Download delegate and move the executable (dg9_9_13) into /usr/local/sbin or /usr/bin. Example:
cp dg9_9_13/DGROOT/bin/dg9_9_13 /usr/local/sbin/delegate
chmod +x /usr/local/sbin/delegate
OlderNewer