summaryrefslogtreecommitdiff
path: root/4 Archives
diff options
context:
space:
mode:
Diffstat (limited to '4 Archives')
-rw-r--r--4 Archives/.gitkeep0
-rw-r--r--4 Archives/Ideas/AI operated reseller.md2
-rw-r--r--4 Archives/Regels Keezen.md8
-rw-r--r--4 Archives/blkio-errors.md14
-rw-r--r--4 Archives/elixir/elixir.md228
-rw-r--r--4 Archives/fix-tc-issues.md25
-rw-r--r--4 Archives/infotube.md1
-rw-r--r--4 Archives/no-tildes.md3
-rw-r--r--4 Archives/spinoza.md15
9 files changed, 296 insertions, 0 deletions
diff --git a/4 Archives/.gitkeep b/4 Archives/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/4 Archives/.gitkeep
diff --git a/4 Archives/Ideas/AI operated reseller.md b/4 Archives/Ideas/AI operated reseller.md
new file mode 100644
index 0000000..002ed4b
--- /dev/null
+++ b/4 Archives/Ideas/AI operated reseller.md
@@ -0,0 +1,2 @@
+Storefront
+AI system that analyzes storefront metrics (product popularity etc) -> suggests orders from alibaba/aliexpress \ No newline at end of file
diff --git a/4 Archives/Regels Keezen.md b/4 Archives/Regels Keezen.md
new file mode 100644
index 0000000..1e374ee
--- /dev/null
+++ b/4 Archives/Regels Keezen.md
@@ -0,0 +1,8 @@
+#gaming #keezen
+
+---
+Boer: swap, alleen met tegenstanders
+Heer: opzetten
+Aas: opzetten of 1
+7: verdelen tussen 2
+4: achteruit, mag alleen als je al een stap vanaf je honk heb gemaakt \ No newline at end of file
diff --git a/4 Archives/blkio-errors.md b/4 Archives/blkio-errors.md
new file mode 100644
index 0000000..2b666a3
--- /dev/null
+++ b/4 Archives/blkio-errors.md
@@ -0,0 +1,14 @@
+Dmesg is spewing blkio errors
+
+Find out which device: e.g dm-4, then:
+```
+sudo virsh list --all --name | while read dom; do sudo virsh dumpxml $dom | grep dm-4 && echo $dom; done
+```
+To find which domain
+After which:
+```
+sudo virsh dumpxml $domain
+```
+to find the hostname
+
+reboot it hard. \ No newline at end of file
diff --git a/4 Archives/elixir/elixir.md b/4 Archives/elixir/elixir.md
new file mode 100644
index 0000000..4d38de1
--- /dev/null
+++ b/4 Archives/elixir/elixir.md
@@ -0,0 +1,228 @@
+Elixir supports "macro's", which is Elixir code that runs at compile time. They receive the AST of the source code as input and can apply transformations to it. This is how Elixir is written itself, using Elixir macro's.
+
+Elixir functions can be organized into [[elixir - modules]].
+```
+defmodule MyModule do
+ # Comment
+ @moduledoc "Documentation for the module"
+ import IO
+ alias IO, as MyIO # Alias import
+
+ @pi 3.14 # Module attribute
+
+ @doc "Describe what the function does"
+ def hello do
+ MyIO.puts("blaat")
+ 3*@pi # Module attribute reference
+ done
+
+ @spec hello_private(string) # typespec, can be used by dialyzer, very useful
+ defp hello_private(hello) do
+ puts(hello)
+ done
+done
+```
+
+The [[Elixir - Kernel]] module is always imported, so functions we use without prefix come from Kernel.
+
+Elixir introduces a concept called [[Elixir - Atoms]]. They are named constants, like enumerations in C.
+```
+:blaat
+:"Bla at"
+Blaat == :"Elixir.Blaat" # Alias
+
+var = :blaat # var contains only a reference to the atom, thus is small and fast.
+```
+
+[[Elixir - Aliases]] are internally represented as "Elixir.RealThing", in the case of the module alias above `MyIO == Elixir.IO`.
+
+[[Elixir - Tuples]] group a, usually small, fixed number of elements together. Kernel.elem/2 for access, Kernel.put_elem/3 for updating.
+
+[[Elixir - Lists]] are a recursive structure with a head of any type and a tail which is another list. They are notated as regular arrays in other languages, but can be written as `[head | tail]`. Therefore it's easy and efficient to push a new item to the top, we can use the head | tail notation ->
+https://hexdocs.pm/elixir/List.html
+https://hexdocs.pm/elixir/Enum.html
+```
+list = [1, 2, 3]
+list = [4 | list]
+list
+[4, 1, 2, 3]
+```
+
+[[Elixir - Immutable functions]] give a form of atomicity, because operations (other functions) they call do not mutate data if anything fails we can just return the original data without having changed anything.
+
+[[Elixir - Maps]] %{}, can also be created with Map.new([{1, 2}, {3, 4}]) (2-tuples).
+https://hexdocs.pm/elixir/Map.html
+```
+a = %{1 => 1}
+a[1]
+1
+```
+Maps can also be used to define structures,
+```
+person = %{name: "Jasper"}
+```
+
+[[Elixir - Binaries]] are consecutive sequences of bytes.
+```
+<<1, 1>> is a two-byte binary where each byte has value of, thus
+0000 0001 0000 0001
+<<1>> <> <<2>> concatenate two binaries
+0000 0001 0000 0010
+```
+
+[[Elixir - Strings]]
+```
+"This is a stringt"
+"
+Multiline
+string
+"
+a = 1337
+"Print number #{a}" # #{} allows evaluation of values strings
+
+~s(This is a sigil which is also a string)
+~s(Is useful to "use" quotes)
+str = "INTERPOLATION!"
+~S(Capital-S sigil allows prevention of string #{str} and \nescaping)
+"Capital-S sigil allows prevention of string \#{str} and \\nescaping"
+
+"Blaat" <> " henk" # Concatenation works like binaries, because strings are binaries
+```
+
+[[Elixir - Lambda]]
+```
+square = fn x -> # lambda's use fn
+ x*x
+end
+
+square.(5) # lambda is called with name period arguments enclosed by parens. The dot is to make it known that we are calling a lambda and not a regular function.
+```
+
+For cases where the lambda just forwards its arguments to another function there is a special syntax, example:
+[[Elixir - capture operator]]
+```
+Enum.each([1, 2, 3], fn x -> IO.puts(x) end)
+Enum.each([1, 2, 3], &IO.puts/1) # The & is called the "capture operator" and can also be used to shorten a lambda definition:
+lambda = fn x, y, z -> x * y + z end
+lambda = &(&1 * &2 + &3) # Like bash arguments ${1} ${2} etc
+```
+
+[[Elixir - Closure]]
+A lambda can reference variables from the outside scope. If we rebind the variable in the parent scope, the lambda will still reference the old one.
+```
+outside = "Abc"
+lambda = &IO.puts/1
+outside = "cdef"
+lambda.()
+"Abc"
+```
+
+Range
+0..1, internally represented as a map with bounds set, therefore small no matter how "big" the range. Is also an enumeration so can use the Enum module.
+
+Keyword list
+List of 2-tuple where the 1st element is an atom. E.g. `[{:monday, 1}, {:tuesday, 2}]` can be written more elegant as `[monday: 1, tuesday: 2]`
+https://hexdocs.pm/elixir/Keyword.html
+Can be used as kwargs like in python.
+
+MapSet
+https://hexdocs.pm/elixir/MapSet.html
+Also an enumeration.
+Initialize with MapSet.new
+
+Times and Dates
+Have modules: Date, Time, DateTime, NaiveDateTime
+Created with sigil ~D for dates, and ~T for time
+```
+dt = ~D[2023-01-01]
+dt.year
+2023
+
+tm = ~T[19:03:32]
+tm.second
+32
+```
+
+IO lists
+Are lists that can consist of one of three types:
+- Int in range 0..255
+- Binaries
+- Another IO list
+It is thus a tree. Input operations are O(1)
+
+
+Pattern matching
+The '=' operator is not an assignment operator, but a match operator.
+pattern = expression
+Pattern can be list, map, tuple, variable, binaries, binary strings
+constants, atom can be matched to discriminate results of expressions.
+{:ok, result} = expr, fails is expr returns for example {:error, result}
+Patterns can be nested: `{_, {hour, _, }, _} = :calendar.local_time()`
+
+Maps can partial match, to extract a property from a complex map.
+Lists can abuse their recursive naturs: `[head | tail] = [1, 2, 3] head = 1, tail = [2,3]`
+Pin-operator `^` is used to match against the value of a variable:
+```
+a = "Bob"
+{^a, _} = {"Bob", 25} <- Matches because the value of a is "Bob"
+{^a, _} = {"Alice", 25} <- Doesn't match
+```
+
+Pattern matching using strings it's possible to match the beginning of a string and assign the rest to a var:
+```
+command = "ping www.hostnet.nl"
+"ping " <> url = command
+url = "www.hostnet.nl"
+```
+
+Pattern matching can be done in function arguments and enabled "multiclause functions", which is a sort of function overloading. It's multiple definitions of the same function, with the same arity, but with different argument patterns. They are treated as a single function, so with the capture operator you can use all "variants".
+```
+defmodule Geo do
+ def area({:square, a, b}), do a * b end
+ def area({:circle, r}), do r * r * pi end
+ def area(unknown), do {:error, {:unknown_shape, unknown}} end
+ # ^ do mind that the arity has to match for this catch-all error, also
+ # ordering is important. The runtime matches from top to bottom.
+end
+
+fn = &Geo.area/1
+
+fn.({:square, 1, 2})
+2
+fn.({:circle, 23})
+whatever this is
+```
+
+Conditionals can be implemented using multiclause functions, but also with the regular if..else statements, cond do .. end and case expression do ... end.
+
+A with-clause can be used to match multiple patterns in order and halt if a pattern doesn't match.
+```
+defp extract_login(%{"login" => login}%) do, %{:ok, login} end
+defp extract_login(_) do, {:error, "login missing"} end
+
+defp extract_email(%{"email" => email}) do, %{:ok, email} end
+defp extract_email(_) do, %{:error, "email missing"} end
+
+def extract_user(user) do
+ case extract_login(user) do
+ {:error, reason} -> {:error, reason}
+ {:ok, login} ->
+ case extract_email(user) do
+ {:error, reason} -> {:error, reason}
+ {ok, email} -> %{login: login, email: email}
+ end
+ end
+end
+
+# can be written as
+
+def extract_user(user) do
+ with {:ok, login} <- extract_login(user),
+ {:ok, email} <- extract_email(user) do
+ {:ok, %{login: login, email: email}}
+ end
+end
+```
+
+Looping is mainly implemented via recursion. The break condition is implemented via a multiclause function matching the condition that you want to break at.
+Recursion can be expensive, unless the recursive call is at the end of a function, which is called a tail-call. Tail-calls are optimized to not require any additional memory, because their result is also the result of the caller, so we don't need to come back to the caller. \ No newline at end of file
diff --git a/4 Archives/fix-tc-issues.md b/4 Archives/fix-tc-issues.md
new file mode 100644
index 0000000..4ad3bf8
--- /dev/null
+++ b/4 Archives/fix-tc-issues.md
@@ -0,0 +1,25 @@
+Probleem: referenties in ovs naar devices die niet meer bestaan. Hij probeert vervolgens een nieuw device aan te maken met een qdisc op zo'n niet bestaande device.
+
+```
+sudo grep -r 'could not open network device' /var/log/openvswitch/ | grep -oi 'tap[a-z0-9\-]*' | uniq > ports_no_device
+```
+```
+sudo ip l l | grep ports_no_device | grep -oi 'tap[a-z0-9\-]*' > ports_with_device
+```
+```
+for P in $(cat ports_no_device | grep -v -f ports_with_device); do sudo ovs-vsctl del-port $P; done
+```
+```
+sudo systemctl restart ovn-controller
+```
+
+
+Rutger versie:
+```
+sudo grep 'could not open network device' /var/log/openvswitch/ovs-vswitchd.log | grep -oi 'tap[a-z0-9\-]*' | sort | uniq | while read dev; do ip l l $dev || sudo ovs-vsctl del-port $dev; done; sudo systemctl restart ovn-controller
+```
+
+
+Dus: ovs-vsctl del-port is nice.
+
+Niet vergeten ovn-controller te herstarten.
diff --git a/4 Archives/infotube.md b/4 Archives/infotube.md
new file mode 100644
index 0000000..d876c9b
--- /dev/null
+++ b/4 Archives/infotube.md
@@ -0,0 +1 @@
+Watching informational YouTube videos where people teach you skills by just giving you distilled information doesn’t really teach you these skills. They can be a great head start but I believe that we must still do all the hard work that they did as well, which well be easier to do thanks to them but should nonetheless be done to achieve true understanding. \ No newline at end of file
diff --git a/4 Archives/no-tildes.md b/4 Archives/no-tildes.md
new file mode 100644
index 0000000..a04434e
--- /dev/null
+++ b/4 Archives/no-tildes.md
@@ -0,0 +1,3 @@
+Falcone does not show tildes for regex matchers.. to find out if they are truly regexes just hop onto an alertmngr and query using `amtool`.
+
+#Falcone
diff --git a/4 Archives/spinoza.md b/4 Archives/spinoza.md
new file mode 100644
index 0000000..6af7f70
--- /dev/null
+++ b/4 Archives/spinoza.md
@@ -0,0 +1,15 @@
+Filosoof
+Vrijheid
+Joods
+Amsterdam
+
+Decartes: je kan pas geloven dat iets waar is als je het redelijkerwijs kan aantonen
+
+Vervloeking door Joodse commune? Bah
+Kern idee godsdienst, zonder bovenstaande zaken
+
+Als je de wereld begrijpt kun je het goede doen voor jezelf en de wereld
+
+De ethica -> Magnum opus (onleesbaar)
+
+Ian burema: wat kunnen we nog leren van spinoza \ No newline at end of file