From 26ee7e333f8a7313db33c441e3a9e23eb73895a5 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Fri, 26 Aug 2022 10:18:19 -0700 Subject: [PATCH 01/13] GH table quick guide --- .../dev-tools/other-resources/github-guide.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 content/en/dev-tools/other-resources/github-guide.md diff --git a/content/en/dev-tools/other-resources/github-guide.md b/content/en/dev-tools/other-resources/github-guide.md new file mode 100644 index 00000000..689ed3c0 --- /dev/null +++ b/content/en/dev-tools/other-resources/github-guide.md @@ -0,0 +1,32 @@ +--- +title: "Github Tips and Tricks" +description: "Github usage for open source contribution" +draft: false +menu: + devtools: + parent: "resources-other" +weight: 80 +--- + +## Markdown quick guide + +Every text input section in [GitHub uses Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/about-writing-and-formatting-on-github). Every Pull Request (PR), review, issue, and comment section supports markdown. Markdown is not specific to Github, but is it's own writing and formatting style. Github has added additional functionality to it that is only usable within Github like interacting with other users with @mentions, issue and PR references, and emoji's! + +If you are contributing to open source repositories and organizations, here are some common uses seen in the wild: + + + +| Markdown | Command | Description | +|------------------------------|--------------------------|-----------------------------------------------------------------------------------------------| +| HEADER | # | Used for headings, add more symbols before the heading to change the size from 1 (biggest) to 6 (smallest). | +| * unorderedList | */- | Either a single `*` or `-` is used for _unordered lists_. Tabs create sub-lists. | +| 1) numberedList | number) | Used to create _numbered lists_. Tabs create sub-lists. | +| > Quote | > | Used to quote other users responses. | +| \`code\` or \```codeblock\``` | \` | A single ` is used for just one line of code. A group of three ``` are used for multi-line code blocks. | +| \[title\]\(www.example.com\) | \[ ] ( ) | Create URLs/Links in this format. With the text you want to display `[]` and the URL in `()` | +| :thumbsup: | :emoji name: | Write the emoji name in between colons to create an emoji. | +| :white_check_mark: Checklist | [] | Github automatically creates a progression bar for checkboxes grouped together within Issues. | +| @username | @ | Github will create a link to the user and notify them (with respect to their preferences). | +| #GHIssueNumber or PRNumber | # or GH- | Github will automatically create a link to an Issue or PR, IF applicable. Else, it'll treat it like Heading. | + +Source: [Github Writing Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax), [Markdown Guide](https://www.markdownguide.org/cheat-sheet/) \ No newline at end of file From eeda1c03beb476ea957cf9966e832f3abfe13e29 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Tue, 20 Sep 2022 15:44:25 -0700 Subject: [PATCH 02/13] Added gh slides from coloweek --- content/en/dev-tools/other-resources/github-guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/en/dev-tools/other-resources/github-guide.md b/content/en/dev-tools/other-resources/github-guide.md index 689ed3c0..9374b362 100644 --- a/content/en/dev-tools/other-resources/github-guide.md +++ b/content/en/dev-tools/other-resources/github-guide.md @@ -8,6 +8,8 @@ menu: weight: 80 --- +{{< gdocs "https://docs.google.com/presentation/d/11V_BA5A64lCY_wFsvuLO4je02zvzJwD5vf2kzONDWyc/embed" >}} + ## Markdown quick guide Every text input section in [GitHub uses Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/about-writing-and-formatting-on-github). Every Pull Request (PR), review, issue, and comment section supports markdown. Markdown is not specific to Github, but is it's own writing and formatting style. Github has added additional functionality to it that is only usable within Github like interacting with other users with @mentions, issue and PR references, and emoji's! From 138ea0e28f1afa51cb7dd26c0a8eb2291102e8e9 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Tue, 20 Sep 2022 15:44:39 -0700 Subject: [PATCH 03/13] Added new shortcode --- layouts/shortcodes/gdocs.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 layouts/shortcodes/gdocs.html diff --git a/layouts/shortcodes/gdocs.html b/layouts/shortcodes/gdocs.html new file mode 100644 index 00000000..af147950 --- /dev/null +++ b/layouts/shortcodes/gdocs.html @@ -0,0 +1,8 @@ +
+ +
\ No newline at end of file From 57eb082097a5ad28d55868ff12acbd8fc9dfe3a4 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Thu, 22 Sep 2022 16:51:00 -0700 Subject: [PATCH 04/13] Created custom shortcode for codeblocks --- assets/js/codemd.js | 56 +++++++++++++++++++++++++ assets/scss/common/_custom.scss | 10 +++++ content/en/curriculum/filecoin/drand.md | 8 +++- layouts/shortcodes/code.html | 8 ++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 assets/js/codemd.js create mode 100644 layouts/shortcodes/code.html diff --git a/assets/js/codemd.js b/assets/js/codemd.js new file mode 100644 index 00000000..ff7ad9b8 --- /dev/null +++ b/assets/js/codemd.js @@ -0,0 +1,56 @@ +// Collapsible Hugo code blocks +// by Jiri De Jagere, @JiriDJ + +var height = "320px"; + +if ( + document.readyState === "complete" || + (document.readyState !== "loading" && !document.documentElement.doScroll) +) { + makeCollapsible(); +} else { + document.addEventListener("DOMContentLoaded", makeCollapsible); +} + +function toggle(e) { + e.preventDefault(); + var link = e.target; + var div = link.parentElement.parentElement; + + if (link.innerHTML == "more ") { + link.innerHTML = "less "; + div.style.maxHeight = ""; + div.style.overflow = "none"; + } + else { + link.innerHTML = "more "; + div.style.maxHeight = height; + div.style.overflow = "hidden"; + div.scrollIntoView({ behavior: 'smooth' }); + } +} + +function makeCollapsible() { + var divs = document.querySelectorAll('.highlight-wrapper'); + + for (i=0; i < divs.length; i++) { + var div = divs[i]; + if (div.offsetHeight > parseInt(height, 10)) { + div.style.maxHeight = height; + div.style.overflow = "hidden"; + + var e = document.createElement('div'); + e.className = "highlight-link"; + + var html = 'more '; + e.innerHTML = html; + div.appendChild(e); + } + } + + var links = document.querySelectorAll('.highlight-link'); + for (i=0; i}} -#### [drand - The Distributed Randomness Beacon | ResNetLabs On Tour – Nicolas GAILLY](https://research.protocol.ai/tutorials/resnetlab-on-tour/modular-p2p-stack/) +#### [Drand - The Distributed Randomness Beacon | ResNetLabs On Tour – Nicolas GAILLY](https://research.protocol.ai/tutorials/resnetlab-on-tour/modular-p2p-stack/) -drand is a distributed randomness beacon. It provides publicly-verifiable, unpredictable, and bias-resistant random numbers as a public service. In this module, we’ll walk through: +Drand is a distributed randomness beacon. It provides publicly-verifiable, unpredictable, and bias-resistant random numbers as a public service. In this module, we’ll walk through: * Threshold Cryptography & Randomness * Distributed Key Generation in drand @@ -29,6 +29,10 @@ drand is a distributed randomness beacon. It provides publicly-verifiable, unpre {{< youtube NNfaQ__UFCE >}} +### Drand Tutorial +This example goes over how to use the Drand network to retrieve a random value in a key-pair list. + + ## Drand Resources * The [drand website](https://drand.love/) diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html new file mode 100644 index 00000000..129c820e --- /dev/null +++ b/layouts/shortcodes/code.html @@ -0,0 +1,8 @@ +
+
{{ .Get 0 }}
+ {{ if len .Params | eq 2 }} + {{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }} + {{ else }} + {{ highlight (trim .Inner "\n\r") (.Get 0) "" }} + {{ end }} +
\ No newline at end of file From ef4d890f93f89fe086ea448a22b905f47735ec52 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Thu, 22 Sep 2022 16:51:41 -0700 Subject: [PATCH 05/13] Added drand example directly to curriculum --- content/en/curriculum/filecoin/drand.md | 81 ++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/content/en/curriculum/filecoin/drand.md b/content/en/curriculum/filecoin/drand.md index 40e97738..1baac008 100644 --- a/content/en/curriculum/filecoin/drand.md +++ b/content/en/curriculum/filecoin/drand.md @@ -29,9 +29,88 @@ Drand is a distributed randomness beacon. It provides publicly-verifiable, unpre {{< youtube NNfaQ__UFCE >}} -### Drand Tutorial +### Drand Example This example goes over how to use the Drand network to retrieve a random value in a key-pair list. +Imagine you are a full time L5 software engineer and have more important things to think about than what to get for lunch. +You decide to leave it up to randomness to choose your next meal. But you still have preferences. +You assign weights to your preferences such that items you would like to eat most often have heavier weights (chances of being chosen) +And things you don't want to eat as often, have smaller probability of being chosen. + +Check out this quick Javascript code: + +{{< code JS >}} + +import Client, { HTTP } from 'drand-client' +import fetch from 'node-fetch' +import AbortController from 'abort-controller' + +global.fetch = fetch +global.AbortController = AbortController +const HEX = 16; +const FoodOptions = { "pho": 0.3, "croquets": 0.29, "pizza": 0.28, "pasta": 0.07, "mole_verde": 0.03, "shrimp": .03 } + +const chainHash = '8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce' // (hex encoded) +const urls = [ + 'https://api.drand.sh', + 'https://drand.cloudflare.com' +] + +// This function takes in a list of items and the probablilty of them being selected. +// returns the number that is randomly selected +async function weightedRandom(prob) { + + const options = { chainHash } + + const client = await Client.wrap(HTTP.forURLs(urls, chainHash), options) + + // e.g. use the client to get the latest randomness round: + const res = await client.get() + // console.log(res.round, res.randomness) + + // assign randomness value as a string to a variable + const randomness = res.randomness + + // grab the left most 12 digits + const drand = randomness.slice(0, 12) + // console.log("drand", drand) + + // Convert hexadecimal randomness value to decimal (base16 -> base10) + var base10 = parseInt(drand, HEX) + // console.log("base10", base10) + + // "normalize" rand value to be a percentage (between 0-1) + var normal = base10 + while (normal > 1){ + normal /= 10; + } + console.log("normalize", parseFloat(normal.toFixed(8))) + + // This for loop selects which key:pair to return + let sum = 0, r = parseFloat(normal.toFixed(8)); + for (let [key, value] of Object.entries(prob)) { + sum += value; + if (r <= sum) { + return key; + } + } +} + +//runs code above +weightedRandom(FoodOptions).then((lunch) => (console.log(lunch))) +// Press Ctrl + C to stop example! + +/* +*/ + +{{< /code >}} + +Things to note: +* Drand mainnet releases a random number every 30 seconds. The problem that arises is if you want to test if the biased randomness works or not, it would take a really long time to test. +* There is work to shorten this time frame to 3 seconds, which is better, but its not as convenient as instant access of psuedo-random numbers like math.random() or crypto.getRandomValues(). +* This "biased" algo is not sophisticated, weights are not changing every iteration to adjust for any external factors. +* Ideally, we have a neural net that adjusts weights in order to control supply ratio. + Or some other algorithm that handled weights better, instead of just summation of key:pair values. ## Drand Resources From 296049d401742c798e83b5bfbaf395301ea93451 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Thu, 22 Sep 2022 17:19:23 -0700 Subject: [PATCH 06/13] Fixed bug, that was not collapsing code block --- content/en/curriculum/filecoin/drand.md | 7 +------ layouts/partials/footer/script-footer.html | 3 ++- layouts/shortcodes/code.html | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/content/en/curriculum/filecoin/drand.md b/content/en/curriculum/filecoin/drand.md index 1baac008..b6f0aeb0 100644 --- a/content/en/curriculum/filecoin/drand.md +++ b/content/en/curriculum/filecoin/drand.md @@ -39,7 +39,7 @@ And things you don't want to eat as often, have smaller probability of being cho Check out this quick Javascript code: -{{< code JS >}} +{{< code javascript >}} import Client, { HTTP } from 'drand-client' import fetch from 'node-fetch' @@ -98,11 +98,6 @@ async function weightedRandom(prob) { //runs code above weightedRandom(FoodOptions).then((lunch) => (console.log(lunch))) -// Press Ctrl + C to stop example! - -/* -*/ - {{< /code >}} Things to note: diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 5cae2790..32bd7517 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -13,6 +13,7 @@ {{ $mermaid := resources.Get "js/mermaid.js" | js.Build -}} {{ $app := resources.Get "js/app.js" -}} +{{ $app := resources.Get "js/codemd.js" -}} {{ $slice := slice $app -}} @@ -105,4 +106,4 @@ {{ if and (.Site.Params.options.flexSearch) (not .IsHome) -}} {{ end -}} -{{ end -}} +{{ end -}} \ No newline at end of file diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html index 129c820e..5c4dd455 100644 --- a/layouts/shortcodes/code.html +++ b/layouts/shortcodes/code.html @@ -1,5 +1,5 @@
-
{{ .Get 0 }}
+
{{ if len .Params | eq 2 }} {{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }} {{ else }} From d7c33390a961737f62a1b5c05a8d78eda7e54ceb Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Thu, 22 Sep 2022 17:27:17 -0700 Subject: [PATCH 07/13] Fixed spacing --- content/en/curriculum/filecoin/drand.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/en/curriculum/filecoin/drand.md b/content/en/curriculum/filecoin/drand.md index b6f0aeb0..ff3e164c 100644 --- a/content/en/curriculum/filecoin/drand.md +++ b/content/en/curriculum/filecoin/drand.md @@ -38,7 +38,6 @@ You assign weights to your preferences such that items you would like to eat mos And things you don't want to eat as often, have smaller probability of being chosen. Check out this quick Javascript code: - {{< code javascript >}} import Client, { HTTP } from 'drand-client' @@ -99,7 +98,7 @@ async function weightedRandom(prob) { //runs code above weightedRandom(FoodOptions).then((lunch) => (console.log(lunch))) {{< /code >}} - +

