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
/** Valid values are from 0 to 255 (inclusive) */ | |
export interface Colour { | |
red: number; | |
blue: number; | |
green: number; | |
} | |
/** Calculates an intermediary colour between 2 or 3 colours. | |
* @returns {Colour} Object with red, green, and blue number fields. | |
* @example -> {red: 123, blue: 255, green: 0} |
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 make_circle_coordinates(top = 0, left = 0, bottom = 300, right = 300, points = 20, visual = true) { | |
// e.g. top: 20, left: 20, right: 1900, bottom: 800 | |
let center = { | |
x: (left + right) / 2, | |
y: (top + bottom) / 2 | |
}, | |
radius = { | |
x: right - center.x, | |
y: bottom - center.y | |
}, |
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
<?php | |
function verify_captcha($token) { | |
$threshold = 0.5; // Score must be > threshold to pass captcha. | |
// Default is 0.5, although the majority of users will get 0.9 | |
$sites = ["localhost", "nachotoast.com", "ntgc.ddns.net"]; // Site names string, e.g. sub.domain.com:8080 | |
$secret = "Put your client secret here."; | |
$url = "https://www.google.com/recaptcha/api/siteverify"; | |
$data = array("secret" => $secret, "response" => $token); |
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
var files = | |
<?php | |
$files = array(); | |
foreach (glob('*.html') as $filename) { | |
$files[] = pathinfo($filename)['filename'] . "." . pathinfo($filename)['extension']; | |
} | |
echo json_encode($files); | |
?>, | |
folders = | |
<?php |
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
<?php | |
function add_folders($root) { | |
$local_folders_array = array(); | |
foreach (glob("$root/*", GLOB_ONLYDIR) as $folder) { | |
array_push($local_folders_array, ['foldername' => $folder]); | |
$arr2 = add_folders($folder); | |
if (count($arr2) > 0) foreach($arr2 as $subfolder) array_push($local_folders_array, ['foldername' => $subfolder['foldername']]); | |
} | |
return $local_folders_array; | |
} |
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
/** Compares the similarity between 2 strings using Levenshtein distance. | |
* @param {string} s1 The first string. | |
* @param {string} s2 The second string. | |
* @returns {number} Similarity between the 2 strings. | |
*/ | |
export function levenshteinDistance(s1: string, s2: string): number { | |
let longerString = s1; | |
let shorterString = s2; | |
if (s1.length < s2.length) { | |
longerString = s2; |
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
export type JoinVerification = 'token' | 'ip' | 'username' | 'gameCode'; | |
import { JwtPayload, verify } from 'jsonwebtoken'; | |
import { Socket } from 'socket.io'; | |
import { CONNECTION_SYSTEM } from '../constants/logging'; | |
import { | |
EMITTED_PLAYER_EVENTS, | |
RECEIVED_PLAYER_EVENTS, | |
} from '../constants/socketEvent'; | |
import { |
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
from filecmp import cmp | |
from requests import post | |
from json import loads | |
from datetime import datetime | |
# generate your token at https://github.com/settings/tokens (i'm not sure what scopes you will need) | |
token = 'api_token' | |
username = 'NachoToast' # doesn't have to be your username | |
url = 'https://api.github.com/graphql' |
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
// typing of implementation is not checked by the compiler, only calls to it | |
declare global { | |
interface Number { | |
between: (min: number, max: number) => boolean; | |
} | |
} | |
Object.defineProperty(Number.prototype, 'between', { | |
value(min: number, max: number): boolean { | |
return this >= min && this <= max; |
OlderNewer