Skip to content

Commit

Permalink
more notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrsk committed Oct 11, 2024
1 parent 44b4acc commit 634a896
Show file tree
Hide file tree
Showing 30 changed files with 345 additions and 77 deletions.
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ assetDir = "static"
blog = "/blog/:year/:slug/"
notes = "/notes/:year/:slug/"

[taxonomies]
category = 'categories'
tag = 'tags'

[mediaTypes."application/atom+xml"]
suffixes = ["xml"]
Expand Down
34 changes: 22 additions & 12 deletions content-org/content.org
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ This is the place where I dump my [[https://www.orgroam.com/][Org ROAM]] notes.

#+RESULTS: export-notes

** Gen Server
:PROPERTIES:
:EXPORT_FILE_NAME: gen-server
:EXPORT_DATE: 2024-10-10
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :slug gen-server
:CUSTOM_ID: gen-server
:END:

#+INCLUDE: "../notes/20241010094109-gen_server.org"


** Erlang Ets
:PROPERTIES:
:EXPORT_FILE_NAME: erlang-ets
:EXPORT_DATE: 2024-10-10
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :slug erlang-ets
:CUSTOM_ID: erlang-ets
:END:

#+INCLUDE: "../notes/20241010093430-erlang_ets.org"


** Relational Theory
:PROPERTIES:
:EXPORT_FILE_NAME: relational-theory
Expand Down Expand Up @@ -516,17 +538,6 @@ This is the place where I dump my [[https://www.orgroam.com/][Org ROAM]] notes.
#+INCLUDE: "../notes/20240709110323-designing_for_scalability_with_erlang.org"


** Programming Erlang
:PROPERTIES:
:EXPORT_FILE_NAME: programming-erlang
:EXPORT_DATE: 2024-07-06
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :slug programming-erlang
:CUSTOM_ID: programming-erlang
:END:

#+INCLUDE: "../notes/20240706213027-programming_erlang.org"


** Monad
:PROPERTIES:
:EXPORT_FILE_NAME: monad
Expand Down Expand Up @@ -812,4 +823,3 @@ This is the place where I dump my [[https://www.orgroam.com/][Org ROAM]] notes.

#+INCLUDE: "../notes/20211012215602-kubernetes.org"


2 changes: 0 additions & 2 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
{{ if .Param "libs" }}
{{ partialCached "libs.html" . }}
{{ end }}
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"></script>
</head>
<body>
{{- partial "nav.html" -}}
Expand Down
12 changes: 12 additions & 0 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Data.Terms.Alphabetical }}
<h2><a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a> ({{ .Count }})</h2>
<ul>
{{ range .WeightedPages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/graph.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions layouts/partials/libs.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script type="text/javascript" src ="https://d3js.org/d3.v7.min.js"></script>
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script>
MathJax = {
Expand Down
2 changes: 1 addition & 1 deletion notes/20211104221056-history_of_logic.org
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:PROPERTIES:
:ID: 0c082d02-4771-4860-8119-83b263c00ff3
:END:
#+title: History-of-Logic
#+title: History of Logic

Notes from the book "History of Logic: from Aristotle to Tarski".

Expand Down
4 changes: 2 additions & 2 deletions notes/20211107141903-the_effective_manager.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
:ID: 32b2fe5a-3bc3-439b-a850-70a539498e9e
:END:
#+title: The Effective Manager
#+HUGO_CATEGORIES: "Management"
#+HUGO_TAGS: "Books"
#+HUGO_CATEGORIES: "Leadership"
#+HUGO_TAGS: "Management"

Notes from the [cite:@horstman2023effective].

Expand Down
4 changes: 2 additions & 2 deletions notes/20230411100120-managing_a_programming_project.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
:ID: da4d5031-66cb-4d1c-b8cf-24d12adf5c17
:END:
#+title: Managing a Programming Project
#+HUGO_CATEGORIES: "Management"
#+HUGO_TAGS: "Books"
#+HUGO_CATEGORIES: "Leadership"
#+HUGO_TAGS: "Management"

Notes from [cite:@metzger1996].

Expand Down
48 changes: 0 additions & 48 deletions notes/20240706213027-programming_erlang.org

This file was deleted.

8 changes: 7 additions & 1 deletion notes/20240715225258-type_driven_development.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
:END:
#+title: Type-Driven Development with Idris
#+HUGO_CATEGORIES: "Functional Programming"
#+HUGO_TAGS: "Idris" "Type-Driven Development"
#+HUGO_TAGS: "Idris"

#+BEGIN_QUOTE
Idris is a pure [[id:171718cd-10fd-484b-8d77-0ffcffc29163][Functional Programming]] language with [[id:7580b45a-1dba-4690-bfbf-652fee25e1d9][Dependent Types]]
#+END_QUOTE

+ References:
+ [cite:@brady2017]

#+print_bibliography:
34 changes: 34 additions & 0 deletions notes/20240924122449-sequential_erlang.org
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,38 @@ If we want additional control structures, we can make our own. Erlang has no for
mps_to_kph(Mps) -> 3.6 * Mps.
#+END_SRC

* Error Handling in Sequential Programs

#+BEGIN_SRC erlang
try FuncOrExpressionSeq of
Pattern1 [when Guard1] -> Expressions1;
Pattern2 [when Guard2] -> Expressions2;
...
catch
ExceptionType1: ExPattern1 [when ExGuard1] -> ExExpressions1;
ExceptionType2: ExPattern2 [when ExGuard2] -> ExExpressions2;
...
after
AfterExpressions
end
#+END_SRC

+ ~exit/1~ :: Used to terminate the current process.
+ ~throw~ :: Used as a documentation to the caller, to show that a function might throw this exception.
+ error :: Crashing errors.

*** Fail Fast and Noisily, Fail Politely

#+BEGIN_QUOTE
In Erlang, when an error is detected internally by the system or is detected by
program logic, the correct approach is to crash immediately and generate a
meaningful error message.

(...)

Second, fail politely means that only the programmer should see the detailed
error messages produced when a program crashes. A user of the program should
never see these messages.
#+END_QUOTE

#+print_bibliography:
84 changes: 82 additions & 2 deletions notes/20240930224229-concurrent_erlang.org
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
:PROPERTIES:
:ID: 63607e63-4428-4578-bf2a-12a49649b49c
:ROAM_ALIAS: "Erlang Process"
:END:
#+title: Concurrent Erlang
#+HUGO_CATEGORIES: "Functional Programming"
#+HUGO_TAGS: "Erlang"
#+STARTUP: inlineimages

* Processes

Expand All @@ -16,13 +16,45 @@ identifier (PID) that can used to interact with the newly created process:
Pid = spawn(ModName, FuncName, [Arg1, Arg2, ..., ArgN]).
#+END_SRC

#+NAME: erlang-spawn
#+BEGIN_SRC dot :file ../static/img/notes/erlang_spawn.png :cmdline -Kdot -Tpng :exports results
digraph Spawn {
node [shape=circle];
sep = 1;

pid1 [label="Pid 1", fontsize="10pt", style=filled, fillcolor=grey];
pid2 [label="Pid 2", xlabel="Mod:Func(Args)", fontsize="10pt", style=filled, fillcolor=red];

pid1 -> pid2 [label=" Spawn(Mod, Func, Args)", fontsize="10pt", minlen=1, style=dashed];
}
#+END_SRC

#+RESULTS: erlang-spawn
[[file:../static/img/notes/erlang_spawn.png]]

+ This BIF never fails
+ A process can either terminate:
* Abormally when run-time errors occur
* Normally when there is no more code to execute

** Modeling Concurrency

#+NAME: erlang-send
#+BEGIN_SRC dot :file ../static/img/notes/erlang_send.png :cmdline -Kdot -Tpng :exports results
digraph Send {
node [shape=circle];
rankdir="LR";

pid1 [label="Pid 1", xlabel="Pid2 ! { self(), hello }", fontsize="10pt", style=filled, fillcolor=grey];
pid2 [label="Pid 2", fontsize="10pt", style=filled, fillcolor=red, xlabel="receive (...) end." ];

pid1 -> pid2 [label="{ Pid1, hello }", fontsize="10pt", style=dashed];
}
#+END_SRC

#+RESULTS: erlang-send
[[file:../static/img/notes/erlang_send.png]]

The syntax ~Pid ! Msg~ means "send the message ~Msg~ to the process ~Pid~", where ~Msg~
is from any valid [[id:de7d0e94-618f-4982-b3e5-8806d88cad5d][Erlang]] data type. For a ~Pid~ to process a message we need to
pattern match:
Expand Down Expand Up @@ -50,10 +82,39 @@ end

+ Messages can be matched and selectivelly retrieved

#+BEGIN_SRC erlang
#+NAME: erlang-seletive
#+BEGIN_SRC dot :file ../static/img/notes/erlang_selective.png :cmdline -Kdot -Tpng :exports results
digraph Selective {
node [shape=circle];
rankdir="LR";
sep = 1;

pid1 [label="Pid 1", xlabel="Pid 3 ! { foo, ... }", fontsize="10pt", style=filled, fillcolor=grey];
pid2 [label="Pid 2", xlabel="Pid 3 ! { bar, ... }", fontsize="10pt", style=filled, fillcolor=grey];
pid3 [label="Pid 3", fontsize="10pt", style=filled, fillcolor=red];

pid1 -> pid3 [label="{foo, ...}", fontsize="10pt", minlen=1, style=dashed];
pid2 -> pid3 [label="{bar, ...}", fontsize="10pt", minlen=1, style=dashed];
}
#+END_SRC

#+RESULTS: erlang-seletive
[[file:../static/img/notes/erlang_selective.png]]

#+BEGIN_SRC erlang
receive
{foo, _} ->
(...)
end,
(...)
receive
{bar, _} ->
(...)
end,
#+END_SRC

this way the message ~{foo, ...}~ is received before the message ~{bar, ...}~.

+ Messages are received when a message matches a clause
+ Mailboxes are scanned sequentially

Expand All @@ -74,6 +135,25 @@ end
executed. Otherwise, ~expr02~ will be executed.
+ ~TimeOut~ is an integer denoting the time in miliseconds or the Atom ~infinity~.

#+NAME: erlang-timeout
#+BEGIN_SRC dot :file ../static/img/notes/erlang_timeout.png :cmdline -Kdot -Tpng :exports results
digraph Timeout {
node [shape=circle];
rankdir="LR";
sep = 1;

timeout [label="🕒", fontsize="10pt", style=filled, fillcolor=white];
pid1 [label="Pid 1", fontsize="10pt", style=filled, fillcolor=grey];
pid2 [label="Pid 2", fontsize="10pt", style=filled, fillcolor=red];

timeout -> pid2 [label="Timeout", fontsize="10pt", minlen=1, style=dashed];
pid1 -> pid2 [label="Msg", fontsize="10pt", minlen=1, style=dashed];
}
#+END_SRC

#+RESULTS: erlang-timeout
[[file:../static/img/notes/erlang_timeout.png]]

#+BEGIN_SRC erlang
receive
Msg ->
Expand Down
Loading

0 comments on commit 634a896

Please sign in to comment.