Things to note: * Drand mainnet releases a random number every 30 seconds. The problem that arises is if you want to test if the biased randomness works or not, it would take a really long time to test. * There is work to shorten this time frame to 3 seconds, which is better, but its not as convenient as instant access of psuedo-random numbers like math.random() or crypto.getRandomValues(). From 1d86d728208f2cff971c9f9f043722e556cd85ee Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Thu, 29 Sep 2022 23:39:08 -0700 Subject: [PATCH 08/13] Test new embedding style --- content/en/curriculum/filecoin/drand.md | 61 +------------------------ 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/content/en/curriculum/filecoin/drand.md b/content/en/curriculum/filecoin/drand.md index ff3e164c..22969248 100644 --- a/content/en/curriculum/filecoin/drand.md +++ b/content/en/curriculum/filecoin/drand.md @@ -38,66 +38,9 @@ You assign weights to your preferences such that items you would like to eat mos And things you don't want to eat as often, have smaller probability of being chosen. Check out this quick Javascript code: -{{< code javascript >}} + -import Client, { HTTP } from 'drand-client' -import fetch from 'node-fetch' -import AbortController from 'abort-controller' - -global.fetch = fetch -global.AbortController = AbortController -const HEX = 16; -const FoodOptions = { "pho": 0.3, "croquets": 0.29, "pizza": 0.28, "pasta": 0.07, "mole_verde": 0.03, "shrimp": .03 } - -const chainHash = '8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce' // (hex encoded) -const urls = [ - 'https://api.drand.sh', - 'https://drand.cloudflare.com' -] - -// This function takes in a list of items and the probablilty of them being selected. -// returns the number that is randomly selected -async function weightedRandom(prob) { - - const options = { chainHash } - - const client = await Client.wrap(HTTP.forURLs(urls, chainHash), options) - - // e.g. use the client to get the latest randomness round: - const res = await client.get() - // console.log(res.round, res.randomness) - - // assign randomness value as a string to a variable - const randomness = res.randomness - - // grab the left most 12 digits - const drand = randomness.slice(0, 12) - // console.log("drand", drand) - - // Convert hexadecimal randomness value to decimal (base16 -> base10) - var base10 = parseInt(drand, HEX) - // console.log("base10", base10) - - // "normalize" rand value to be a percentage (between 0-1) - var normal = base10 - while (normal > 1){ - normal /= 10; - } - console.log("normalize", parseFloat(normal.toFixed(8))) - - // This for loop selects which key:pair to return - let sum = 0, r = parseFloat(normal.toFixed(8)); - for (let [key, value] of Object.entries(prob)) { - sum += value; - if (r <= sum) { - return key; - } - } -} - -//runs code above -weightedRandom(FoodOptions).then((lunch) => (console.log(lunch))) -{{< /code >}}

