This file contains 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
/** | |
* circumscribe(Number x1, Number y1, Number x2, Number y2, Number x3, Number y3) | |
* | |
* Returns an object describing the circle's center, radius, and equation in Standard Form. | |
* Returns an error if points are overlapping or on the same line. | |
* Example: `circumscribe(5, -3, -1, -3, 2, -6)` returns {circumcenter: [2, -3], equation: "(x-2)²+(y+3)²=9", radius: 3} | |
**/ | |
function circumscribe(x1, y1, x2, y2, x3, y3) { | |
// It took some math to figure this out but I'll never tell you how 😈 |
This file contains 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() { | |
const solutions = window.gameData.today.answers; | |
let list = document.createElement("div"); | |
list.style = `position:fixed;width:15%;height:40%;left:2%;top:30%; | |
border:5px solid black;z-index:999;padding:5px;background:white; | |
overflow-y:scroll;resize:both;`; | |
document.body.append(list); | |
list.innerHTML = `<h2 style='cursor:all-scroll;user-select:none;font-size:20px;'>Word list</h2> | |
<hr/><ul></ul>`; | |
let listEl = list.children[2]; |
This file contains 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
// ==UserScript== | |
// @name Hide Upvote Count | |
// @description Hides upvote count on posts and comments on Reddit | |
// @match *://*.reddit.com/* | |
// @version 0.0.0.0.1 | |
// @developer gosoccerboy5 | |
// ==/UserScript== | |
(function() { | |
'use strict'; |
This file contains 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
/** | |
* area(Array<Array<Number>> ...list) | |
* | |
* takes in a set of points (in clockwise or counterclockwise order) and returns the area of the polygon the points form | |
* example call: `area([3, 10], [9, 7], [11, 2], [2, 2]);` | |
**/ | |
function area(...list) { | |
let total = 0; | |
for (let index = 0; index < list.length; index++) { |
This file contains 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
// Find a point between two points that fits a certain ratio of distance to both of them | |
function findMidpointFromPointsAndRatio(a, b, c, d, f = 1, g = 1) { | |
/** | |
Example: The coordinates of the endpoints of Line ST are S(10, 2) and T(17, 16). | |
Point U is on ST and divides it such that SU:TU is 2:5. | |
How the function would be called: findMidpointFromPointsAndRatio(10, 2, 17, 16, 2, 5); | |
What it should return: Array [12, 6] | |
**/ | |
const h = f+g; | |
return [a + f*(c-a)/h, b + f*(d-b)/h]; |
This file contains 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
// Parse a quadratic, find its coefficients, and feed it into the "quadratic" function | |
function parseQuadratic(input) { | |
const refined = input.toLowerCase().replaceAll(" ", ""); | |
// A regex that matches and finds the coefficients in a quadratic in the format ax^2+bx+c | |
const matches = refined.match(/(-?[0-9.]*)[a-z]\^2(?:([+-][0-9.]*)[a-z])?([+-][0-9.]*)?/) | |
.slice(1) // We don't want the first value (which is the full match) | |
.map(str => Number( // we will convert our refined coefficients from a string to a number | |
(str ?? "0") // If the current item in the matches list is undefined, it was not provided, the coefficient will be 0 | |
.replace(/^[+-]?$/, x => x + "1"))); // If we have only +/- or even no coefficient along with the x, we assume it is 1 |
This file contains 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
// Use this to await the next event occurring on an element. | |
/* Usage example: | |
await querySelector("#myButton").next("click"); | |
print("Button clicked!"); | |
*/ | |
import "dart:html"; | |
import "dart:async"; | |
extension on Element { |
This file contains 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
const pi = 3.1415; | |
extension NumbersAsFunctions on num { | |
num call(num other) => this * other; | |
} | |
void main() { | |
print(2(pi)); // 6.283 | |
} |
This file contains 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 "dart:html"; | |
final input = querySelector("#input") as TextAreaElement; | |
final target = querySelector("#output") as TextAreaElement; | |
final number = querySelector("#amount") as InputElement; | |
final trigger = querySelector("#trigger") as ButtonElement; | |
// Setup elements | |
void main() { | |
input.addEventListener("input", (Event event) { |
This file contains 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 "dart:html"; | |
final input = querySelector("#input") as TextAreaElement; | |
final output = querySelector("#output") as TextAreaElement; | |
final radio = querySelector("#tabs2spaces") as RadioButtonInputElement; | |
final button = querySelector("#button") as ButtonElement; | |
final spacesPerTabs = querySelector("#spacesPerTabs") as InputElement; | |
// Setup elements | |
void main() { |
NewerOlder