Skip to content

Instantly share code, notes, and snippets.

View CaptainZidgel's full-sized avatar
🦀

Zidgel CaptainZidgel

🦀
  • California
View GitHub Profile
@CaptainZidgel
CaptainZidgel / mgeme_mock_server.py
Created March 2, 2023 09:56
Example of faking a server for mgeme testing (200x easier than sourcemod!)
# Example of faking a server for mgeme testing
# (Mgeme is a project of mine, but this code example may be useful to somebody else anyway)
import asyncio
import websockets
import sys
import json
host = sys.argv[1]
port = sys.argv[2]
secret = sys.argv[3]
@CaptainZidgel
CaptainZidgel / nhl_roster.py
Created October 26, 2021 07:39
Get roster list containing jersey numbers and player names from a NHL API gameid. (You could modify to get other fields if you wanted to).
#Get roster reports from NHL's official API
#https://gitlab.com/dword4/nhlapi/-/tree/master/
#https://www.kevinsidwar.com/iot/2017/7/1/the-undocumented-nhl-stats-api
import requests
class Person: #I don't have any reason for making this a class besides dot notation
def __init__(self, n, name):
self.n = n
self.name = name
@CaptainZidgel
CaptainZidgel / vdub_job_maker.py
Created August 22, 2021 20:58
Creates jobs for vdub from a folder of lawena output
#https://www.virtualdub.org/docs/vdscript.txt
#Open vdub>File>Job Control>File>Load job list badda bing badda boom
import os
import re
frame_group_pattern = re.compile('([a-z]\d)_(\d+)\.tga')
jf_out = input("This file should be saved to...>")
in_dir = input("Frames In Dir >")
out_dir = input("AVI Out Dir >")
"""
A simple Discord bot to display a user queue with add up / unadd buttons via reactions - a basic task most bots will need.
This bot uses a single Cog for the purposes of using member attributes to keep track of data in a typical OOP w/ async fashion.
"""
import discord
from discord.ext import commands
TOKEN = open("token.txt", "r").read()
prefix = "!"
@CaptainZidgel
CaptainZidgel / upload_cli.py
Created March 6, 2021 04:42
An uploading tool for a forthcoming application - hopefully a useful template for you
import requests
import cmd
import os
import magic
import json
import sys
URL = "http://127.0.0.1:8080/"
def mimetype(path):
@CaptainZidgel
CaptainZidgel / electors_per_state.py
Last active November 4, 2020 21:19
Party Votes by State 1976-2016 as a dict:
#There have been 538 electors since 1964
#I am operating on the critical - but possibly wrong - assumption that the number of electors per state is static
electors = {
"California": 55,
"Nevada": 6,
"Oregon": 7,
"Washington": 12,
"Idaho": 4,
"Utah": 6,
@CaptainZidgel
CaptainZidgel / DefineLog.kt
Created August 24, 2020 07:57
Non comprehensive definition of logs.tf logs for kotlin
//This class is nonexhaustive, as I didn't want to spend an hour creating a bunch of useless subclasses.
class Log(
val version: Int,
val success: Boolean,
val info: Info,
val players: HashMap<String, pInfo>
) {
data class pInfo(
val team: String,
val class_stats: List<class_stats>,
@CaptainZidgel
CaptainZidgel / emean.kt
Created August 23, 2020 20:40
Kotlin Expanding Mean
//An expanding mean function created as my own implementation of pandas' .expanding(window).mean()
//Only thing missing is the window size option.
fun expandingMean (data: List<Float>): MutableList<Float> {
var result = mutableListOf<Float>()
var i = 0
for (value in data.listIterator()) {
result.add(data.slice(0..i).average().toFloat())
i += 1
}
@CaptainZidgel
CaptainZidgel / tf2seasons.py
Created August 15, 2020 00:37
TF2 Competitive Seasons as an ordered list of dicts with datetime objects as start and end dates
from datetime import datetime
seasons_ESEA = {
3: (datetime(2009, 5, 4), datetime(2009, 8, 2)),
4: (datetime(2009, 8, 9), datetime(2009, 11, 15)),
5: (datetime(2009, 11, 30), datetime(2010, 3, 6)),
6: (datetime(2010, 4, 12), datetime(2010, 7, 13)),
7: (datetime(2010, 7, 23), datetime(2010, 11, 30)),
8: (datetime(2011, 1, 6), datetime(2011, 4, 14)),
9: (datetime(2011, 6, 13), datetime(2011, 9, 25)),
@CaptainZidgel
CaptainZidgel / alias_suggester.py
Created August 12, 2020 02:11
Quick and simple collecter of aliases used in logs. Non interactive, requires you to copy/paste values to wherever you're trying to assosciate IDs with permanent Aliases.
import json
import os
from collections import Counter
import sys
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
IDs = {}
for file in os.listdir(".logs"):
with open(os.path.join('.logs', file), "r") as f: