This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "questions": [ | |
| { | |
| "title": "What's the output?", | |
| "code": "function sayHi() {\n console.log(name);\n console.log(age);\n var name = 'Lydia';\n let age = 21;\n}\n\nsayHi();", | |
| "choices": { | |
| "A": "`Lydia` and `undefined`", | |
| "B": "`Lydia` and `ReferenceError`", | |
| "C": "`ReferenceError` and `21`", | |
| "D": "`undefined` and `ReferenceError`" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getCourseId() { | |
| const courseEl = document.querySelector("body#udemy"); | |
| if (!courseEl) throw new Error("Must be on a Udemy course page!"); | |
| const id = courseEl.dataset.clpCourseId; | |
| if (!id) { | |
| // for active course | |
| const secondaryId = document.querySelector("#udemy > div.main-content-wrapper > div.main-content > div").dataset.moduleArgs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// UDEMY /// | |
| // Resets progress | |
| // ERROR PRONE WAY | |
| // checkboxes.forEach((checkbox, i) => { | |
| // setTimeout(() => checkbox.click(), i * 50); | |
| // }); | |
| // all *checked* checkbox elements within the "curriculum section" | |
| var checkboxes = document |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // all gear buttons for the chapters | |
| var chapterOptionButtons = document.querySelectorAll('.study__chapters act') | |
| // "id": "value" | |
| var defaultOptions = { | |
| // available options: normal, practice, conceal, gamebook | |
| "chapter-mode": "gamebook", | |
| // "chapter-orientation": "white" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // properties and initial velocity | |
| const defaultProps = { | |
| bounce: 0.75, | |
| radius: 30, | |
| color: 'red' | |
| } | |
| export class Ball { | |
| constructor (x = 0, y = 0, sceneProps, props) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ball from './Ball' | |
| // some default values | |
| const defaultConfig = { | |
| width: 500, | |
| height: 500, | |
| gravity: 0.25, | |
| friction: 0.98 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ball from './Ball' | |
| const defaultConfig = { | |
| width: 500, | |
| height: 500, | |
| gravity: 0.25, | |
| friction: 0.98 | |
| } | |
| export class Scene { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| update () { | |
| const { props, sceneProps } = this | |
| // bottom bound / floor | |
| if (this.y + props.radius >= sceneProps.height) { | |
| this.velY *= -props.bounce | |
| this.y = sceneProps.height - props.radius | |
| this.velX *= sceneProps.friction | |
| } | |
| // top bound / ceiling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| draw (ctx) { | |
| const { x, y, props } = this | |
| ctx.save() | |
| ctx.beginPath() | |
| ctx.fillStyle = props.color | |
| ctx.arc( | |
| x, y, | |
| props.radius, | |
| 0, Math.PI * 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // properties and initial velocity | |
| const defaultProps = { | |
| bounce: 0.75, | |
| radius: 30, | |
| color: 'red', | |
| // starting velocity | |
| startVelX: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1), | |
| startVelY: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1) |
NewerOlder