Skip to content

Instantly share code, notes, and snippets.

@wilfreddv
wilfreddv / BotWriteup.md
Last active November 19, 2018 20:51
Writeup of a Discord bot that runs Python code

Writing a Discord bot that executes Python code

How did it start

Python has become wildly popular in a number of fields, one of which is (chat)bots. Finally, I couldn't resist the urge to write one myself. I wouldn't be myself if it did not involve some dangerous challenge. That's why I challenged myself to write a Discord bot, that lets users run snippets of python code, on my machine.

Chapter 1: Building the skeleton

This was the easy part. After kickstarting my Discord bot knowledge by watching Sentdex' series on YouTube, I managed to throw together a quick bot. Of course, this was still very bare-bones, with only 2 functions: reporting

@wilfreddv
wilfreddv / snake.c
Created August 9, 2018 15:17
Snake in C using Ncurses
#include <ncurses.h>
#include <time.h>
#include <stdlib.h>
#define MINSCRX 150
#define MINSCRY 50
#define UP 0
#define RIGHT 1
@wilfreddv
wilfreddv / brainfuck.c
Last active November 2, 2021 21:47
BrainF*ck interpreter and transpiler to C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Bracemap
{
int left;
int right;
struct Bracemap *next;
@wilfreddv
wilfreddv / text-to-brainfuck.py
Created May 14, 2018 16:38
Python script to turn text into the brainfuck code to print it
#!/usr/bin/python3
'''
Text-to-Brainfuck Generator
This program reads a textfile from stdin and
writes Brainfuck to stdout
The output only uses one block in a Brainfuck,
which is the currently selected block. It leaves
the block with value 0.
'''
@wilfreddv
wilfreddv / twothousandeightyfour.py
Last active April 26, 2018 16:28
A very simple clone of the game '2048' in Python using PyGame
import pygame
import random
S_WIDTH, S_HEIGHT = 400, 400
DIV = 5
T_WIDTH, T_HEIGHT = (S_WIDTH - DIV * 5) // 4, (S_HEIGHT - DIV * 5) // 4
BLACK= (0,0,0)
COLORS = {