Skip to content

Instantly share code, notes, and snippets.

View CaptainZidgel's full-sized avatar
🦀

Zidgel CaptainZidgel

🦀
  • California
View GitHub Profile
@CaptainZidgel
CaptainZidgel / goroutines.go
Created December 11, 2019 08:21
Example of go routines via
//https://pythonprogramming.net/go/sync-goroutines-go-language-programming-tutorial/?completed=/go/goroutines-go-language-programming-tutorial/
//https://godoc.org/github.com/go-redis/redis#example-PubSub
package main
import (
"github.com/go-redis/redis/v7" //this is so hard to install :D
"fmt"
"sync"
"time"
)
@CaptainZidgel
CaptainZidgel / Luaexample.c
Created January 18, 2020 08:11
Documentations added to example code of Lua C API
//This code is from
//https://github.com/norman/hello-lua/blob/master/hello.c
//Thanks Norman!
//Unfortunately you forgot to actually document it so I'm adding comments as I learn. This is written for Lua 5.1.*, the API will change with versions, of course.
#include "lua.h"
#include "lauxlib.h"
#define MESSAGE "hello world!"
@CaptainZidgel
CaptainZidgel / bbtags.lua
Created February 17, 2020 07:38
A short implementation of mybb style markdown tags. Converts custom made tags (dictionary) to html.
--What you want is the function bb and the table dictionary, everything else is me building up to it.
local dictionary_one = {
cite = [[<a href="%1">%2</a>]],
i = [[<i>%2</i>]]
} --fitting only for one liner function.
local dictionary = {
cite = {open = [[<a href="%1">]], close = "</a>"},
i = {open = "<i>", close = "</i>"},
b = {open = "<b>", close = "</b>"}
@CaptainZidgel
CaptainZidgel / src_demo_filter.lua
Created May 2, 2020 02:11
Filter out source demo files into folders based on their maps.
local ffi = require("ffi")
local lfs = require("lfs")
local time_format = function(str)
local t = {}
string.gsub(str, '(%d%d%d%d)%-(%d%d)%-(%d%d)', function(y, m, d)
t.year = y
t.month = m
t.day = d
end)
@CaptainZidgel
CaptainZidgel / sw.sh
Last active May 11, 2020 23:21
sw.sh (swish) will swap your javascript cdn embeds between development and production mode. Requires Lua.
#!/bin/bash
# A script to swap distributions for imported scripts <production / development>
# Written by Zidgel for the public domain on 5/11/2020
# Usage: ./sw.sh [file] [library] [mode]
# Modes: d - Development | p - Production
# If you want to know what a line does, let me know.
lua -e "
print([[sw.sh: Executing swap]])
local dict = {
@CaptainZidgel
CaptainZidgel / parse_relays.py
Last active May 17, 2020 23:33
Take the relay ranges from a list of Valve's servers and turn them into an absolute list.
import json
import sys
import ipaddress
def unfurl_relays(src="NetworkDatagramConfig.json", psep=":"):
l = []
with open(src, "r") as f:
servers = json.loads(f.read())
for pop in servers['pops']:
key, pop = pop, servers['pops'][pop]
@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:
@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 / rgl.py
Last active August 22, 2020 05:17
Scrape RGL for teams and player IDs
#Original script by Zesty McLime https://github.com/zestymclime/RGLStats/blob/master/grablogs.py
#Modifed by CaptainZidgel for readability, functionality, and removal of pandas/numpy as dependency in the scraping section
from bs4 import BeautifulSoup
import cfscrape
import re
season3_divs = {'invite':'404','div1':'405','div2':'430','main':'406','intermediate':'407','amateur':'410','newcomer':'411'}
season2_divs = {'invite': '360', 'advanced': '361', 'main': '362', 'intermediate': '363', 'amateur': '359', 'newcomer': '364'}
def scrape_teams(divisions, div_ids = season3_divs, season_id = '70', league_id = '40'):
@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
}