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 / enter_shikari_wallpaper.py
Last active March 27, 2024 04:26
a customizable script to create the logo of 'enter: shikari' as wallpaper using matplotlib (and python)
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
file_name = "wallpaper" # base name of the file
dpi = 650 # resolution
edge_color = "#FF0050" # color of the logo
scale_factor = 1.55 # how large shall it be?
landscape = True # landscape or portrait mode?
@nonchris
nonchris / discord-custom-help-command.py
Last active January 2, 2024 19:32
A kinda advanced custom "help" command for your Discord.py 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 Discord.py!
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.)
[Deleted] https://gist.github.com/StudioMFTechnologies/ad41bfd32b2379ccffe90b0e34128b8b
Rewritten and optimized by github.com/nonchris
@nonchris
nonchris / format_execption.py
Created November 4, 2023 22:32
might be helpful for someone
# might be useful for someone - but traceback.format_exc() is honestly better
# but this version gives at least some understanding of whats happening
def exec_location_info():
exc_type, exc_value, exc_traceback = sys.exc_info()
traceback_details = tb.extract_tb(exc_traceback, limit=None)
last_call = traceback_details[-1]
rel_path = os.path.relpath(last_call.filename)
@nonchris
nonchris / things_i_did.py
Last active August 18, 2023 11:43
things i did
"""
Things I did and always look up how I did it.
Feel free to suggest futher things you always forget :)
"""
# date format
f'{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}'
# current directory
f"{os.getcwd()}/{file_name}"
@nonchris
nonchris / minecraft-python-installation.txt
Last active August 3, 2023 13:30
Installationsanweisungen für den "python mit minecraft" Workshop
- Python programmieren mit Minecraft:
Anleitung siehe https://jandahlhaus.de/python-programmieren-mit-minecraft/
Falls das installierte Java zu neu ist und nicht unterstützt wird, bitte JDK11 von hier installieren:
https://adoptium.net/de/temurin/archive
Angepasst von Christoph Geron, Jun 2022
Änderungen:
- Anweisungen für Pycharm (Community Edition) install hinzugefügt
- Installation der python pakete in venv
- Jupyter erfordert und Anleitung zum Install und Test hinzugefügt
@nonchris
nonchris / extract-nb.sh
Last active January 5, 2023 17:37
Extract notebooks from nested zip-files
#!/usr/bin/env zsh
# tool to collect jupyter notebooks from the "download all zip from eCampus"
# options
# -z: zip folder with extracted content at the end
# -p: persitent -> unzipped folder not be deleted
# -t [file]: include full content of other zip in target folder (e.g. the tutor zip)
# positional arguments (needed to be positioned after optional ones)
@nonchris
nonchris / telegram-inline-bot.py
Created June 9, 2022 23:21
A very simple inline telegram bot as starting point (it tells you the time if you ask)
# pip3 install python-telegram-bot~=13.12
import datetime as dt
import os
from telegram import Bot, Update, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.ext import Updater, CallbackQueryHandler, CallbackContext, MessageHandler, Filters
# inline keyboard sent with messages
main_menu = InlineKeyboardMarkup([[InlineKeyboardButton('time', callback_data='time'),
@nonchris
nonchris / telegram-dialogue.py
Last active June 9, 2022 23:13
Telegram Bot Dialogue Keyboard (minimal example)
"""
This code shows how to create a custom keyboard for a telegram bot
Using https://github.com/python-telegram-bot/python-telegram-bot
"""
from 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
nonchris / custom-string-task.md
Last active May 2, 2022 19:42
A small task to play with function overloading and slicing

This task was migrated to github.com/nonchris/python.
The gist is no longer maintained.

Custom String

A small task to play with function overloading and slcining of elements.
Our goal is to implement a basic string-class that is mutable (parts can be changed after creation).

class CustomString:
 def __init__(self):
@nonchris
nonchris / reaction-role-fix.py
Created March 29, 2022 20:30
A quick d.py fix if your reaction role bot f*cked up
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():