{"schemaVersion":1,"contentVersion":"3.4.0","id":"intermediate.6","languages":{"javascript":{"id":"intermediate.6","title":"Protect a useful copy","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p><strong>Before this lesson:</strong> Copy and move text.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h3>Example</h3><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p>","teaches":["register:0","register:_","register:a"],"introduces":["register","y","p","yy","dd"],"constraints":[],"drills":[{"task":"Serve images from <code>media.northwind.shop</code> first, and keep the <code>img</code> host as the last fallback.","hint":"Copy the line before you change it. The change replaces what p puts, but \"0p still puts your copy.","mode":"jsx","start":"import { pickHost } from \"./pickHost\";\n\n// Image hosts, tried in order until one answers.\nexport const IMAGE_HOSTS = [\n  \"https://img.northwind.shop\",\n  \"https://images.cdn-eu.example\",\n  \"https://images.cdn-us.example\",\n];\n\nexport const imageUrl = (path) => pickHost(IMAGE_HOSTS) + path;","startCursor":{"line":4,"ch":11},"paths":[{"keys":["y","y","c","w","media","<Esc>","2","j","\"","0","p"],"tier":"idiomatic","technique":"register:0","core":["register:0"],"note":"cw put img in the unnamed register, so a plain p would put img. Register 0 still has the line you copied."}],"target":"import { pickHost } from \"./pickHost\";\n\n// Image hosts, tried in order until one answers.\nexport const IMAGE_HOSTS = [\n  \"https://media.northwind.shop\",\n  \"https://images.cdn-eu.example\",\n  \"https://images.cdn-us.example\",\n  \"https://img.northwind.shop\",\n];\n\nexport const imageUrl = (path) => pickHost(IMAGE_HOSTS) + path;","language":"javascript","evidence":"guided","canonicalKey":"intermediate.6#0","canonicalFingerprint":"1vzonah"},{"task":"The preview server is back on its old address, the one in the comment on line 13. Put it in both empty strings and delete the comment.","hint":"\"_dd deletes the line without touching what you copied, so p and P still put the address.","mode":"jsx","start":"// End-to-end test settings. The tests start the preview server themselves.\nexport const baseURL = \"\";\nexport const webServer = { command: \"npm run preview\", url: \"\" };\n\nexport const browsers = [\"chromium\", \"firefox\"];\nexport const retries = process.env.CI ? 2 : 0;\nexport const timeoutMs = 30_000;\n\n// Screenshots only when a test fails, to keep the reports small.\nexport const screenshot = \"only-on-failure\";\nexport const trace = \"retain-on-failure\";\n\n// The preview server used to run on \"http://localhost:4173\".\nexport const workers = process.env.CI ? 1 : undefined;\nexport const reporter = [[\"list\"], [\"html\", { open: \"never\" }]];","startCursor":{"line":14,"ch":0},"paths":[{"keys":["2","k","y","i","\"","\"","_","d","d","2","G","f","\"","p","j","$","F","\"","P"],"tier":"idiomatic","technique":"register:_","core":["register:_"],"note":"The \"_ register takes the deleted line, so the copy stays for both puts."}],"target":"// End-to-end test settings. The tests start the preview server themselves.\nexport const baseURL = \"http://localhost:4173\";\nexport const webServer = { command: \"npm run preview\", url: \"http://localhost:4173\" };\n\nexport const browsers = [\"chromium\", \"firefox\"];\nexport const retries = process.env.CI ? 2 : 0;\nexport const timeoutMs = 30_000;\n\n// Screenshots only when a test fails, to keep the reports small.\nexport const screenshot = \"only-on-failure\";\nexport const trace = \"retain-on-failure\";\n\nexport const workers = process.env.CI ? 1 : undefined;\nexport const reporter = [[\"list\"], [\"html\", { open: \"never\" }]];","language":"javascript","evidence":"guided","canonicalKey":"intermediate.6#1","canonicalFingerprint":"g98nvb"},{"task":"Klarna uses the sandbox keys until it has its own. Copy the public key and then the webhook secret into its two empty strings, in that order.","hint":"\"aye copies the key into register a, and the next copy leaves it alone. \"ap puts it back.","mode":"jsx","start":"// Payments for the test shop. Klarna borrows the sandbox keys.\nexport const payments = {\n  klarna: { keys: [\"\", \"\"], country: \"SE\" },\n  paypal: { clientId: \"AYkq3_sandbox_paypal\", currency: \"EUR\" },\n  ideal: { enabled: true, banks: [\"ABN\", \"ING\", \"RABO\"] },\n};\n\nexport const retries = { attempts: 3, backoffMs: 500 };\nexport const statementName = \"NORTHWIND TEST\";\n// The sandbox account. Live keys never go in this file.\nexport const sandbox = {\n  publicKey: \"pk_test_51HcSandboxNorthwind\",\n  webhookSecret: \"whsec_sandbox_4kQ9xT\",\n  accountName: \"Northwind Test\",\n};","startCursor":{"line":11,"ch":14},"paths":[{"keys":["\"","a","y","e","j","y","i","\"","3","G","f","\"","\"","a","p","W","p"],"tier":"idiomatic","technique":"register:a","core":["register:a"],"note":"Register a keeps the first key while the second copy goes to the unnamed register, so one trip up does both."}],"target":"// Payments for the test shop. Klarna borrows the sandbox keys.\nexport const payments = {\n  klarna: { keys: [\"pk_test_51HcSandboxNorthwind\", \"whsec_sandbox_4kQ9xT\"], country: \"SE\" },\n  paypal: { clientId: \"AYkq3_sandbox_paypal\", currency: \"EUR\" },\n  ideal: { enabled: true, banks: [\"ABN\", \"ING\", \"RABO\"] },\n};\n\nexport const retries = { attempts: 3, backoffMs: 500 };\nexport const statementName = \"NORTHWIND TEST\";\n// The sandbox account. Live keys never go in this file.\nexport const sandbox = {\n  publicKey: \"pk_test_51HcSandboxNorthwind\",\n  webhookSecret: \"whsec_sandbox_4kQ9xT\",\n  accountName: \"Northwind Test\",\n};","language":"javascript","evidence":"guided","canonicalKey":"intermediate.6#2","canonicalFingerprint":"1j8ur65"}]},"python":{"id":"intermediate.6","title":"Protect a useful copy","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p><strong>Before this lesson:</strong> Copy and move text.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h3>Example</h3><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p>","teaches":["register:0","register:_","register:a"],"introduces":["register","y","p","yy","dd"],"constraints":[],"drills":[{"task":"Serve images from <code>media.northwind.shop</code> first, and keep the <code>img</code> host as the last fallback.","hint":"Copy the line before you change it. The change replaces what p puts, but \"0p still puts your copy.","mode":"python","start":"from shop.images.pick import pick_host\n\n# Image hosts, tried in order until one answers.\nIMAGE_HOSTS = [\n    \"https://img.northwind.shop\",\n    \"https://images.cdn-eu.example\",\n    \"https://images.cdn-us.example\",\n]\n\n\ndef image_url(path):\n    return pick_host(IMAGE_HOSTS) + path","startCursor":{"line":4,"ch":13},"paths":[{"keys":["y","y","c","w","media","<Esc>","2","j","\"","0","p"],"tier":"idiomatic","technique":"register:0","core":["register:0"],"note":"cw put img in the unnamed register, so a plain p would put img. Register 0 still has the line you copied."}],"target":"from shop.images.pick import pick_host\n\n# Image hosts, tried in order until one answers.\nIMAGE_HOSTS = [\n    \"https://media.northwind.shop\",\n    \"https://images.cdn-eu.example\",\n    \"https://images.cdn-us.example\",\n    \"https://img.northwind.shop\",\n]\n\n\ndef image_url(path):\n    return pick_host(IMAGE_HOSTS) + path","language":"python","evidence":"guided","canonicalKey":"intermediate.6#0","canonicalFingerprint":"1vzonah"},{"task":"The preview server is back on its old address, the one in the comment on line 13. Put it in both empty strings and delete the comment.","hint":"\"_dd deletes the line without touching what you copied, so p and P still put the address.","mode":"python","start":"\"\"\"Settings for the browser tests, which start the preview server on their own.\"\"\"\nBASE_URL = \"\"\nWEB_SERVER = {\"command\": \"npm run preview\", \"url\": \"\"}\n\nBROWSERS = (\"chromium\", \"webkit\")\nRETRIES_ON_CI = 2\nTEST_TIMEOUT_SECONDS = 45\n\n# Keep a screenshot and a video of failed tests only.\nSCREENSHOTS = \"only-on-failure\"\nVIDEO = \"retain-on-failure\"\n\n# The preview server ran on \"http://localhost:4173\" before the move.\nWORKERS_ON_CI = 1\nREPORT_DIR = \"reports/e2e\"","startCursor":{"line":14,"ch":0},"paths":[{"keys":["2","k","y","i","\"","\"","_","d","d","2","G","f","\"","p","j","$","F","\"","P"],"tier":"idiomatic","technique":"register:_","core":["register:_"],"note":"The \"_ register takes the deleted line, so the copy stays for both puts."}],"target":"\"\"\"Settings for the browser tests, which start the preview server on their own.\"\"\"\nBASE_URL = \"http://localhost:4173\"\nWEB_SERVER = {\"command\": \"npm run preview\", \"url\": \"http://localhost:4173\"}\n\nBROWSERS = (\"chromium\", \"webkit\")\nRETRIES_ON_CI = 2\nTEST_TIMEOUT_SECONDS = 45\n\n# Keep a screenshot and a video of failed tests only.\nSCREENSHOTS = \"only-on-failure\"\nVIDEO = \"retain-on-failure\"\n\nWORKERS_ON_CI = 1\nREPORT_DIR = \"reports/e2e\"","language":"python","evidence":"guided","canonicalKey":"intermediate.6#1","canonicalFingerprint":"g98nvb"},{"task":"Klarna uses the sandbox keys until it has its own. Copy the public key and then the webhook secret into its two empty strings, in that order.","hint":"\"aye copies the key into register a, and the next copy leaves it alone. \"ap puts it back.","mode":"python","start":"\"\"\"Payments for the test shop. Klarna uses the sandbox keys until it has its own.\"\"\"\n\nKLARNA_KEYS = (\"\", \"\")\nKLARNA_COUNTRY = \"SE\"\nPAYPAL_CLIENT_ID = \"AYkq3_sandbox_paypal\"\nIDEAL_BANKS = [\"ABN\", \"ING\", \"RABO\"]\nIDEAL_RETURN_PATH = \"/checkout/ideal/return\"\n\nRETRY_ATTEMPTS = 3\nSTATEMENT_NAME = \"NORTHWIND TEST\"\n# The sandbox account. Nothing live belongs here.\nSANDBOX_PUBLIC_KEY = \"pk_test_51HcSandboxNorthwind\"\nSANDBOX_WEBHOOK_SECRET = \"whsec_sandbox_4kQ9xT\"\nSANDBOX_ACCOUNT = \"Northwind Test\"\nSANDBOX_CURRENCY = \"SEK\"","startCursor":{"line":11,"ch":22},"paths":[{"keys":["\"","a","y","e","j","y","i","\"","3","G","f","\"","\"","a","p","W","p"],"tier":"idiomatic","technique":"register:a","core":["register:a"],"note":"Register a keeps the first key while the second copy goes to the unnamed register, so one trip up does both."}],"target":"\"\"\"Payments for the test shop. Klarna uses the sandbox keys until it has its own.\"\"\"\n\nKLARNA_KEYS = (\"pk_test_51HcSandboxNorthwind\", \"whsec_sandbox_4kQ9xT\")\nKLARNA_COUNTRY = \"SE\"\nPAYPAL_CLIENT_ID = \"AYkq3_sandbox_paypal\"\nIDEAL_BANKS = [\"ABN\", \"ING\", \"RABO\"]\nIDEAL_RETURN_PATH = \"/checkout/ideal/return\"\n\nRETRY_ATTEMPTS = 3\nSTATEMENT_NAME = \"NORTHWIND TEST\"\n# The sandbox account. Nothing live belongs here.\nSANDBOX_PUBLIC_KEY = \"pk_test_51HcSandboxNorthwind\"\nSANDBOX_WEBHOOK_SECRET = \"whsec_sandbox_4kQ9xT\"\nSANDBOX_ACCOUNT = \"Northwind Test\"\nSANDBOX_CURRENCY = \"SEK\"","language":"python","evidence":"guided","canonicalKey":"intermediate.6#2","canonicalFingerprint":"1j8ur65"}]},"text":{"id":"intermediate.6","title":"Protect a useful copy","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p><strong>Before this lesson:</strong> Copy and move text.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h3>Example</h3><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p>","teaches":["register:0","register:_","register:a"],"introduces":["register","y","p","yy","dd"],"constraints":[],"drills":[{"task":"Serve images from <code>media.northwind.shop</code> first, and keep the <code>img</code> host as the last fallback.","hint":"Copy the line before you change it. The change replaces what p puts, but \"0p still puts your copy.","mode":"text/plain","start":"# Image hosts, tried in order until one answers. One per line.\nhttps://img.northwind.shop\nhttps://images.cdn-eu.example\nhttps://images.cdn-us.example\n\n# The storefront reads this file when it starts.","startCursor":{"line":1,"ch":8},"paths":[{"keys":["y","y","c","w","media","<Esc>","2","j","\"","0","p"],"tier":"idiomatic","technique":"register:0","core":["register:0"],"note":"cw put img in the unnamed register, so a plain p would put img. Register 0 still has the line you copied."}],"target":"# Image hosts, tried in order until one answers. One per line.\nhttps://media.northwind.shop\nhttps://images.cdn-eu.example\nhttps://images.cdn-us.example\nhttps://img.northwind.shop\n\n# The storefront reads this file when it starts.","language":"text","evidence":"guided","canonicalKey":"intermediate.6#0","canonicalFingerprint":"1vzonah"},{"task":"The preview server is back on its old address, the one in the comment on line 13. Put it in both empty strings and delete the comment.","hint":"\"_dd deletes the line without touching what you copied, so p and P still put the address.","mode":"text/plain","start":"# Browser test job. It starts the preview server before the first test.\nbase_url: \"\"\nweb_server: {command: \"npm run preview\", url: \"\"}\n\nbrowsers: [chromium, firefox, webkit]\nretries: 2\ntimeout: 60s\n\n# A failed test keeps its screenshot and its trace.\nscreenshot: only-on-failure\ntrace: retain-on-failure\n\n# Preview address from last year: \"http://localhost:4173\"\nworkers: 2\nreport: html","startCursor":{"line":14,"ch":0},"paths":[{"keys":["2","k","y","i","\"","\"","_","d","d","2","G","f","\"","p","j","$","F","\"","P"],"tier":"idiomatic","technique":"register:_","core":["register:_"],"note":"The \"_ register takes the deleted line, so the copy stays for both puts."}],"target":"# Browser test job. It starts the preview server before the first test.\nbase_url: \"http://localhost:4173\"\nweb_server: {command: \"npm run preview\", url: \"http://localhost:4173\"}\n\nbrowsers: [chromium, firefox, webkit]\nretries: 2\ntimeout: 60s\n\n# A failed test keeps its screenshot and its trace.\nscreenshot: only-on-failure\ntrace: retain-on-failure\n\nworkers: 2\nreport: html","language":"text","evidence":"guided","canonicalKey":"intermediate.6#1","canonicalFingerprint":"g98nvb"},{"task":"Klarna uses the sandbox keys until it has its own. Copy the public key and then the webhook secret into its two empty strings, in that order.","hint":"\"aye copies the key into register a, and the next copy leaves it alone. \"ap puts it back.","mode":"text/plain","start":"# Payments for the test shop. Until Klarna has keys of its own, it shares the sandbox ones.\nklarna:\n  keys: [\"\", \"\"]\n  country: SE\npaypal:\n  client_id: AYkq3_sandbox_paypal\nideal:\n  banks: [ABN, ING, RABO]\nretries: 3\n# The sandbox account, with test keys only.\nsandbox:\n  public_key: \"pk_test_51HcSandboxNorthwind\"\n  webhook_secret: \"whsec_sandbox_4kQ9xT\"\n  account: Northwind Test\n  currency: SEK","startCursor":{"line":11,"ch":15},"paths":[{"keys":["\"","a","y","e","j","y","i","\"","3","G","f","\"","\"","a","p","W","p"],"tier":"idiomatic","technique":"register:a","core":["register:a"],"note":"Register a keeps the first key while the second copy goes to the unnamed register, so one trip up does both."}],"target":"# Payments for the test shop. Until Klarna has keys of its own, it shares the sandbox ones.\nklarna:\n  keys: [\"pk_test_51HcSandboxNorthwind\", \"whsec_sandbox_4kQ9xT\"]\n  country: SE\npaypal:\n  client_id: AYkq3_sandbox_paypal\nideal:\n  banks: [ABN, ING, RABO]\nretries: 3\n# The sandbox account, with test keys only.\nsandbox:\n  public_key: \"pk_test_51HcSandboxNorthwind\"\n  webhook_secret: \"whsec_sandbox_4kQ9xT\"\n  account: Northwind Test\n  currency: SEK","language":"text","evidence":"guided","canonicalKey":"intermediate.6#2","canonicalFingerprint":"1j8ur65"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Copy and move text.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h2 class=\"prose-subhead\">Example</h2><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Copy and move text.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h2 class=\"prose-subhead\">Example</h2><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Copy and move text.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Keep something you copied safe while you delete other text, or save it under a name.</p><p>Copying also fills register 0. A later delete or change replaces what a plain p puts, but register 0 keeps your last copy, so \"0p still puts it. \"_dd deletes a line without touching your copy. \"ayy copies a line into register a and \"ap puts it. A lowercase a replaces what's in that register. An uppercase A adds to it instead, but you won't need that here.</p><h2 class=\"prose-subhead\">Example</h2><p>Copy a heading with yy, delete an obsolete line with dd, then use \"0p to put the heading instead of the deleted line.</p><p>Use Start over to try again.</p></div></details>"}}}