Things to note: * Drand mainnet releases a random number every 30 seconds. The problem that arises is if you want to test if the biased randomness works or not, it would take a really long time to test. From 2d051d7b3d5669f837cd8230b5cb3e8167b2ac06 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Sat, 1 Oct 2022 14:14:28 -0500 Subject: [PATCH 09/13] Drand tutorial v1 --- .../en/curriculum/filecoin/drand(tutorial).md | 58 +++++++++++++++++++ content/en/curriculum/filecoin/drand.md | 20 ------- layouts/shortcodes/code.html | 8 --- 3 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 content/en/curriculum/filecoin/drand(tutorial).md delete mode 100644 layouts/shortcodes/code.html diff --git a/content/en/curriculum/filecoin/drand(tutorial).md b/content/en/curriculum/filecoin/drand(tutorial).md new file mode 100644 index 00000000..3ee251d1 --- /dev/null +++ b/content/en/curriculum/filecoin/drand(tutorial).md @@ -0,0 +1,58 @@ +--- +title: "Drand (Tutorial)" +description: "Distributed, Unpredictable, Publicly-Verifiable, and Decentralized Randomness Generator" +draft: false +menu: + curriculum: + parent: "curriculum-filecoin" +weight: 423 +category: lecture +level: +- deep +--- +This example goes over how to use Drand as a client to retrieve a random value in a key-value pair list. + +**If a code section loads as a single line, try refreshing the page.** + +## Pre-Requisites +* Make sure you have Node version 12 or greater installed. You can find instructions on how to do that on the [NodeJS website](https://nodejs.org/en/). +* Download repo at XYZ and run: + 1) `npm install` + 2) `node bias.js` + +## Caveats +* Drand mainnet releases a random number every 30 seconds. So if you run your results immediately after the other, you may get the exact same output. The problem that arises is if you want to test if the biased randomness works or not over time, it would take a really long time to test. +* This "biased" algo is not sophisticated, weights are not changing every iteration to adjust for any external factors. + +## Instructions +Imagine you are a full time L5 software engineer and have more important things to think about than what to get for lunch. +You decide to leave it up to randomness to choose your next meal. But you still have preferences. You assign weights to your preferences such that items you would like to eat most often have heavier weights (chances of being chosen). And things you don't want to eat as often, have smaller chance of being chosen. + +To be able start talking with the Drand network you will need to import the necessary libraries. + + + +Now we can make calls to the Drand network. But to do that we have to create the Client to get the latest random number published. + + + +`client.get()` is an asynchronous function that returns an object where you can access the random number with `res.randomness`. This returns a 64-digit hexidecimal number as a **string**. + +We do not need 64 digits for this simple example let alone for them to be in hex. For our example we can just grab the first two digits from `rand` and convert it base 10. This will make it easier to compare the user weights to our random number. + +``` javascript +rand = randomness.slice(0, 2); +randomDecimal = parseInt(rand, HEX); // HEX = 16 +``` + + Unfortunately, a two digit Hexadecimal value [doesn't always convert to a 2 digit decimal number](https://kb.iu.edu/d/afdl). So we create a simple ["sliding window"](https://www.geeksforgeeks.org/window-sliding-technique/) function to find the first pair of digits that converts properly. + + + +Now that we have our random number we compare it against our food options to find out what we are having for lunch. This simple algorithm converts the user weights provided as decimal numbers to be integers, and adds the sums, the first weight that isn't bigger than our random number is what we are having for lunch. + +For example here is our food options,: +``` javascript +const FoodOptions = { "pho": 0.3, "croquets": 0.29, "pizza": 0.28, "pasta": 0.07, "molé_verde": 0.03, "shrimp": .03 }; +``` + \ No newline at end of file diff --git a/content/en/curriculum/filecoin/drand.md b/content/en/curriculum/filecoin/drand.md index 22969248..ff16d3b6 100644 --- a/content/en/curriculum/filecoin/drand.md +++ b/content/en/curriculum/filecoin/drand.md @@ -29,26 +29,6 @@ Drand is a distributed randomness beacon. It provides publicly-verifiable, unpre {{< youtube NNfaQ__UFCE >}} -### Drand Example -This example goes over how to use the Drand network to retrieve a random value in a key-pair list. - -Imagine you are a full time L5 software engineer and have more important things to think about than what to get for lunch. -You decide to leave it up to randomness to choose your next meal. But you still have preferences. -You assign weights to your preferences such that items you would like to eat most often have heavier weights (chances of being chosen) -And things you don't want to eat as often, have smaller probability of being chosen. - -Check out this quick Javascript code: - - -

