Skip to content

Instantly share code, notes, and snippets.

View nonchris's full-sized avatar
👀
Why isn't it moving?

Chris G nonchris

👀
Why isn't it moving?
View GitHub Profile
@nonchris
nonchris / few-macros.tex
Created November 6, 2021 16:06
Things I use for making my life easier using LaTeX
% OWN macros
% vereinfacht den Befehl \texttt
\newcommand{\tttt}[1]{\texttt{#1}}
% vereinfacht den Befehl \textbf
\newcommand{\ttf}[1]{\textbf{#1}}
% vereinfacht den Befehl \textbf
\newcommand{\ttsl}[1]{\textsl{#1}}
\newcommand{\ttsf}[1]{\textsf{#1}}
% underline
@nonchris
nonchris / count_bot.py
Created October 9, 2021 22:47
Discord-Bot to counts messages in a channel that fulfill certain requirements
#!/bin/env python
import os
import re
from typing import Union, Dict
import discord
import discord.errors as d_errors
from discord.ext import commands
"""
@nonchris
nonchris / array_speed.py
Created July 3, 2021 15:06
Some quick array operations using python lists and numpy to get a feeling for performance
import sys
import time
import numpy as np
"""
Just a quick non scientific performance test for iterables from python and numpy.
This is only meant to get a rough feeling for different performances.
"""
@nonchris
nonchris / PlaceMNIST.py
Last active June 22, 2021 09:23
A task for the lecture 'computational itelligence' at the univeristy of bonn. It places three images from the MNIST dataset 'randomized' on a 64x64 image.
import random
from typing import Tuple, List
import numpy as np
import numpy.typing as npt
import torch
"""
This is a sub-task for the lecture 'computational itelligence' at the univeristy of bonn.
It places three images from the MNIST dataset 'randomized' on a 64x64 image.
@nonchris
nonchris / while_loop.tex
Created June 12, 2021 22:05
A basic loop written in tex
% NOTE: I do not guarantee that this is the best way of doing it
% but I wanna share it anyways since I can't really find any (commented) example code like this.
% ---
% command to print numbers one per line
% paste somewhere into your document (can be preamble or document itself)
% init counter variable
\newcount\i
@nonchris
nonchris / example-cog-usage.py
Last active May 2, 2021 08:43
Discord.py: Get Role by Role Name, ID or mention
import re
import discord
"""
A function that returns the matching role-id(s) in a list (as integers)
Needed Arguments: Comamnd-Context and Role-ID/ Role-Mention/ Role-Name (as a string)
The function will return a tuple of values that contains two values:
- A list with all matching role-id (should be one most of the times)
- The length of that list as secondary return value
@nonchris
nonchris / converter.py
Created November 7, 2020 12:47
symbol replacer for file content
def conv(file: str, new="converted-file.txt", symbol=",", rep=".") -> str:
"""
Needs: filename
Optional: filename, symbol to replace, symbol to replace with
- reads data, replaces a symbol with an other symbol of choice
- writes new data in file and returns filename
"""
with open(file, "r") as f: #open file
read = f.read() #read content
repl = read.replace(symbol, rep) #replace symbol