Skip to content

Instantly share code, notes, and snippets.

View CodeDraken's full-sized avatar

Evan CodeDraken

View GitHub Profile
{
"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`"
@CodeDraken
CodeDraken / udemy-get-createdDate.js
Last active July 22, 2021 18:09
Run this on a course page to get the date the course was created and last updated.
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;
@CodeDraken
CodeDraken / automate-udemy-lichess.js
Created December 22, 2020 03:22
Automate the Web - Basics (Udemy, Lichess Scripts)
/// 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
@CodeDraken
CodeDraken / lichess-study-converter.js
Last active December 22, 2020 03:14
Converts Lichess study chapters to interactive lessons
// 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"
}
// properties and initial velocity
const defaultProps = {
bounce: 0.75,
radius: 30,
color: 'red'
}
export class Ball {
constructor (x = 0, y = 0, sceneProps, props) {
import Ball from './Ball'
// some default values
const defaultConfig = {
width: 500,
height: 500,
gravity: 0.25,
friction: 0.98
}
import Ball from './Ball'
const defaultConfig = {
width: 500,
height: 500,
gravity: 0.25,
friction: 0.98
}
export class Scene {
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
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
// 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)