From 1a911ffef8f7bf094af1b4be2acb31bc6dc74da2 Mon Sep 17 00:00:00 2001 From: dongdigua Date: Sat, 29 Oct 2022 13:26:19 +0800 Subject: [PATCH] add random quote --- index.html | 14 ++++++++------ js/random-quote.js | 12 ++++++++++++ p2p_chat.md | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 js/random-quote.js diff --git a/index.html b/index.html index fc5fa15..662028e 100644 --- a/index.html +++ b/index.html @@ -25,19 +25,21 @@
 (let ((name "dongdigua")
-      (blog "posts/")
-      (feed "feed.xml")
+      (blog "posts/")
+      (feed "feed.xml")
       (github "@dongdigua")
-      (payment "monero")
-      (pgp "0x56CEE157C9F5334F")
+      (payment "monero")
+      (pgp "0x56CEE157C9F5334F")
       (interests
        '("computer science"
          "cyber security"
          "GeoGebra"
          "Minecraft redstone survival"
          "anime"
-         (Lost (In (Superfluous (Parentheses))))))))
+         (Lost (In (Superfluous (Parentheses)))))))
+      (random-quote
+      ""))
     
- + diff --git a/js/random-quote.js b/js/random-quote.js new file mode 100644 index 0000000..6a406aa --- /dev/null +++ b/js/random-quote.js @@ -0,0 +1,12 @@ +var data = [ + "富强民主闻名和谐, 自由平等公正法治, 爱国敬业诚信友善", + "解放思想, 实事求是, 与时俱进", + + "You are not alone", + "The internet is FULL, go away!", + "May the --force be with you", + "Software that sucks less", +]; + +var index = Math.floor((Math.random() * data.length)); +window.document.getElementById("quote").innerHTML = data[index]; diff --git a/p2p_chat.md b/p2p_chat.md index 1f672ed..ba9f739 100644 --- a/p2p_chat.md +++ b/p2p_chat.md @@ -17,7 +17,7 @@ - rsa 非对称加密 - UDP 打洞
整个思路来源都是从这两个视频来的:
-[使用 Netcat 的原理讲解](https://www.youtube.com/watch?v=s_-UCmuiYW8) & +[使用 Netcat 的原理讲解](https://www.youtube.com/watch?v=s_-UCmuiYW8) & [使用 Python 实现 p2p 通信](https://www.youtube.com/watch?v=IbzGL_tjmv4)
我的理解就是通过发送 UDP 包打开一个端口,
然后将两个需要发消息的客户端相互告诉对方各自的公网 IP 以及映射到的端口,就能实现 p2p 通信。
@@ -279,7 +279,7 @@ defmodule Server do case find_peer(user_data) do nil -> add_peer(user_data) - {{peer0, msg0}, {peer1, msg1}} -> + { {peer0, msg0}, {peer1, msg1} } -> :gen_udp.send(socket, peer0, msg0) :gen_udp.send(socket, peer1, msg1) end