Skip to content

Instantly share code, notes, and snippets.


Chris nonchris

View GitHub Profile
nonchris /
Last active Jun 22, 2021
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 / while_loop.tex
Created Jun 12, 2021
A basic loop written in tex
View while_loop.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
nonchris /
Created Nov 28, 2020
Telegram Bot Dialogue Keyboard (minimal example)
This code shows how to create a custom keyboard for a telegram bot
rom telegram.ext import Updater
from telegram.ext import CommandHandler
from telegram.ext import MessageHandler, Filters
from telegram import Bot
from telegram import KeyboardButton
from telegram import ReplyKeyboardMarkup
nonchris /
Created Nov 7, 2020
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 = #read content
repl = read.replace(symbol, rep) #replace symbol
nonchris /
Last active May 2, 2021 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 /
Last active Jun 18, 2021
A kinda advanced custom "help" command for your bots!
import discord
from discord.ext import commands
from discord.errors import Forbidden
"""This custom help command is a perfect replacement for the default one on any Discord Bot written in!
However, you must put "bot.remove_command('help')" in your bot, and the command must be in a cog for it to work.
Original concept by Jared Newsom (AKA Jared M.F.)
Rewritten and optimized by