Skip to content

Instantly share code, notes, and snippets.

@C0D3D3V
C0D3D3V / lti.py
Created March 9, 2023 16:25
lti moodle mod
from typing import Dict, List
from moodle_dl.config import ConfigHelper
from moodle_dl.moodle.mods import MoodleMod
from moodle_dl.types import Course, File
class LTIMod(MoodleMod):
MOD_NAME = 'lti'
MOD_PLURAL_NAME = 'ltis'
@C0D3D3V
C0D3D3V / convert_to_aiohttp_cookie_jar.py
Last active February 28, 2023 09:25
Convert an http.cookiejar.MozillaCookieJar that uses a Netscape HTTP Cookie File to an aiohttp.cookiejar.CookieJar
@C0D3D3V
C0D3D3V / zip_submissions.py
Created February 7, 2022 12:44
A small script to zip all submissions of a course
import zipfile
import os
import sys
import pathlib
def create_zip(course_path, maintain_hierarchy = False):
ziped_submissions_path = os.path.join(course_path, 'submissions.zip')
# creating zip file with write mode
zip_file = zipfile.ZipFile(ziped_submissions_path, 'w', zipfile.ZIP_DEFLATED)
# Walk through the files in a directory
@C0D3D3V
C0D3D3V / sanitize_filename.py
Last active January 3, 2022 12:35
sanitize_filename
import re
def sanitize_filename(s):
"""Sanitizes a string so it could be used as part of a filename."""
def replace_insane(char):
if char == '\n':
return ' '
elif char == '?' or ord(char) < 32 or ord(char) in [127, 173]:
return ''
elif char == '"':
return '\''
@C0D3D3V
C0D3D3V / moodle_dl_telegram_bot.py
Created October 8, 2021 12:09
Simple Telegram bot that runs the moodle-dl via /start
# Original Author: Davide Mastromatteo
# Source: http://thepythoncorner.com/dev/how-create-telegram-bot-in-Python/
# Make sure you have adapted the `storage_path` and the `TOKEN` below.
import datetime
import math
from moodle_dl.main import run_main
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
# function to handle the /start command
#!/usr/bin/env python3
def berechnen_von_Fourier(funktions_werte: []):
"""
Die Anzahl der funktions_werte muss eine Potenz von 2 sein.
"""
n = len(funktions_werte)
schritt = 1
#!/usr/bin/env python3
def berechnen_von_ANF(funktions_werte: []):
"""
Die Anzahl der funktions_werte muss eine Potenz von 2 sein.
"""
n = len(funktions_werte)
schritt = 1
#!/usr/bin/env python
def enc(block: str, key: str) -> str:
if (len(block) != 5):
print("Length does not match!")
result = ""
for i in range(5):
index = 4 - int(key[i: i + 1])
@C0D3D3V
C0D3D3V / aes.py
Created January 5, 2020 16:10
AES but the way you should not implement it!
#!/usr/bin/env python
""" y selects Array and x selects Elemnt || (xy)"""
substitute_table = [["63", "CA", "B7", "04", "09", "53", "D0", "51",
"CD", "60", "E0", "E7", "BA", "70", "E1", "8C"],
["7C", "82", "FD", "C7", "83", "D1", "EF", "A3",
"0C", "81", "32", "C8", "78", "3E", "F8", "A1"],
["77", "C9", "93", "23", "2C", "00", "AA", "40",
"13", "4F", "3A", "37", "25", "B5", "98", "89"],
["7B", "7D", "26", "C3", "1A", "ED", "FB", "8F",
@C0D3D3V
C0D3D3V / Pixelflut Viewer (only LAN)
Last active December 29, 2018 20:48
Pixelflut Viewer (only LAN) for 35c3 - View the Pixelflut screen with python - not realy optimized
#Made for 35c3 by c0d3d3v
from random import *
import socket
import traceback
import pygame
from pygame import gfxdraw
import time
from Tkinter import Tk, Canvas, PhotoImage, mainloop, Frame
import re
import thread