Skip to content

Instantly share code, notes, and snippets.

View idkwebdev's full-sized avatar
😪

idk idkwebdev

😪
  • The Bahamas
  • 16:03 (UTC -04:00)
View GitHub Profile
@idkwebdev
idkwebdev / parseENV.js
Last active March 7, 2024 20:38
A quick and easy .env parser for Node.js
function parseENV(content) {
var contentArray = content.split('\n')
var contentDict = {}
for (var i = 0; i < contentArray.length; i++) {
if (contentArray[i] === '') { continue }
contentArray[i].replace('\r', '')
contentArray[i].trim()
function eloRating(player, opponent, score, K = 20) {
// Score is 1 if player won, 0 if opponent won, and 0.5 if a draw
// Information: https://www.omnicalculator.com/sports/elo
let difference = K * (score - (1 / (1 + 10**((opponent - player)/400))))
difference = Math.round(Math.abs(difference))
if (score >= 1) {
player += difference
opponent -= difference
} else if (score <= 0) {