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
// ########################################## | |
// GENERATING KEYS | |
// ########################################## | |
my_user_id = "John Test <john_test@someserver.com>"; | |
my_passphrase = "123qwe"; // Key Pairs is always protected with a password to safety. | |
my_key = openpgp.generateKeyPair({numBits: 1024, userId: my_user_id, passphrase: my_passphrase}); | |
// My Private Key String | |
console.log("My private key:\n\n" + my_key.privateKeyArmored + "\n\n"); |
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
defmodule Math do | |
def zero?(0) do | |
true | |
end | |
def zero?(x) when is_integer(x) do | |
false | |
end | |
end |
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
defmodule Recursion do | |
def print_multiple_times(msg, n) when n <= 1 do | |
IO.puts msg | |
end | |
def print_multiple_times(msg, n) do | |
IO.puts msg | |
print_multiple_times(msg, n - 1) | |
end | |
end |
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
defmodule Math do | |
def sum_list([head | tail], accumulator) do | |
sum_list(tail, head + accumulator) | |
end | |
def sum_list([], accumulator) do | |
accumulator | |
end | |
end |
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
:: Elixir study notes. | |
# get some help: | |
iex> i 'hello' | |
Term | |
'hello' | |
Data type | |
List | |
Description | |
... |
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
def print_msg_n_times(msg, n) | |
n.times do | |
puts msg | |
end | |
end | |
print_msg_n_times('Hello world', 6_000) |
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
defmodule Math do | |
def sum_list(list, accumulator \\ 0) | |
def sum_list([head | tail], accumulator) do | |
sum_list(tail, head + accumulator) | |
end | |
def sum_list([], accumulator) do | |
accumulator | |
end |
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
defmodule Triple do | |
def pythagorean(n) when n > 0 do | |
for a <- 1..n, | |
b <- 1..n, | |
c <- 1..n, | |
do: IO.puts "#{a} #{b} #{c}" | |
end | |
end | |
Triple.pythagorean(10) |
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
# Challenge 1: Given a list of integers, create a module that maps that list | |
# into different processes. Deliver to those processes the element and a | |
# function to be performed with it. This function can be anything, for | |
# instance: "Returns square of the number". Finally each process shoud send | |
# a message to the spawning process with the result. | |
defmodule Spawner do | |
@moduledoc """ | |
Maps a list into processes performing a given function. Each one sends a | |
message to the spawning process, this one uses the IO module to print it out. |
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
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
if [[ $UID -eq 0 ]]; then | |
local user_host='%{$terminfo[bold]$fg[red]%}%n@%m%{$reset_color%}' | |
local user_symbol='#' | |
else | |
local user_host='%{$terminfo[bold]$fg[grey]%}%n@%m%{$reset_color%}' | |
local user_symbol='$' | |
fi |
OlderNewer