diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3c0e816 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: deploy + +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-22.04 + environment: garage + steps: + - uses: actions/checkout@v4 + - name: Copy website + run: | + mkdir dist + files=$(git ls-files | grep -E '\.(html|css|js)$') + cp --parents $files ./dist + - name: Deploy website + run: | + aws configure set default.s3.addressing_style path + aws s3 sync ./dist s3://womangling.noratrieb.dev + env: + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_KEY }}" + AWS_REGION: garage + AWS_ENDPOINT_URL: https://garage.noratrieb.dev diff --git a/flashcard.js b/flashcard.js index 8761135..e6888ee 100644 --- a/flashcard.js +++ b/flashcard.js @@ -1,19 +1,18 @@ -const randomItem = (not) => { - let item; - - do { - const idx = Math.floor(Math.random() * window.ITEMS.length); - item = window.ITEMS[idx]; - } while (not && item === not); - - return item; -}; - const infoText = document.querySelector("#info-text"); function next() { infoText.textContent = ""; - const item = randomItem(); + + const candiates = [...window.ITEMS]; + + const nextRandomItem = () => { + const idx = Math.floor(Math.random() * candiates.length); + const result = candiates[idx]; + candiates.splice(idx, 1); + return result; + }; + + const item = nextRandomItem(); const mangle = Math.random() > 0.5; @@ -24,10 +23,10 @@ function next() { children[1].textContent = mangle ? item.means : item.mangle; const options = [ - randomItem(item), - randomItem(item), - randomItem(item), - randomItem(item), + nextRandomItem(item), + nextRandomItem(item), + nextRandomItem(item), + nextRandomItem(item), ]; const correctIdx = Math.floor(Math.random() * options.length); options[correctIdx] = item; diff --git a/lesson-1.html b/lesson-1.html index bc73a47..61b1dd1 100644 --- a/lesson-1.html +++ b/lesson-1.html @@ -31,7 +31,7 @@ Every C++ mangled symbol is prefixed with the string _Z. This signifies that this is a mangled C++ symbol. _Z starts with an underscore followed by an uppercase - letter. All symbols of that structures are reserved by the C + letter. All symbols of that structure are reserved by the C standard and cannot be used by programs. This ensures that there are no name collisions with normal C functions and mangled C++ functions.