Skip to content

Instantly share code, notes, and snippets.

View mogggen's full-sized avatar
🤔
Heads or tails, 1000x tails in a row. What's the probability the coin is uneven?

Morgan Nyman mogggen

🤔
Heads or tails, 1000x tails in a row. What's the probability the coin is uneven?
View GitHub Profile
@mogggen
mogggen / German tank problem unit test.py
Created September 26, 2025 15:59
Re implementation of the example variation of German tank problem from Zack Star
from random import choices
# German tank problem
CATCH_FIRST = 1000
CATCH_SECOND = 1000
TRIALS = 5
POPULATION = 80_000
class Tank:
@mogggen
mogggen / merge-todos.ps1
Created September 24, 2025 15:49
Keep track of all your todo files
[CmdletBinding()]
param (
# Where to save the Summary 'TODO.txt' file.
[Parameter()][String]$todoPath = '.',
# Which paths to search in.
[Parameter()][String[]]$searchPaths = @($env:HOMEDIRECTORY),
# What file extensions to look for (case-insensitive). No file extension is implied.
[Parameter()][String[]]$fileExtensions = @('txt', 'md')
)
@mogggen
mogggen / average daily commits.ps1
Created August 20, 2025 13:04
Average commits per day per user
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[string]
$branch = 'HEAD',
[Parameter(Mandatory = $false)]
[datetime]
$after,
[Parameter(Mandatory = $false)]
[datetime]
@mogggen
mogggen / Plug-and-play.py
Created June 30, 2025 22:07
C++ Hello world!
with open("main.cpp", "w") as f:
f.write("int main()\n{\n\t\n}")
with open("CMakeLists.txt", "w") as f:
f.write("cmake_minimum_required(VERSION 3.6)\nadd_executable(app main.cpp)")
import os
os.system("cmake -S . -B ./build/")
path = "\""+os.getcwd()+"\\build\\Project.sln\""
os.system(path)
@mogggen
mogggen / json version list genertor.py
Created June 27, 2025 11:51
Json version list genertor
import json as table
from random import shuffle
versions = lambda i : "20"+ str(20+i//4+1) + "." + str(i%4+1) + ""
def deploy(number_of_versions):
from os.path import dirname as di, join as rel
for ver in number_of_versions:
filename = rel(di(__file__), "version-news", versions(ver))
f=open(file=filename, mode="w")
@mogggen
mogggen / all unique legal chess notations.py
Created June 27, 2025 11:37
v 0.1 - needs to fix bishop and queen
@mogggen
mogggen / bostadsköer.json
Created June 25, 2025 10:09
Auto-retrieve
{"http://localhost:8000/temp_site.html": "", "http://localhost:8000/other.html": ""}
@mogggen
mogggen / readme.txt
Last active June 23, 2025 11:04
Neovim motion cheat sheet
most used vim motions
--------------------------
Help
:h[elp] [command] - get the help page of [command]
:q[uit]a[ll]! - quit Neovim without saving anything!
:w [file] - save current/[file]
:e [file] - [open]/reload file
@mogggen
mogggen / Homemade DeserializeXNode.cs
Last active June 17, 2025 08:46
DeserializeXNode without Newtonsoft, only tested for RestSharp API
using System.Xml;
using System.Xml.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
var restSharpJson = """
{
"errorResponse":
{
@mogggen
mogggen / call-graph-mermaid-generator.py
Created June 9, 2025 08:52
mermaid call graph generator
import re
content = """
"""
# readfile
# find the matching function name "Foofuncname("
def get_graph_node(loaad):
thing = re.findall(r"(?:\w+\s)* (\w+)\(", loaad)