Skip to content

Instantly share code, notes, and snippets.

View idkwebdev's full-sized avatar
😪

idk idkwebdev

😪
  • The Bahamas
  • 05:07 (UTC -04:00)
View GitHub Profile
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) {
@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()
@idkwebdev
idkwebdev / oauth.py
Created January 27, 2025 00:16
TickTick OAuth Helper
import requests
from requests.auth import HTTPBasicAuth as Auth
url = 'https://ticktick.com/oauth/authorize?scope=tasks:write%20tasks:read&client_id={client_id}&state=state&redirect_uri=https://www.example.com/&response_type=code'
print('Welcome to the TickTick API OAuth2.0 setup.')
print('Before beginning, go to "https://developer.ticktick.com/manage" and create a new app.')
print('Under "OAuth redirect URL", add "https://www.example.com/"')
print()
client_id = input('What is your client ID?\n> ')