-Things to note: -* Drand mainnet releases a random number every 30 seconds. The problem that arises is if you want to test if the biased randomness works or not, it would take a really long time to test. -* There is work to shorten this time frame to 3 seconds, which is better, but its not as convenient as instant access of psuedo-random numbers like math.random() or crypto.getRandomValues(). -* This "biased" algo is not sophisticated, weights are not changing every iteration to adjust for any external factors. -* Ideally, we have a neural net that adjusts weights in order to control supply ratio. - Or some other algorithm that handled weights better, instead of just summation of key:pair values. - ## Drand Resources * The [drand website](https://drand.love/) diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html deleted file mode 100644 index 5c4dd455..00000000 --- a/layouts/shortcodes/code.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- {{ if len .Params | eq 2 }} - {{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }} - {{ else }} - {{ highlight (trim .Inner "\n\r") (.Get 0) "" }} - {{ end }} -
\ No newline at end of file From 7259deaf46125f4053e9cd9cbcdd5c703945b552 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Sun, 2 Oct 2022 14:06:15 -0500 Subject: [PATCH 10/13] Removing code from old branch --- assets/js/codemd.js | 56 ------------------- assets/scss/common/_custom.scss | 36 +++++------- .../dev-tools/other-resources/github-guide.md | 34 ----------- layouts/shortcodes/gdocs.html | 8 --- 4 files changed, 13 insertions(+), 121 deletions(-) delete mode 100644 assets/js/codemd.js delete mode 100644 content/en/dev-tools/other-resources/github-guide.md delete mode 100644 layouts/shortcodes/gdocs.html diff --git a/assets/js/codemd.js b/assets/js/codemd.js deleted file mode 100644 index ff7ad9b8..00000000 --- a/assets/js/codemd.js +++ /dev/null @@ -1,56 +0,0 @@ -// Collapsible Hugo code blocks -// by Jiri De Jagere, @JiriDJ - -var height = "320px"; - -if ( - document.readyState === "complete" || - (document.readyState !== "loading" && !document.documentElement.doScroll) -) { - makeCollapsible(); -} else { - document.addEventListener("DOMContentLoaded", makeCollapsible); -} - -function toggle(e) { - e.preventDefault(); - var link = e.target; - var div = link.parentElement.parentElement; - - if (link.innerHTML == "more ") { - link.innerHTML = "less "; - div.style.maxHeight = ""; - div.style.overflow = "none"; - } - else { - link.innerHTML = "more "; - div.style.maxHeight = height; - div.style.overflow = "hidden"; - div.scrollIntoView({ behavior: 'smooth' }); - } -} - -function makeCollapsible() { - var divs = document.querySelectorAll('.highlight-wrapper'); - - for (i=0; i < divs.length; i++) { - var div = divs[i]; - if (div.offsetHeight > parseInt(height, 10)) { - div.style.maxHeight = height; - div.style.overflow = "hidden"; - - var e = document.createElement('div'); - e.className = "highlight-link"; - - var html = 'more '; - e.innerHTML = html; - div.appendChild(e); - } - } - - var links = document.querySelectorAll('.highlight-link'); - for (i=0; i}} - -## Markdown quick guide - -Every text input section in [GitHub uses Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/about-writing-and-formatting-on-github). Every Pull Request (PR), review, issue, and comment section supports markdown. Markdown is not specific to Github, but is it's own writing and formatting style. Github has added additional functionality to it that is only usable within Github like interacting with other users with @mentions, issue and PR references, and emoji's! - -If you are contributing to open source repositories and organizations, here are some common uses seen in the wild: - - - -| Markdown | Command | Description | -|------------------------------|--------------------------|-----------------------------------------------------------------------------------------------| -| HEADER | # | Used for headings, add more symbols before the heading to change the size from 1 (biggest) to 6 (smallest). | -| * unorderedList | */- | Either a single `*` or `-` is used for _unordered lists_. Tabs create sub-lists. | -| 1) numberedList | number) | Used to create _numbered lists_. Tabs create sub-lists. | -| > Quote | > | Used to quote other users responses. | -| \`code\` or \```codeblock\``` | \` | A single ` is used for just one line of code. A group of three ``` are used for multi-line code blocks. | -| \[title\]\(www.example.com\) | \[ ] ( ) | Create URLs/Links in this format. With the text you want to display `[]` and the URL in `()` | -| :thumbsup: | :emoji name: | Write the emoji name in between colons to create an emoji. | -| :white_check_mark: Checklist | [] | Github automatically creates a progression bar for checkboxes grouped together within Issues. | -| @username | @ | Github will create a link to the user and notify them (with respect to their preferences). | -| #GHIssueNumber or PRNumber | # or GH- | Github will automatically create a link to an Issue or PR, IF applicable. Else, it'll treat it like Heading. | - -Source: [Github Writing Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax), [Markdown Guide](https://www.markdownguide.org/cheat-sheet/) \ No newline at end of file diff --git a/layouts/shortcodes/gdocs.html b/layouts/shortcodes/gdocs.html deleted file mode 100644 index af147950..00000000 --- a/layouts/shortcodes/gdocs.html +++ /dev/null @@ -1,8 +0,0 @@ -
- -
\ No newline at end of file From b199e9a65887e3e1a31d52635aa9e0f25c8fd34e Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Tue, 4 Oct 2022 05:55:21 -0500 Subject: [PATCH 11/13] Fixed bug --- layouts/partials/footer/script-footer.html | 126 +++++++++++---------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 32bd7517..f42928fc 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -13,49 +13,48 @@ {{ $mermaid := resources.Get "js/mermaid.js" | js.Build -}} {{ $app := resources.Get "js/app.js" -}} -{{ $app := resources.Get "js/codemd.js" -}} {{ $slice := slice $app -}} {{ if .Site.Params.options.lazySizes -}} - {{ $lazySizes := resources.Get "js/lazysizes.js" -}} - {{ $lazySizes := $lazySizes | js.Build -}} - {{ $slice = $slice | append $lazySizes -}} +{{ $lazySizes := resources.Get "js/lazysizes.js" -}} +{{ $lazySizes := $lazySizes | js.Build -}} +{{ $slice = $slice | append $lazySizes -}} {{ end -}} {{ if .Site.Params.options.clipBoard -}} - {{ $clipBoard := resources.Get "js/clipboard.js" -}} - {{ $clipBoard := $clipBoard | js.Build -}} - {{ $slice = $slice | append $clipBoard -}} +{{ $clipBoard := resources.Get "js/clipboard.js" -}} +{{ $clipBoard := $clipBoard | js.Build -}} +{{ $slice = $slice | append $clipBoard -}} {{ end -}} {{ if .Site.Params.options.instantPage -}} - {{ $instantPage := resources.Get "js/instant.page.js" -}} - {{ $instantPage := $instantPage | js.Build -}} - {{ $slice = $slice | append $instantPage -}} +{{ $instantPage := resources.Get "js/instant.page.js" -}} +{{ $instantPage := $instantPage | js.Build -}} +{{ $slice = $slice | append $instantPage -}} {{ end -}} {{ if .Site.Params.options.flexSearch -}} - {{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}} - {{ $slice = $slice | append $flexSearch -}} +{{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}} +{{ $slice = $slice | append $flexSearch -}} {{ end -}} {{ if .Site.Params.options.darkMode -}} - {{ $darkMode := resources.Get "js/darkmode.js" -}} - {{ $darkMode := $darkMode | js.Build -}} - {{ $slice = $slice | append $darkMode -}} +{{ $darkMode := resources.Get "js/darkmode.js" -}} +{{ $darkMode := $darkMode | js.Build -}} +{{ $slice = $slice | append $darkMode -}} {{ end -}} {{ if and (.Site.Params.alert) (.Site.Params.alertDismissable) -}} - {{ $alert := resources.Get "js/alert.js" -}} - {{ $alert := $alert | js.Build -}} - {{ $slice = $slice | append $alert -}} +{{ $alert := resources.Get "js/alert.js" -}} +{{ $alert := $alert | js.Build -}} +{{ $slice = $slice | append $alert -}} {{ end -}} {{ if .Site.Params.options.kaTex -}} - {{ $katexConfig := resources.Get "js/katex.js" -}} - {{ $katexConfig := $katexConfig | js.Build -}} - {{ $slice = $slice | append $katexConfig -}} +{{ $katexConfig := resources.Get "js/katex.js" -}} +{{ $katexConfig := $katexConfig | js.Build -}} +{{ $slice = $slice | append $katexConfig -}} {{ end -}} {{ $scrollLock := resources.Get "js/scroll-lock.js" | js.Build -}} @@ -64,46 +63,49 @@ {{ $js := $slice | resources.Concat "main.js" -}} {{ if eq (hugo.Environment) "development" -}} - {{ if .Site.Params.options.bootStrapJs -}} - - {{ end -}} - {{ if .Site.Params.options.highLight -}} - - {{ end -}} - {{ if .Site.Params.options.kaTex -}} - - - {{ end -}} - - {{ with .Params.mermaid -}} - - {{ end -}} - {{ if and (.Site.Params.options.flexSearch) (not .IsHome) -}} - - {{ end -}} +{{ if .Site.Params.options.bootStrapJs -}} + +{{ end -}} +{{ if .Site.Params.options.highLight -}} + +{{ end -}} +{{ if .Site.Params.options.kaTex -}} + + +{{ end -}} + +{{ with .Params.mermaid -}} + +{{ end -}} +{{ if and (.Site.Params.options.flexSearch) (not .IsHome) -}} + +{{ end -}} {{ else -}} - {{ $js := $js | minify | fingerprint "sha512" -}} - {{ $index := $index | minify | fingerprint "sha512" -}} - {{ $bs := $bs | minify | fingerprint "sha512" -}} - {{ $highlight := $highlight | minify | fingerprint "sha512" -}} - {{ $katex := $katex | minify | fingerprint "sha512" -}} - {{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}} - {{ $mermaid := $mermaid | minify | fingerprint "sha512" -}} - {{ if .Site.Params.options.bootStrapJs -}} - - {{ end -}} - {{ if .Site.Params.options.highLight -}} - - {{ end -}} - {{ if .Site.Params.options.kaTex -}} - - - {{ end -}} - - {{ with .Params.mermaid -}} - - {{ end -}} - {{ if and (.Site.Params.options.flexSearch) (not .IsHome) -}} - - {{ end -}} +{{ $js := $js | minify | fingerprint "sha512" -}} +{{ $index := $index | minify | fingerprint "sha512" -}} +{{ $bs := $bs | minify | fingerprint "sha512" -}} +{{ $highlight := $highlight | minify | fingerprint "sha512" -}} +{{ $katex := $katex | minify | fingerprint "sha512" -}} +{{ $katexAutoRender := $katexAutoRender | minify | fingerprint "sha512" -}} +{{ $mermaid := $mermaid | minify | fingerprint "sha512" -}} +{{ if .Site.Params.options.bootStrapJs -}} + +{{ end -}} +{{ if .Site.Params.options.highLight -}} + +{{ end -}} +{{ if .Site.Params.options.kaTex -}} + + +{{ end -}} + +{{ with .Params.mermaid -}} + +{{ end -}} +{{ if and (.Site.Params.options.flexSearch) (not .IsHome) -}} + +{{ end -}} {{ end -}} \ No newline at end of file From b958f0f76c455624fdf6e9c819ff33be3da505f8 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Tue, 4 Oct 2022 06:07:07 -0500 Subject: [PATCH 12/13] Added description --- content/en/curriculum/filecoin/drand(tutorial).md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/curriculum/filecoin/drand(tutorial).md b/content/en/curriculum/filecoin/drand(tutorial).md index 3ee251d1..cb394882 100644 --- a/content/en/curriculum/filecoin/drand(tutorial).md +++ b/content/en/curriculum/filecoin/drand(tutorial).md @@ -22,7 +22,7 @@ This example goes over how to use Drand as a client to retrieve a random value i ## Caveats * Drand mainnet releases a random number every 30 seconds. So if you run your results immediately after the other, you may get the exact same output. The problem that arises is if you want to test if the biased randomness works or not over time, it would take a really long time to test. -* This "biased" algo is not sophisticated, weights are not changing every iteration to adjust for any external factors. +* This "biased" algo is not sophisticated, it takes a random number and compares it against the list of user provided items, the last number smaller than the random number is chosen. ## Instructions Imagine you are a full time L5 software engineer and have more important things to think about than what to get for lunch. From cb15cff9c325b92374ab935014b66cea10131f34 Mon Sep 17 00:00:00 2001 From: Marco Rodriguez-Salinas Date: Wed, 12 Oct 2022 12:14:41 -0700 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: Enol <51820585+enoldev@users.noreply.github.com> --- content/en/curriculum/filecoin/drand(tutorial).md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/curriculum/filecoin/drand(tutorial).md b/content/en/curriculum/filecoin/drand(tutorial).md index cb394882..c01a22fb 100644 --- a/content/en/curriculum/filecoin/drand(tutorial).md +++ b/content/en/curriculum/filecoin/drand(tutorial).md @@ -16,13 +16,13 @@ This example goes over how to use Drand as a client to retrieve a random value i ## Pre-Requisites * Make sure you have Node version 12 or greater installed. You can find instructions on how to do that on the [NodeJS website](https://nodejs.org/en/). -* Download repo at XYZ and run: +* Clone the [launchpad-tutorials](https://github.com/protocol/launchpad-tutorials) repository and run `npm install` 1) `npm install` 2) `node bias.js` ## Caveats * Drand mainnet releases a random number every 30 seconds. So if you run your results immediately after the other, you may get the exact same output. The problem that arises is if you want to test if the biased randomness works or not over time, it would take a really long time to test. -* This "biased" algo is not sophisticated, it takes a random number and compares it against the list of user provided items, the last number smaller than the random number is chosen. +* This "biased" algorithm is not sophisticated, it takes a random number and compares it against the list of user provided items, the last number smaller than the random number is chosen. ## Instructions Imagine you are a full time L5 software engineer and have more important things to think about than what to get for lunch.